ComfyUI Node

Custom GPTImage1 API Node

GPT Image 1 as a first-class IMAGE node — generation and inpainting

By AhBumm·Created 2 years ago·Updated 3 months ago· 11
Custom GPTImage1 API Node
  • image
  • mask
  • image
  • seed
prompt
api_urlhttps://api.openai.com/v1
api_keyenter your key here...
modelgpt-image-1
seed0
qualitylow
sizeauto
n1

Here's the thing most of this pack's image nodes make you do: they hand you a base64 string and you have to convert it. This one doesn't. The GPT Image 1 node calls OpenAI's gpt-image-1 and returns an actual IMAGE tensor, ready to preview. It also does image editing - feed it a reference image and a mask and it becomes an inpainting node, all through the API. If you're going to pay OpenAI for image generation, this is the nicest wrapper in the pack to do it through.

How it works

It uses the OpenAI Python SDK against api_url/api_key (defaults to https://api.openai.com/v1, no third-party detour). Two paths in the code:

  • No input imageclient.images.generate(). Plain text-to-image.
  • With image (and optionally mask)client.images.edit(). It converts your tensor to a PNG, and if you supply a mask it turns it into an RGBA image where the mask's transparent areas are what gets regenerated - the standard gpt-image-1 editing convention. Inputs get downscaled to a sane size before upload so you're not paying to ship a 4K tensor.

The response is decoded straight into an IMAGE tensor - no string-to-image conversion step needed. That's the single biggest quality-of-life difference versus the DALL-E node in this pack.

The inputs that matter

  • prompt - text for generation or the edit instruction.
  • model - gpt-image-1 by default.
  • quality - low, medium, high. The tooltip is honest: quality drives both cost and generation time. low is fine for drafts; high is where the money goes.
  • size - auto, 1024x1024, 1024x1536, or 1536x1024.
  • n - 1 to 8 images.
  • image / mask (optional) - the editing inputs. The mask must match the image's dimensions or the node throws.
  • seed - the tooltip says it flat out: "not implemented yet in backend". Don't fight it; GPT Image 1 isn't seed-reproducible right now.

Outputs: image (IMAGE) and seed (INT, an echo for bookkeeping).

Installing it

It's one node in the AhBumm/ComfyUI_BillBum_APIset_Nodes pack. ComfyUI Manager → search "billbum" → install, or:

cd ComfyUI/custom_nodes
git clone https://github.com/AhBumm/ComfyUI_BillBum_APIset_Nodes.git
cd ComfyUI_BillBum_APIset_Nodes
pip install -r requirements.txt

Then restart ComfyUI. Only Python deps (openai, pillow, requests, numpy, tenacity), no models.

Common issues

  • Editing fails when image and mask disagree. The node checks mask shape against image size and bails with a clear error. If your mask came from a different-sized source, resize it first.
  • No mask + image still works, but differently. With just an image (no mask) it does a full re-imagine of the whole picture rather than a localized edit. Know which mode you're in.
  • The cost ladder. high quality on a 1536px image adds up fast when you're iterating. low/medium are your friends during exploration.
  • Content moderation. GPT Image 1 has OpenAI's filtering baked in. Some prompts just won't generate, and the node has nothing to do with it.

Also worth knowing: the API accepts mask per-image batch constraints - multiple images with a mask throw, by design, since a single mask can't meaningfully edit a batch. Keep edits to one image at a time.

CategoryBillBum_API

Inputs (10)

NameTypeDefaultDescription
promptSTRINGText prompt for GPT Image 1
api_urlSTRINGhttps://api.openai.com/v1Costume API URL
api_keySTRINGenter your key here...Costume API key
modelSTRINGgpt-image-1Model name
seedoptINT00–2147483647not implemented yet in backend
qualityoptCOMBOlowImage quality, affects cost and generation time.
sizeoptCOMBOautoImage size
noptINT11–8How many images to generate
imageoptIMAGEOptional reference image for image editing.
maskoptMASKOptional reference image for image editing.

Outputs (2)

NameTypeDescription
imageIMAGE
seedINT