Custom GPTImage1 API Node
GPT Image 1 as a first-class IMAGE node — generation and inpainting
- image
- mask
- image
- seed
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 image →
client.images.generate(). Plain text-to-image. - With
image(and optionallymask) →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-1by default. - quality -
low,medium,high. The tooltip is honest: quality drives both cost and generation time.lowis fine for drafts;highis where the money goes. - size -
auto,1024x1024,1024x1536, or1536x1024. - 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.
highquality on a 1536px image adds up fast when you're iterating.low/mediumare 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.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | Text prompt for GPT Image 1 | |
| api_url | STRING | https://api.openai.com/v1 | Costume API URL |
| api_key | STRING | enter your key here... | Costume API key |
| model | STRING | gpt-image-1 | Model name |
| seedopt | INT | 00–2147483647 | not implemented yet in backend |
| qualityopt | COMBO | low | Image quality, affects cost and generation time. |
| sizeopt | COMBO | auto | Image size |
| nopt | INT | 11–8 | How many images to generate |
| imageopt | IMAGE | Optional reference image for image editing. | |
| maskopt | MASK | Optional reference image for image editing. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| seed | INT | — |