Comfyui_gpt_image_1_edit
Masks, image refs, and 'make it bluer'
- image
- mask
- edited_image
- response
- chats
Comfyui_gpt_image_1_edit is the image-editing half of the pack's gpt-image-1 pair: you feed it an image, type what you want changed, and it sends the whole thing off to the cloud and hands back an edited tensor. The genuinely interesting part is the conversation mode. With clear_chats set to False, it remembers its last output and feeds it back as context - so you can run the graph repeatedly with "more contrast", "now make it blue", "actually keep the vase" and it iterates on its own previous work like you're talking to an artist instead of re-rolling the whole image.
This matters more than it sounds. The KB's inpainting essay makes the point that instruction-based editing has been eating classic masked inpainting's lunch since 2025 - but gpt-image-1's real trick is that it will honor a mask when you give it one, and leave the rest of the frame alone. That's the best of both worlds.
How it works
The node encodes your image(s) as PNGs and POSTs a multipart form to https://ai.comfly.chat/v1/images/edits. A single image goes in as image; multiple images become image[] entries, which act as reference images. If you wire in a mask, it's converted to an RGBA PNG where the alpha channel encodes the mask and posted alongside. Inputs are downscaled to fit ~1536×1024 (lanczos) before upload, so big batches don't balloon the request. Requests retry with exponential backoff, and the timeout grows 1.5× per attempt up to a 1200s ceiling - the author knows the upstream is slow and built for it.
Inputs that matter
image- required. Any IMAGE tensor, so it chains after Load Image or another generation node.prompt- required, multiline. Say what to change.mask- optional MASK input, e.g. from a Mask Editor. Two hard rules in the code: you can't use a mask with multiple images, and the mask must match the image's dimensions, or it errors out.clear_chats-True(default) = stateless, edit only what you feed in.False= the conversational iteration mode above, and it also lets extra images in the batch act as references.quality/size/background/output_format/output_compression- same official gpt-image-1 knobs as the generation node;background: transparentworks here too.max_retries(default 5) andinitial_timeout(default 900s) - tune if your group is flaky or your image is huge.
Outputs: edited_image (the IMAGE), response (a STRING log of the call), and chats (the accumulated conversation history).
The key gotcha: key groups again
Like Comfyui_gpt_image_1, this node needs a key from one of the official groups on ai.comfly.chat (the author points at ssvip as the current best value), not the cheap reverse-engineered group that powers ComfyuiChatGPTApi. Wrong tier, API error - every time. If you only have the free $0.20 credit from signup, you're on the reverse tier and this node won't take it.
Install
One repo, three nodes, one install. ComfyUI Manager → search "Comfyui-chatgpt-api" → Install → restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/ainewsto/Comfyui-chatgpt-api
Restart. The requirements (aiohttp, requests, numpy, Pillow, torch, GitPython) are all standard - no model files, no GPU requirement, nothing to download.
Troubleshooting
- "Cannot use a mask with multiple images" - send one image per masked call. That's a hard limit in the code.
- "Mask and Image must be the same size" - resize your mask to match the input before wiring it in.
- Hangs for 15+ minutes - with a 900s initial timeout and 5 retries, a dead request can sit there a while. Drop
max_retriesorinitial_timeoutif your upstream is actually down. - API error out of the gate - verify you're on an official key group, not the reverse one.
Worth it? If you already keep gpt-image-1 generation in your workflow, the edit node turns it into an iterative editing loop with real mask support - and that's something open-weights editing still doesn't do as cleanly.
Inputs (15)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| prompt | STRING | — | |
| maskopt | MASK | — | |
| api_keyopt | STRING | — | |
| modelopt | STRING | gpt-image-1 | — |
| nopt | INT | 11–10 | — |
| qualityopt | COMBO | auto | 4 options: auto, high, medium, low |
| sizeopt | COMBO | auto | 4 options: auto, 1024x1024, 1536x1024, 1024x1536 |
| seedopt | INT | 00–18446744073709550000 | — |
| clear_chatsopt | BOOLEAN | true | — |
| backgroundopt | COMBO | auto | 3 options: auto, transparent, opaque |
| output_compressionopt | INT | 1000–100 | — |
| output_formatopt | COMBO | png | 3 options: png, jpeg, webp |
| max_retriesopt | INT | 51–10 | — |
| initial_timeoutopt | INT | 90060–1200 | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| edited_image | IMAGE | — |
| response | STRING | — |
| chats | STRING | — |