Nodes/comfyui-gpt-image-2/GPT Image 2 — Edit
ComfyUI Node

GPT Image 2 — Edit

Nine reference images and a mask, one API call

By graedance·Created 4 months ago·Updated 4 months ago· 0
GPT Image 2 — Edit
  • mask
  • image_1
  • image_2
  • image_3
  • image_4
  • image_5
  • image_6
  • image_7
  • image_8
  • image_9
  • IMAGE
modelgpt-image-2
prompt
size1024x1024
qualityhigh
output_formatpng
n1
backgroundauto
output_compression100
api_key

This is the node that made GPT Image 2 worth putting in a workflow at all. Generate is nice, but any API image model can write "a cat" convincingly. Edit is where the closed model's lead over local shows: it takes your existing image, an instruction, and up to nine reference images in one call, and hands back an edited result that ComfyUI treats like any other IMAGE output.

If you've tried to do character consistency or product edits with open-weight models - a LoRA here, an inpainting pass there, fighting for a dozen generations until the face sticks - you know why this is attractive. GPT Image 2 composes across the reference images in a single shot. One light aside, but genuinely: for spritesheets and multi-character scenes, local models "are not even close," as one r/comfyui user put it while trying to train a Qwen-based equivalent. That gap is the whole reason to pay per call.

How it works

Under the hood it's the same pack and the same API-key plumbing as Generate, but it calls OpenAI's images.edit() instead. Each connected image_1 through image_9 input is converted to a PNG and passed along; if you connect more than one, they go to the API as a list and the model composes across them. The result comes back base64-encoded and is decoded back into a ComfyUI IMAGE tensor.

The one mechanic worth understanding before you blame the node: the optional mask input is applied to image_1 only. That's OpenAI's mask semantics, not a bug - the node converts your MASK to an RGBA PNG (alpha = 255 − mask) and ships it with the first image. So if you're masking, put the image you want edited in the first slot. Connect no images at all and you get a clean error telling you to plug in image_1.

Inputs to care about:

  • image_1 … image_9 - plain IMAGE inputs. image_1 is the base; the rest are references.
  • prompt - the edit instruction, in plain language ("change the shirt to navy, keep the pose").
  • mask - optional, applied to image_1 only, as above.
  • size / quality / n / output_format - the same set as Generate; size constraints are identical, so don't pick a 4K size with a legacy 1.x model.

Note the moderation input from Generate is absent here - Edit just doesn't expose it.

Wiring it in

Typical flow: Load Image → image_1, Load Image → image_2 (reference), prompt, then the Edit node's IMAGE output into a preview or a Save Image node. If you want to mask, connect an image through a MaskEditor or MaskFromColor first. Everything downstream is standard ComfyUI, which is the whole point of an API node - the canvas never knows the generation happened on someone else's server.

Install and cost

Same install as its sibling in this pack: Manager → Install via Git URL, or

cd ComfyUI/custom_nodes
git clone https://github.com/graedance/comfyui-gpt-image-2.git
cd comfyui-gpt-image-2
pip install -r requirements.txt

then restart. Dependencies are just openai>=1.54.0 and Pillow. Set OPENAI_API_KEY as an environment variable rather than pasting it into the node - the pasted version is saved into the workflow JSON.

Every edit is a billed call, and reference images count as input tokens on top of the output image cost. Run the pack's Estimate Cost node with input_images set to however many references you're feeding - the "image in" line is real money at $8/M tokens. And remember the API-node deal: your images and prompt go to OpenAI's servers, subject to their moderation. For a vetted-but-metered alternative, Comfy's own Partner Nodes cover the same models on prepaid credits, but they need a Comfy account; this pack just needs your key.

CategoryOpenAI/GPT-Image-2

Inputs (19)

NameTypeDefaultDescription
modelCOMBOgpt-image-25 options: gpt-image-2, gpt-image-2-2026-04-21, gpt-image-1.5, gpt-image-1, gpt-image-1-mini
promptSTRING
sizeCOMBO1024x102410 options: auto, 1024x1024, 1024x1536, 1536x1024, 1792x1024, 1024x1792, +4
qualityCOMBOhigh4 options: auto, low, medium, high
output_formatCOMBOpng3 options: png, jpeg, webp
nINT11–8
backgroundCOMBOauto2 options: auto, opaque
output_compressionINT1000–100
maskoptMASK
api_keyoptSTRING
image_1optIMAGE
image_2optIMAGE
image_3optIMAGE
image_4optIMAGE
image_5optIMAGE
image_6optIMAGE
image_7optIMAGE
image_8optIMAGE
image_9optIMAGE

Outputs (1)

NameTypeDescription
IMAGEIMAGE