OpenAI GPT Image Edit
OpenAI GPT Image Edit — the mask-capable editor this pack exists to feed
- image_1
- image_2
- image_3
- image_4
- image_5
- image_6
- mask_image
- images
- info
GPT Image is the editor in this pack that actually accepts a mask - which makes it the natural partner for the mask-based local edit path, the one that keeps every pixel outside your region bit-identical. This node is the FAL relay for it: it wraps OpenAI's GPT Image 2 through FAL's relay (openai/gpt-image-2/edit), which matters more than it sounds, because it means you authenticate with a FAL key, not an OpenAI one.
The key story, since it confuses everyone
Despite the input named openai_api_key, this node never calls OpenAI directly. Every request goes to FAL, and FAL authenticates to OpenAI on the backend with its own credentials. Your FAL key is what authenticates the call - wire it into api_key (or FAL_KEY env var) and leave openai_api_key blank. In the current version, blank is fine and the node proceeds using FAL auth alone.
If you ever see RuntimeError: Missing OpenAI API key, the README has the full archaeology: older versions of the pack only checked that the field was non-empty, so people "fixed" it by pasting their FAL key into openai_api_key as well - a workaround that no longer needs to exist. The modern fix is just: update the pack and leave it blank.
The inputs that matter
Required: prompt (default: "Retouch only the masked region. Preserve the rest of the image."), image_1, and the key inputs. Then:
mask_image- the mask, uploaded asmask_image_url. It must be the exact same pixel size asimage_1. In the pack's flow that's automatic: wireSmart Mask Crop -> cropped_mask_imagehere, not the original Florence mask.size_mode-preset(withimage_size, simplest:autoworks like magic for inpainting),aspect_ratio(+aspect_ratio/resolution),custom(explicitwidth/height, multiples of 16), orauto_from_region. For a stable automatic flow, connectSmart Mask Crop -> infointoregion_infoand setauto_from_region- GPT then requests the same edit size the stitch expects, so nothing resamples.quality(low/medium/high) andnum_images(1–4) - your cost/quality tradeoff.image_2...image_6- optional references sent alongsideimage_1.
Outputs: images (into Smart Mask Stitch), and info.
Where it sits
Florence-2 or SAM selector -> mask -> Smart Mask Crop
-> cropped_image -> image_1
-> cropped_mask_image -> mask_image
-> info -> region_info (size_mode = auto_from_region)
-> result -> Smart Mask Stitch
Prompt the masked edit conservatively: name only the object, and explicitly preserve everything outside the mask. "Recompose the portrait" belongs in a full-frame pass, not a local masked edit - the editor will happily comply on the crop, and then the stitch pastes an island of chaos back.
Install
Search comfyui-inpaint-cropstitch-nb2 in ComfyUI Manager, or:
cd ComfyUI/custom_nodes
git clone https://github.com/amortegui84/comfyui-inpaint-cropstitch-nb2
Restart. FAL-backed, so FAL_KEY (or the node's api_key) is required; a 401 on first run means the key isn't reaching the process - set it before launch and fully restart ComfyUI.
Inputs (23)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | Retouch only the masked region. Preserve the rest of the image. | — |
| image_1 | IMAGE | — | |
| api_key | STRING | — | |
| api_key_env_var | STRING | FAL_KEY | — |
| openai_api_key | STRING | — | |
| openai_api_key_env_var | STRING | OPENAI_API_KEY | — |
| image_2opt | IMAGE | — | |
| image_3opt | IMAGE | — | |
| image_4opt | IMAGE | — | |
| image_5opt | IMAGE | — | |
| image_6opt | IMAGE | — | |
| mask_imageopt | IMAGE | — | |
| region_infoopt | STRING | — | |
| size_modeopt | COMBO | preset | 4 options: preset, aspect_ratio, custom, auto_from_region |
| image_sizeopt | COMBO | auto | 7 options: auto, square_hd, square, portrait_4_3, portrait_16_9, landscape_4_3, +1 |
| aspect_ratioopt | COMBO | 16:9 | 9 options: 1:1, 16:9, 9:16, 4:5, 5:4, 3:2, +3 |
| resolutionopt | COMBO | 1K | 3 options: 1K, 2K, 4K |
| widthopt | INT | 192016–4096 | — |
| heightopt | INT | 108016–4096 | — |
| qualityopt | COMBO | high | 3 options: low, medium, high |
| num_imagesopt | INT | 11–4 | — |
| output_formatopt | COMBO | png | 3 options: png, webp, jpeg |
| sync_modeopt | BOOLEAN | false | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | — |
| info | STRING | — |