Nodes/Imagent/πŸ€– Imagent: OpenAI Image Edit
ComfyUI Node

πŸ€– Imagent: OpenAI Image Edit

Inpaint, edit, and stitch up to 16 images β€” with a model you'll never download

By agarzonΒ·Created 2 months agoΒ·Updated 2 months agoΒ· 0
πŸ€– Imagent: OpenAI Image Edit
  • images
  • mask
  • image
β—„promptβ–Ί
β—„modelβ–Ύβ–Ί
β—„qualityautoβ–Ί
β—„output_formatpngβ–Ί
β—„moderationautoβ–Ί
β—„n1β–Ί

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, leave mask disconnected. "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 images input 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 transparent background and an input_fidelity widget (high default - how closely to preserve the reference - or low if you want the model to roam).
  • quality and n - same as the generate node; n 1–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.

CategoryImagent

Inputs (8)

NameTypeDefaultDescription
promptSTRINGDescribe the edit to apply to the reference image(s).
modelCOMBOOpenAI gpt-image model. Switching this changes the options below.
imagesCOMFY_AUTOGROW_V3Reference image(s) to edit; grows up to 16. A mask (if used) applies to the first image and requires exactly one image.
qualityCOMBOautoRendering quality. 'auto' lets the model decide; higher quality costs more.
output_formatCOMBOpngImage file format returned by the API.
moderationCOMBOautoContent moderation strictness. 'auto' (default) or 'low'. Sent only when not 'auto'.
nINT11–8How many images to generate (1-8).
maskoptMASKInpaint mask: white marks the region to edit. Requires a single reference image.

Outputs (1)

NameTypeDescription
imageIMAGEβ€”