ComfyUI Node

Dalle Image Edit

Inpainting by API — but the mask is pickier than you think

By cleanlii·Created about a year ago·Updated about a year ago· 1
Dalle Image Edit
  • image
  • mask
  • IMAGE
prompt
size
n1

Inpainting by API - but the mask is pickier than you think

Dalle Image Edit does what local inpainting does, minus the local part: feed it an image, a mask, and a prompt, and OpenAI regenerates just the region you flagged. If the generation node in this pack is "cloud text-to-image," this is "cloud inpainting" - same tradeoffs, plus one gotcha that catches everyone.

Why you'd reach for it

You already have local inpainting in ComfyUI, so the reasons mirror the sibling nodes: no VRAM, no model swap, and a "keep everything, but change the mug to a cat" instruction that actually lands. Where people get burned is the mask, which is the entire game - and it's not the mask you're used to.

How it works (and the catch)

The node takes the first frame of the image and mask inputs, converts both to RGBA, resizes the mask to match the image, then both to your chosen size, saves them to /tmp, and calls OpenAI's images.edit. Here's the thing the README never tells you: the code doesn't pass a model, so it rides the SDK default - which is dall-e-2 for the edit endpoint. That single fact explains every constraint below.

The mask's alpha channel is the edit region. DALL·E 2-style editing works by transparency: fully transparent areas of the mask PNG say "change this," opaque areas say "leave it alone." So the mask input isn't a ComfyUI Mask - it's an IMAGE, and a black-and-white mask pushed through MaskToImage has no alpha to speak of. In practice, feed it an RGBA image: a LoadImage whose transparent area is the edit zone.

The inputs

  • image - what to edit.
  • mask - an IMAGE whose transparent areas mark the edit zone.
  • prompt - what to do to those zones.
  • size - the same three options as the generation node, but only 1024x1024 actually works. The edit endpoint accepts square sizes only; pick portrait or landscape and the API rejects the call.
  • n - 1 to 4. Unlike generation, this one can genuinely return multiple edits (the API allows up to 10). It just multiplies the bill.

The output is IMAGE, ready for your normal saving or upscaling nodes.

Installing & shared gotchas

Same pack, same install as the sibling nodes: Manager search "DalleImageNodes" or

cd ComfyUI/custom_nodes
git clone https://github.com/cleanlii/comfyui-dalle-integration

then python -m pip install openai and a real key in config.json (the pack auto-creates it with a placeholder sk-####... that you must replace). Beyond the mask and size rules:

  • Only the first frame is used - the code reads image[0] and mask[0]. Batch inputs get silently truncated.
  • Hardcoded /tmp paths - fine on Linux and macOS; on Windows make sure a \tmp directory exists or the node fails before it ever reaches the API.
  • 401s mean the placeholder key; mask errors mean the mask has no transparency for the API to read.

Keep the prompt focused on what you want changed, not the whole scene. The API only touches the transparent regions, so describing everything just invites it to wander.

CategoryOpenAI/Dalle

Inputs (5)

NameTypeDefaultDescription
imageIMAGE
maskIMAGE
promptSTRING
sizeCOMBO3 options: 1024x1024, 1024x1792, 1792x1024
nINT11–4

Outputs (1)

NameTypeDescription
IMAGEIMAGE