OpenAI Image Edit
Gpt-image-2 with mask inpainting and continuity
- image
- client
- mask
- image
OpenAI Image Edit is the editing node in the ERPK/OpenAI family, and it's the most "ComfyUI-native" edit node in the pack: it takes a real IMAGE tensor (plus an optional MASK), and defaults to gpt-image-2, OpenAI's current flagship image model. GPT-Image-2's headline strengths are legible multilingual text and character continuity across edits - the same subject stays recognizable from one edit to the next, which is exactly what you want when you're iterating on a look instead of regenerating from scratch.
The mask support is what separates it from a basic web-UI edit. Wire a MASK into the mask input and only the white areas get edited - white means edit, black means keep. That makes this node genuinely useful for targeted inpainting inside a larger workflow: generate a face, mask the hair, ask for a different color, everything else stays untouched. It's the closest this pack gets to local inpainting ergonomics, minus the local sampler.
How it works
The node converts your IMAGE tensor to PNG bytes and sends it to OpenAI's edit endpoint. Two details worth knowing:
- Batched IMAGE input = multi-image reference. If you pass an IMAGE with a batch dimension > 1 (from an Image Batch / Rebatch node), all N frames go as reference images - gpt-image-2 uses them for character/scene continuity, up to 16. The mask, if provided, applies to the first.
- Masks become alpha. The mask is applied as transparency where it's white (edit area), which is how OpenAI's edit endpoint understands "change this region."
The result comes back as an IMAGE tensor, ready for your downstream chain.
The inputs that matter
- image - the input tensor. Batched = multi-reference continuity.
- prompt - the edit description. Specific beats vague, as always.
- mask - optional; white = edit, black = keep. This is the inpainting knob.
- model -
gpt-image-2(default), plus gpt-image-1.5 / 1 / 1-mini. - size - 1024-series sizes for the edit endpoint, auto-filtered by model.
- n - how many edited variants per call, 1–10.
- moderation - "auto" (default filters) or "low" (more permissive).
background (transparent requires a supporting format), quality (gpt-image-1 only), and input_fidelity (ignored by gpt-image-2, which always edits at high fidelity) are the deep-end options.
Installing it
Part of the ERPK Collection (eRepublik-Labs/comfyui-nodes-erpk). ComfyUI Manager: search erpk → ERPK Custom Nodes → restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/eRepublik-Labs/comfyui-nodes-erpk.git erpk
cd erpk
pip install -r requirements.txt
Needs openai>=2.32.0 and an OpenAI API key (Settings → ERPK → API Keys). No model downloads.
Common issues
- "Prompt cannot be empty" - same rule as every node in the pack.
- Mask edits the wrong area - check the polarity: white = edit, black = keep. If the whole image changes, the mask may be inverted or not connected.
- Transparent background came out solid -
background: transparentneeds an output format that supports alpha; on formats that don't, transparency is dropped. - Cost per edit - gpt-image-2 is billed per edit.
n> 1 multiplies it. Use the seed andn=1while iterating.
Inputs (12)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Input image(s) to edit. A single image is the default. If you pass a batched IMAGE (e.g. from an Image Batch / Rebatch node), all N images are sent as reference images — gpt-image-2 uses this for character/scene continuity (up to 16 images). Mask (if provided) applies to the first. | |
| prompt | STRING | Description of how to modify the image | |
| seed | INT | -1-1–2147483647 | Seed for reproducible outputs (best-effort). Randomizes by default. |
| clientopt | OPENAI_API_CLIENT | OpenAI API client from OpenAI API Config node | |
| maskopt | MASK | Optional mask indicating areas to edit (white = edit, black = keep) | |
| modelopt | COMBO | gpt-image-2 | Image editing model. gpt-image-2 is the latest flagship (multilingual text, character continuity across edits). gpt-image-1.5 / gpt-image-1 / gpt-image-1-mini remain available. |
| sizeopt | COMBO | 1024x1024 | Output image size. Options auto-filter based on the selected model. Edit endpoint supports the 1024-series sizes (and auto) across all GPT Image models. |
| qualityopt | COMBO | auto | Image quality (gpt-image-1 only) |
| moderationopt | COMBO | auto | Content moderation level. 'auto' uses OpenAI's default safety filters; 'low' relaxes them for permissive content. |
| nopt | INT | 11–10 | Number of edited image variants to return per call (OpenAI supports 1-10 for all GPT Image models). |
| backgroundopt | COMBO | auto | Background type for the edited output (GPT Image models only). 'transparent' requires an output format that supports transparency. |
| input_fidelityopt | COMBO | auto | Fidelity to the original input image(s). 'high' preserves details more aggressively; 'low' gives the model more creative freedom. Ignored by gpt-image-2 (always processes at high fidelity). |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |