Imagent
ComfyUI nodes for OpenAI gpt-image generation and editing
Nodes (2)
β¨ Features
- πΌοΈ Two nodes β Imagent: OpenAI Image (text-to-image) and Imagent: OpenAI Image Edit (edit, inpaint, multi-reference compose).
- π€ Current gpt-image models β
gpt-image-2,gpt-image-1.5,gpt-image-1. - βοΈ Text-to-image with full control over size, quality, background, and output format.
- π¨ Edit + inpaint (mask) β supply a mask to repaint a specific region; white pixels mark the area to edit.
- π Multi-reference compositing β feed up to 16 reference images to the edit node (auto-growing input).
- ποΈ Per-model UI β the
modelwidget is dynamic: switching models swaps the size list and shows only the options that model supports (no invalid combos). - ποΈ Up to 8 images per call β batch generation in a single node execution.
- π‘οΈ Optional content moderation β
auto(default) orlow. - π BYOK β your own OpenAI API key, your own costs. Unlike ComfyUI's built-in OpenAI nodes (which route through ComfyUI's paid proxy), Imagent calls the OpenAI API directly. No proxy, no per-image credit markup.
- π« DALLΒ·E intentionally excluded β all DALLΒ·E models were shut down by OpenAI in 2026.
π¦ Installation
Requires ComfyUI β₯ 0.23.0 β the nodes use the
comfy_apiIO schema (DynamicCombo) for the per-model UI.
Option A β ComfyUI Manager (recommended)
Open ComfyUI Manager β Custom Nodes Manager, search for Imagent, click Install, and restart ComfyUI.
Option B β git clone
cd ComfyUI/custom_nodes
git clone https://github.com/agarzon/ComfyUI-Imagent.git
pip install -r ComfyUI-Imagent/requirements.txt
Restart ComfyUI.
π API key
Imagent reads your key in this order:
- Environment variable (preferred): set
OPENAI_API_KEYbefore launching ComfyUI. config.json: copyconfig.example.jsonβconfig.json(gitignored) in the extension directory and add your key.
Note: OpenAI may require API Organization Verification before gpt-image models can be called. If your key is valid but you receive an authorization error, complete verification in the OpenAI dashboard β the error message logged to the ComfyUI console will tell you.
π§© Nodes
π€ Imagent: OpenAI Image
Text-to-image generation via images.generate.
| Parameter | Type | Values / Notes |
|---|---|---|
| prompt | STRING | Text description of the image to generate |
| model | DynamicCombo | gpt-image-2 (default), gpt-image-1.5, gpt-image-1. Switching the model swaps the options below. |
| β³ size | COMBO | gpt-image-2: auto, the three base sizes, five high-res presets, and custom. gpt-image-1.x: auto + the three base sizes only. |
| β³β³ custom_width / custom_height | INT | Appear only when size = custom. 1024β3840, step 16; both multiples of 16; aspect β€ 3:1; total pixels 655,360β8,294,400. |
| β³ background | COMBO | gpt-image-2: auto, opaque. gpt-image-1.x: auto, opaque, transparent (needs png/webp). |
| quality | COMBO | auto, low, medium, high |
| output_format | COMBO | png, jpeg, webp |
| output_compression | INT | 0β100. Applied only for jpeg and webp. |
| moderation | COMBO | auto (default), low. Sent only when not auto. |
| n | INT | 1β8 images per call |
Rows marked β³ live inside the dynamic model widget (appear only for models that support them); β³β³ rows are nested one level deeper and appear only when their parent option is selected.
No
seedwidget: OpenAI's image API has no seed, so it can't make outputs reproducible. ComfyUI's normal input-based caching applies β re-queuing an unchanged graph returns the cached image; change the prompt (or any input) to regenerate.
Output: image (IMAGE tensor, batch of n). Errors are logged to the ComfyUI console.
π€ Imagent: OpenAI Image Edit
Image editing, inpainting, and multi-reference compositing via images.edit.
| Parameter | Type | Values / Notes |
|---|---|---|
| prompt | STRING | Description of the desired edit |
| model | DynamicCombo | Same three models; switching swaps the options below. |
| β³ size | COMBO | Same as the generate node (hi-res + custom on gpt-image-2; base sizes on gpt-image-1.x). |
| β³β³ custom_width / custom_height | INT | Appear only when size = custom (gpt-image-2). Same rules as the generate node. |
| β³ background | COMBO | gpt-image-2: auto/opaque; gpt-image-1.x: adds transparent. |
| β³ input_fidelity | COMBO | gpt-image-1.x only. high (default) or low β how closely to follow the reference image. |
| images | IMAGE (auto-grow) | Reference image(s) to edit β grows up to 16 slots; at least one required. |
| quality | COMBO | auto, low, medium, high |
| output_format | COMBO | png, jpeg, webp |
| moderation | COMBO | auto (default), low |
| n | INT | 1β8 images per call |
| mask (optional) | MASK | White = region to edit. Inpainting requires exactly one reference image. |
Rows marked β³ live inside the dynamic model widget; β³β³ rows appear only when their parent option is selected.
Output: image (IMAGE tensor, batch of n). Errors are logged to the ComfyUI console.
Quick-start recipes:
- Edit: connect one image to
images, write aprompt, leavemaskdisconnected. - Inpaint: connect one image +
mask(white = area to repaint), write aprompt. - Multi-reference: connect several images (the input grows as you wire them up), write a
prompt. Mask not supported for multi-image calls.
π οΈ Development
python3 -m venv .venv
.venv/bin/pip install -e ".[test]"
.venv/bin/pytest -q
Smoke testing with Docker
Set your API key first β either export OPENAI_API_KEY in your shell, or copy config.example.json β config.json and add your key. Then:
docker compose -f docker/docker-compose.yml up -d --build
ComfyUI will be available at http://localhost:8188 with Imagent pre-loaded. For Python changes, restart the container. The repo is bind-mounted into the container's custom_nodes/ directory.
πΎ The story behind the name
Imagent = image + agent. A small model-driven agent that images things into existence β and edits them once they're there.
It comes from Wallrus, whose own name blends a social wall with a walrus. Two friendly ideas, one tool: straightforward, reliable image generation without the middleman.
π Sponsored by Wallrus
ComfyUI-Imagent is proudly sponsored by Wallrus. If Imagent makes your ComfyUI workflow nicer, go say hi. π
π License
MIT Β© 2026 Alexander Garzon