GPT Image Edit
Edit images with a sentence — and a mask, if you bring one
- image1
- image2
- image3
- image4
- mask
- IMAGE
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 legacydall-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.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | — | |
| image1 | IMAGE | — | |
| image2opt | IMAGE | — | |
| image3opt | IMAGE | — | |
| image4opt | IMAGE | — | |
| maskopt | MASK | — | |
| modelopt | COMBO | gpt-image-2-all | 4 options: gpt-image-2-all, gpt-image-1.5, gpt-image-1, dall-e-2 |
| nopt | INT | 11–10 | — |
| qualityopt | COMBO | auto | 4 options: auto, high, medium, low |
| sizeopt | COMBO | auto | 4 options: auto, 1024x1024, 1536x1024, 1024x1536 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |