Nodes/ComfyUI_OpenAI_GPTImage2/GPT-Image-2 Image Edit (Responses API, file cache)
ComfyUI Node

GPT-Image-2 Image Edit (Responses API, file cache)

This GPT-Image-2 Edit Node's Real Trick Is the File Cache

By kevinzilin·Created 3 months ago·Updated 3 months ago· 0
GPT-Image-2 Image Edit (Responses API, file cache)
  • image
  • mask
  • image
  • url
  • response
prompt
api_key
width1024
height1024
qualityauto
responses_modelgpt-5.5
image_modelgpt-image-2
proxy
n1
custom_responses_model
custom_image_model

Of the three nodes in kevinzilin/ComfyUI_OpenAI_GPTImage2, this one has the scariest name: "GPT-Image-2 Image Edit (Responses API, file cache)." Strip the marketing and it's simple - an image edit node that uploads your input once, remembers the file ID, and lets a two-model pipeline do the editing. If you edit the same image repeatedly in one session, the cache is the difference between fast and sitting through another upload.

It's an edit node for OpenAI's gpt-image-2, but routed through the Responses API instead of the plain Images edit endpoint. The Responses route means two models in play, and the README's table is worth internalizing:

  • responses_model - the brains. A general model like gpt-5.5 (default) that understands your request and decides to call the image_generation tool.
  • image_model - the hands. The actual image model, gpt-image-2, that renders the edit. Set it to auto to let the API choose; use the custom_responses_model / custom_image_model string fields only when you set the matching dropdown to custom.

Mechanically it's clean: the node hashes each input image (SHA256 of the PNG bytes), uploads it via files.create(..., purpose="vision"), and stores the returned file_id in a module-level dict keyed by that hash. Same pixels come through again, same session, and it reuses the cached ID - no re-upload. The mask, if you feed one in, gets uploaded as its own file and passed to the tool as input_image_mask. The request streams, and the node pulls the finished edit from the image_generation_call result, decodes base64, and hands you an IMAGE tensor.

Why pick this over the plain GPTImage2Edit sibling in the same pack: batching and reuse. It takes up to 16 input images, so multi-image fusion edits work ("merge these three references" is GPT-Image-2's calling card), and iterating on the same source skips the upload each pass. One caveat straight from the author: the cache is in-memory only. Restart ComfyUI and it's gone, so the first edit after a restart pays the upload cost again.

Inputs that matter:

  • image - required IMAGE input; wire in whatever you want edited. Up to 16 frames.
  • prompt (multiline) - what to change.
  • api_key - paste your OpenAI key into the node. It's stored in the workflow JSON, so scrub it before sharing.
  • mask (optional) - a MASK input if you have one. But read this: masking here is prompt-guided. The author's own words - the mask helps guide the edit, "exact mask boundaries are not guaranteed." Don't expect pixel-perfect inpainting like a local model; expect a nudge.
  • quality, width/height, n, proxy - same meaning as the rest of the pack. The size rules apply identically: multiples of 16, max edge 3840px, 0.65–8.3MP, aspect ratio ≤ 3:1.

Outputs are the pack's standard three: image (the edit, ready to wire into anything downstream), url (reports "(base64)" because responses stream inline), and response - a text summary of which models ran, how long it took, and the file IDs used, which is genuinely useful for cost-checking.

Install is identical to the rest of the pack. ComfyUI Manager, search "ComfyUI_OpenAI_GPTImage2", or:

cd ComfyUI/custom_nodes
git clone https://github.com/kevinzilin/ComfyUI_OpenAI_GPTImage2
cd ComfyUI_OpenAI_GPTImage2
E:\ComfyUI_windows_portable\python_embeded\python.exe -m pip install -r requirements.txt

Then restart. The requirements are openai>=2.38.0 and httpx[socks] on top of what ComfyUI already ships - no model downloads, the models live at OpenAI.

Common problems: the same key/size/proxy errors as the T2I node, plus "Too Many Images" if you feed more than 16, and "No Image in Response" when the API returns fine but empty - usually a model-field problem. If iteration suddenly feels slow, remember the cache is per-process; a restart silently dropped it. And yes, the client disables TLS verification for proxy compatibility, so don't route it through a network you don't trust.

Bottom line: this is the node from the pack that rewards reading the README, because the two-model dropdowns confuse people the most and the file cache is the feature that saves the most time. Editing or fusing images with gpt-image-2 in a session, this is the one to reach for. Just remember the other half of the API-node bargain: your image is leaving the machine to get edited, OpenAI's filters and all.

CategoryOpenAI/GPT-Image-2

Inputs (13)

NameTypeDefaultDescription
imageIMAGE
promptSTRING
api_keySTRING
widthINT1024256–3840
heightINT1024256–3840
qualityCOMBOauto4 options: auto, high, medium, low
responses_modelCOMBOgpt-5.55 options: gpt-5.5, gpt-5.4, gpt-5.4-mini, gpt-5.4-nano, custom
image_modelCOMBOgpt-image-23 options: gpt-image-2, auto, custom
maskoptMASK
proxyoptSTRING
noptINT11–4
custom_responses_modeloptSTRING
custom_image_modeloptSTRING

Outputs (3)

NameTypeDescription
imageIMAGE
urlSTRING
responseSTRING