GPT Image 1 (Direct API)
OpenAI's Image Model, Wired Into Your Graph
- image
- mask
- IMAGE
The name is not a lie - this node really does call OpenAI's API directly, and it really needs your key. GPTImage1 generates images with OpenAI's gpt-image-1 model straight from ComfyUI and hands you the result as a normal IMAGE tensor, ready for every downstream node you already know. No local model, no VRAM, no checkpoints. Just a prompt, a key, and a per-image bill.
Why bother, when you could run Flux locally? Because gpt-image-1 is genuinely good at the things local open-weight models still stumble on - text rendering inside images, following detailed instructions, and editing existing pictures with a mask. The standard pattern people actually build (this is a real thing r/comfyui has discussed since the model launched) is hybrid: generate an edit with gpt-image-1, then run the result through Flux or an upscaler for refinement. Or feed it an image your local stack produced and let it do the cleanup an open model can't. One API call, real capability, no trade-offs on your GPU.
How it works
It's a thin HTTP wrapper. Text-to-image posts to https://api.openai.com/v1/images/generations; the moment you supply both an image and a mask, it switches to /images/edits and sends them as multipart files. The response comes back as image bytes, which the node decodes into a proper ComfyUI IMAGE tensor with correct batch dimension - so it plugs into a preview node, a save node, or an upscaler like any locally generated image.
Two details worth knowing from the source. Input images are auto-downscaled to fit within 1536×1024 before upload (with a Lanczos resize), so you don't blow the API's input limit by accident. And the mask semantics match what you'd expect: white = the area to edit, black = leave it alone.
The inputs and outputs that matter
- prompt (multiline) - the text prompt for gpt-image-1. Required.
- api_key - leave blank to fall back to the
OPENAI_API_KEYenvironment variable. If neither is set, it errors with a clear message.
Then the optional dials, and they mostly map 1:1 to OpenAI's API:
- quality -
low(default),medium,high. Low is cheap and fast; high costs more and takes longer. Start low. - size -
auto,1024x1024,1024x1536,1536x1024. - moderation -
low(default) orauto. Low is less restrictive filtering; auto is OpenAI's standard. Note that OpenAI's moderation has a history of being unpredictable - it's a platform filter you don't control. - background -
opaqueortransparent. - seed - passed through, but the tooltip is honest: "check model support." gpt-image-1's seed behavior is not a guarantee.
- n - how many images, 1–8.
- image + mask - the edit path. Both are required together; supplying only one raises an error.
Output is a single IMAGE tensor.
Where people get burned
The edit path only accepts batch size 1 - one image, one mask. If you feed it a multi-frame tensor (say, something that came out of a video node), it'll throw. The source even carries special handling for a bizarre high-channel-count tensor case, which tells you people have fed this node some weird stuff. Keep it to a single still image.
The other trap is the bill. Every generation is a paid API call; crank n to 8 on high quality and you've made an expensive mistake. Set quality low, watch n, and treat this node as the specialist it is - use it where it beats local models, not for bulk generation.
Installing it
It ships in the oshtz Nodes pack alongside four other nodes. ComfyUI Manager: search "oshtz". Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/oshtz/ComfyUI-oshtz-nodes.git
cd ComfyUI-oshtz-nodes
pip install -r requirements.txt
Restart ComfyUI. Dependencies are just requests, pydantic, Pillow, and numpy - no model downloads. The only thing you need to add is OPENAI_API_KEY, either as an environment variable or in the node. First run takes a few seconds (the API can be slow, and the node uses a 120-second timeout), then the image lands in your graph like it was always there.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | Text prompt for the gpt-image-1 model | |
| api_key | STRING | Optional. Leave blank to use OPENAI_API_KEY. | |
| seedopt | INT | 00–2147483647 | Seed for generation (check model support) |
| qualityopt | COMBO | low | Image quality, affects cost and generation time. |
| backgroundopt | COMBO | opaque | Return image with or without background |
| moderationopt | COMBO | low | Content moderation level. 'low' (default) for less restrictive filtering, 'auto' for standard filtering. |
| sizeopt | COMBO | auto | Image size |
| nopt | INT | 11–8 | How many images to generate |
| imageopt | IMAGE | Optional reference image for editing (requires 'mask' too) | |
| maskopt | MASK | Optional mask for inpainting (requires 'image' too, white=edit area) |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |