ComfyUI GPT Image Direct
Direct OpenAI GPT Image 2.6 and 2.5 (Flare / Sunburst), GPT Image 2, 1.5 and 1-mini generation and editing with your own API key: animated GIF, SVG and markup edits on 2.6, no credits middleman, exact USD cost per run
ComfyUI-GPT-Image-Direct
OpenAI GPT Image 2.6 and 2.5 (Flare and Sunburst), GPT Image 2, 1.5 and 1-mini in ComfyUI, on your own API key.
No Comfy credits, no middleman, no markup. One node, text-to-image and reference editing, exact USD cost printed after every run.
Why
ComfyUI's built-in OpenAI partner node bills through Comfy.org credits. Its own price badge quotes about 1.4x OpenAI's list price, and the credit table on docs.comfy.org implies more than that once you buy credits in packs. This node sends the same request to the same OpenAI endpoint with your key, and reads the real token usage back so you see what each image actually cost.
Node
| Node | What it does |
|------|--------------|
| GPT Image Generate (Direct API) | Text-to-image, or edit up to 16 reference images with an optional inpaint mask. Outputs the image batch, an alpha mask (for transparent backgrounds), a cost_info string and a cache_key. |
Category: AKURATE/GPT Image Direct
Inputs
model:gpt-image-2.6-flare(default; fast, everyday),gpt-image-2.6-sunburst(slower, more precise text and layouts),gpt-image-2.5-flare,gpt-image-2.5-sunburst,gpt-image-2,gpt-image-1.5,gpt-image-1-mini. Flare and Sunburst cost the same per token.quality:low,medium,high,xhigh,max,auto. This is the cost lever. 1024x1024 prices at list rate on 2.6 (measured, same for Flare and Sunburst): low ~$0.025, medium ~$0.043, high ~$0.053, xhigh ~$0.094, max ~$0.21. On 2.5, low and medium are cheaper (~$0.006, ~$0.02). Sunburst is slower, not dearer: max took 174 s against Flare's 37 s.xhighandmaxexist on 2.5 and 2.6 only; other models fall back tohigh.size: presets up to 3840x2160 orcustom(multiples of 16, aspect 1:3 to 3:1, 480 to 3840 px per edge). Legacy models fall back to 1024x1024 for sizes they lack.background:auto,opaque,transparent(forces png or webp; the alpha lands on themaskoutput).output_formatandoutput_compression: png, jpeg or webp (file format only, no effect on cost), plus two 2.6-only formats:gif: an animated GIF. Its frames come out as an IMAGE batch and the .gif is saved untouched. Setframe_count(2 to 16) andframe_duration_ms(20 to 2000). No mask. OpenAI packs the frames into one sheet, and its longest edge must be 3840 px or less, so size presets are ignored andautois sent (512 px frames in testing). Usecustomto set the frame size yourself. Your OpenAI project needs GIF preview access.svg: a vector. Generation only (no references), one per run. The SVG text comes out on thesvgoutput and is saved as a .svg file. ComfyUI has no SVG rasterizer, soimagesgets a grey placeholder. OpenAI renders a raster reference first (billed as usual, set byquality) and then writes the SVG.svg_model(defaultgpt-5.4-mini) picks the text model that writes the SVG. Its tokens are listed incost_infobut not priced, so check your OpenAI usage page for that part. Leavesvg_modelempty if your project has no SVG model selection.
moderation:autoorlow.n: images per run, 1 to 8.seed: not sent to OpenAI (the API has no seed). Changing it forces a re-run and a freshcache_key.image_1toimage_4(optional): individual reference sockets, any sizes.images(optional): a batch appended after them. 16 references total. Any reference switches to the edits endpoint.mask(optional): white = repaint. Needs exactly one reference image. Auto-resized to the reference.reference_max_size: downscale references before upload (2048 default). Smaller references mean fewer input tokens.input_fidelity:auto(not sent),low,high. Edits only. High keeps more of the reference but costs more input tokens.complexity(2.6 only):auto(not sent, the API useshigh),low,medium,high. Sets how much the model plans before rendering, separately fromquality. There is no extra fee, and lower settings are faster.markup+markup_mask(optional, 2.5 and 2.6): markup-guided edits. Draw circles or sketches on a separate transparent PNG overimage_1and load it with Load Image. Wire its IMAGE tomarkupand its MASK tomarkup_mask, then describe the change in the prompt. Markup can't be combined withmask, and it is resized toimage_1automatically.api_key,api_base,timeout_sec: override the key, point at an OpenAI-compatible base URL (Azure, fal, a proxy), and give slow max-quality 4K runs more time.
Outputs
images: IMAGE batch (GIF frames in order; a grey placeholder for svg).mask: MASK, 1 where the image is transparent (same convention as Load Image).cost_info:"$0.0528 USD (exact) | gpt-image-2.5-flare high 1536x1024 x1 | 14.2s | tokens: 24 text-in, 0 img-in, 0 cached, 1756 out | gpt_image_20260919_120000_00.png". Exact when the API returnsusage, otherwise labelled(estimated).cache_key: deterministic string of every input, for Hash Vault in ComfyUI-API-Optimizer. The 2.6 settings are added only when changed from their defaults, so keys from older workflows stay the same.svg: the SVG source whenoutput_formatis svg, otherwise empty.
Images are also saved to output/gpt_image_direct/.
Installation
- Copy this folder into
ComfyUI/custom_nodes/(or clone it there). - No extra pip installs. It uses
requestsand Pillow, which ComfyUI already ships. - Restart ComfyUI.
API key
Resolution order:
- The
api_keyinput on the node OPENAI_API_KEYenvironment variableopenai_api_key.txtin your ComfyUI root (next tomain.py)
Get a key at https://platform.openai.com/api-keys. GPT Image models need a one-time Organization Verification at https://platform.openai.com/settings/organization/general. Without it the node reports the 401/403 with a pointer to that page.
Keeping it cheap
quality=lowfor iteration,mediumfor most finals.highis 9x low,maxis 35x low.- Keep references at 1024 unless the edit needs detail. Every reference image costs input tokens on every call.
- Leave
input_fidelityonautounless the reference must survive pixel-exact. - Wide and tall presets (1536x1024, 1024x1536) often cost slightly less than square at the same quality.
- For big offline batches, OpenAI's Batch API is half price. That is a separate async workflow, not this node.
Pricing reference
USD per 1M tokens, OpenAI list price as of 2026-11-08:
| Model | Text in | Cached in | Image in | Image out | |-------|---------|-----------|----------|-----------| | gpt-image-2.6-flare / sunburst | 5.00 | 1.25 | 8.00 | 30.00 | | gpt-image-2.5-flare / sunburst | 5.00 | 1.25 | 8.00 | 30.00 | | gpt-image-2 | 5.00 | 1.25 | 8.00 | 30.00 | | gpt-image-1.5 | 5.00 | 1.25 | 8.00 | 32.00 | | gpt-image-1-mini | 2.00 | 0.20 | 2.50 | 8.00 |
The node multiplies the usage counts the API returns by this table. Update PRICE_PER_1M in gpt_image_direct_nodes.py if OpenAI changes prices.
Testing
python tools/test_gpt_image_direct.py # offline, mocked HTTP, no spend
python tools/test_gpt_image_direct.py --live # plus one real low-quality 2.6 Flare call (~$0.025)
License
MIT