π€ Imagent: OpenAI Image Edit
Inpaint, edit, and stitch up to 16 images β with a model you'll never download
- images
- mask
- image
ImagentOpenAIImageEdit is the edit sibling of ImagentOpenAIImage - same pack, same BYOK idea, different job. Instead of generating from text, it sends your reference image(s) and a prompt to OpenAI's images.edit endpoint, and because GPT Image is natively multimodal, the model actually understands what it's looking at. You get the one thing local pipelines still struggle with: an edit node where "make the door green and keep everything else" usually works on the first try.
Three modes, one node
- Plain edit - connect one image to
images, write a prompt, leavemaskdisconnected. "Remove the background clutter," "change her jacket to leather." This is the everyday mode. - Inpaint - connect one image and a mask. White marks the region to edit - the standard ComfyUI mask convention, so anything you already use to build masks feeds in directly. The node converts it to the alpha format OpenAI wants, so white pixels become the editable region. Exactly one reference image is required here.
- Multi-reference compose - the
imagesinput auto-grows as you wire in more slots, up to 16 reference images. Feed it a person, a location, a prop, and a prompt that says "combine these." This is the closest thing to Nano Banana Pro's multi-image magic that OpenAI's current API gives you. Mask is not supported in multi-image mode.
There's no seed on this node either - same as the generate node, OpenAI's edit API isn't reproducible. Change any input to regenerate; otherwise ComfyUI's input caching returns the cached result.
The inputs that matter
- prompt - describes the edit, not a new image. "Inpaint" is implied; don't restate the whole scene.
- images - the auto-growing reference slots. At least one is required, and the node handles the plumbing: references get downscaled to fit the API's pixel budget before upload, so a giant ComfyUI canvas won't get rejected.
- mask (optional) - white = region to edit. Only valid with a single reference image.
- model - dynamic, like the generate node. On gpt-image-2 you get hi-res and custom sizes; gpt-image-1.x adds a
transparentbackground and an input_fidelity widget (highdefault - how closely to preserve the reference - orlowif you want the model to roam). - quality and n - same as the generate node;
n1β8 returns a batch.
Output is a single image IMAGE tensor, ready to feed an upscaler, a face-fix pass, or a save node.
Install
Identical to its sibling - it ships in the same pack:
cd ComfyUI/custom_nodes
git clone https://github.com/agarzon/ComfyUI-Imagent.git
pip install -r ComfyUI-Imagent/requirements.txt
Or just search Imagent in ComfyUI Manager and hit Install. Restart either way. Dependencies are only openai, Pillow, and numpy. Requires ComfyUI β₯ 0.23.0 for the dynamic-model IO schema - update ComfyUI first if the node won't appear. Set your key via OPENAI_API_KEY env var or a config.json in the extension folder.
Troubleshooting
The node never crashes the queue - a failed call returns an empty/black image and logs the real error to the ComfyUI console. That's where you'll find:
- "requires at least one reference image" - you forgot to wire
images. - "mask inpainting requires a single reference image" - you connected a mask plus multiple images; the API only inpaints one at a time.
- 403 - your OpenAI org probably needs API Organization Verification before gpt-image models can be called; the dashboard will tell you.
- 429 - quota hit. Edits cost per call, and multi-reference requests are the priciest ones here. Watch the bill.
One last thing: every image and prompt you feed this node goes to OpenAI's servers, subject to their logging and moderation. If the source material can't leave your machine, keep the edit local. Otherwise - this is the fastest way to get gpt-image's editing brain into a workflow, without Comfy's proxy markup.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | Describe the edit to apply to the reference image(s). | |
| model | COMBO | OpenAI gpt-image model. Switching this changes the options below. | |
| images | COMFY_AUTOGROW_V3 | Reference image(s) to edit; grows up to 16. A mask (if used) applies to the first image and requires exactly one image. | |
| quality | COMBO | auto | Rendering quality. 'auto' lets the model decide; higher quality costs more. |
| output_format | COMBO | png | Image file format returned by the API. |
| moderation | COMBO | auto | Content moderation strictness. 'auto' (default) or 'low'. Sent only when not 'auto'. |
| n | INT | 11β8 | How many images to generate (1-8). |
| maskopt | MASK | Inpaint mask: white marks the region to edit. Requires a single reference image. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | β |