Nodes/ERPK Collection/OpenAI Image Edit
ComfyUI Node

OpenAI Image Edit

Gpt-image-2 with mask inpainting and continuity

By eRepublik-Labs·Created 11 months ago·Updated 21 days ago· 1
OpenAI Image Edit
  • image
  • client
  • mask
  • image
prompt
seed-1
modelgpt-image-2
size1024x1024
qualityauto
moderationauto
n1
backgroundauto
input_fidelityauto

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 erpkERPK 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: transparent needs 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 and n=1 while iterating.
CategoryERPK/OpenAI

Inputs (12)

NameTypeDefaultDescription
imageIMAGEInput 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.
promptSTRINGDescription of how to modify the image
seedINT-1-1–2147483647Seed for reproducible outputs (best-effort). Randomizes by default.
clientoptOPENAI_API_CLIENTOpenAI API client from OpenAI API Config node
maskoptMASKOptional mask indicating areas to edit (white = edit, black = keep)
modeloptCOMBOgpt-image-2Image 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.
sizeoptCOMBO1024x1024Output image size. Options auto-filter based on the selected model. Edit endpoint supports the 1024-series sizes (and auto) across all GPT Image models.
qualityoptCOMBOautoImage quality (gpt-image-1 only)
moderationoptCOMBOautoContent moderation level. 'auto' uses OpenAI's default safety filters; 'low' relaxes them for permissive content.
noptINT11–10Number of edited image variants to return per call (OpenAI supports 1-10 for all GPT Image models).
backgroundoptCOMBOautoBackground type for the edited output (GPT Image models only). 'transparent' requires an output format that supports transparency.
input_fidelityoptCOMBOautoFidelity 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)

NameTypeDescription
imageIMAGE