ComfyUI Node

GPT Image Edit

Edit images with a sentence — and a mask, if you bring one

By jiaqianjing·Created 2 years ago·Updated 4 months ago· 18
GPT Image Edit
  • image1
  • image2
  • image3
  • image4
  • mask
  • IMAGE
prompt
modelgpt-image-2-all
n1
qualityauto
sizeauto

This is the instruction-editing node of the pack: give GPT Image Edit a picture, describe the change in plain words, and the model rewrites the image. No inpainting pass, no ControlNet, no local weights - the edit happens server-side on GPT's image model via the pack's 云雾 (Yunwu) relay, and you get back a normal IMAGE tensor. If you've used open-source instruction editors like Qwen-Image-Edit locally (see the KB panel), this is the closed, pay-per-use version of the same idea, with one extra card up its sleeve: an actual mask input.

How it works

The node serializes your images and POSTs them as multipart/form-data to {api_url}/v1/images/edits - the OpenAI-compatible edit endpoint - with your prompt plus quality, size, and n. Results come back base64-encoded and get converted to tensors like the generate node.

The interesting part is the mask. OpenAI's edit API doesn't take a mask as a boolean mask - it expects the areas to edit to be transparent in an RGBA PNG. So the node inverts your ComfyUI mask (white = edit region becomes alpha 0, black stays opaque), packs it into a PNG with that alpha channel, and sends it as the mask file. What that means in practice: white regions in your mask are what get changed, everything else is protected. It's a proper targeted edit - change the shirt, leave the face.

Inputs

  • prompt - required. The edit instruction, in plain language.
  • image1 - required. Your base image.
  • image2 / image3 / image4 - optional extra reference images.
  • mask - optional MASK input. White = region to edit (gets flipped to transparent before upload).
  • model - gpt-image-2-all (default), gpt-image-1.5, gpt-image-1, or the legacy dall-e-2.
  • n, quality, size - same options as the generate node.

One output: IMAGE.

Installing

ComfyUI Manager (search "ComfyUI-MidjourneyHub") or:

cd ComfyUI/custom_nodes
git clone https://github.com/jiaqianjing/ComfyUI-MidjourneyHub
# restart ComfyUI

Key goes in config.ini under [GPT_IMAGE_API] - and yes, the repo ships the author's keys in there, so swap them for your own before you run anything. Light dependencies (aiohttp, openai, nest_asyncio), no downloads to speak of.

Where people get burned

The mask direction trips people up more than anything: white edits, black protects. Invert your thinking from a typical inpainting mask and it's fine. Relay pricing groups are the other trap - same "无可用渠道" refusal if your token group has no channel for the model, fixed by moving to a pricier tier. And remember this is per-image paid generation through a Chinese-language reseller console, so it's a tool for jobs, not for free experimentation.

CategoryMidjourneyHub

Inputs (10)

NameTypeDefaultDescription
promptSTRING
image1IMAGE
image2optIMAGE
image3optIMAGE
image4optIMAGE
maskoptMASK
modeloptCOMBOgpt-image-2-all4 options: gpt-image-2-all, gpt-image-1.5, gpt-image-1, dall-e-2
noptINT11–10
qualityoptCOMBOauto4 options: auto, high, medium, low
sizeoptCOMBOauto4 options: auto, 1024x1024, 1536x1024, 1024x1536

Outputs (1)

NameTypeDescription
IMAGEIMAGE