JAS OpenAI Image Edit [set OPENAI_API_KEY]
GPT Image edits with real masks, no Comfy account in the way
- image
- mask
- images
OpenAI's image models are closed, which means if you want GPT Image to edit one of your renders, you're calling an API - and the official ComfyUI route wants an account login and prepaid credits. This node skips the account and the meter. Give it an image, a prompt, and an OPENAI_API_KEY, and it sends the edit straight to OpenAI's images API and hands you back an IMAGE tensor. One key, no Comfy login, no credits balance to babysit.
The genuinely useful bit: it's the one node in the pack that takes an optional mask. Wire a MASK tensor in and it uploads it with the request, so you get actual regional editing - change the foreground, leave the background alone - instead of begging the model to infer what you meant.
How it works
The node converts your image tensor to a PNG (and, if you gave it one, the mask too), builds a multipart/form-data request, and POSTs it to OpenAI's images endpoint. The quality, background, size, and n fields go straight into the request body; a nonzero seed is sent as a user: seed:N string, which is workflow-compatibility sugar more than true reproducibility - the README says plainly that OpenAI generation isn't guaranteed deterministic. The response decodes into a tensor and drops back into the graph.
The inputs that matter
- image - your input, from a Load Image.
- mask (optional) - here's the gotcha: the README and the code agree that mask requires exactly one input image. Feed it a batch and the node refuses. One image in, mask in, edit in.
- prompt - the edit instruction, multiline.
- model -
gpt-image-1,gpt-image-1.5, orgpt-image-2(default). The older two only accept square-ish sizes up to 1536×1536, so if you pick them, expect the size list to shrink.
Then the fiddly trio: quality (low/medium/high), background (auto/opaque/transparent - and note transparent is hard-blocked for gpt-image-2 to match the API constraint; pick gpt-image-1.5 if you need alpha), and size (auto plus presets plus Custom). Custom size opens up custom_width/custom_height, which are only honored by gpt-image-2: multiples of 16, 1024–3840 each, aspect ratio no wider than 3:1, and total pixels between ~0.6M and ~8.3M. It'll tell you if you break the rules.
n (1–8) controls how many variants per call. Output is a single images tensor, wired to Save Image or into an upscaler.
Installing it
This is one of six nodes in the comfyui_jas_nodes pack. Manager: search "comfyui_jas_nodes". Or:
cd ComfyUI/custom_nodes
git clone https://github.com/reducm/comfyui_jas_nodes
cd comfyui_jas_nodes
python -m pip install -r requirements.txt # just `requests`, the only dependency
Set the key in the shell that launches ComfyUI, then restart:
export OPENAI_API_KEY="sk-..."
No models, no VRAM, no downloads.
Common issues
The classic failure mode is the key not being in ComfyUI's environment - you'll get OPENAI_API_KEY is not set immediately. Set it where ComfyUI starts, not in some other terminal, and fully restart. If the mask doesn't seem to do anything, you almost certainly fed it more than one image; the node throws a specific error for that. And remember the cost and privacy reality: every edit ships your image and prompt to OpenAI's servers, and OpenAI's content filter applies at the source - the node can't route around a refusal. For precision edits with real masking, though, this is the node to reach for.
Inputs (12)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| prompt | STRING | — | |
| base_url | STRING | https://api.openai.com/v1 | — |
| model | COMBO | gpt-image-2 | 3 options: gpt-image-1, gpt-image-1.5, gpt-image-2 |
| quality | COMBO | low | 3 options: low, medium, high |
| background | COMBO | auto | 3 options: auto, opaque, transparent |
| size | COMBO | auto | 10 options: auto, 1024x1024, 1024x1536, 1536x1024, 2048x2048, 2048x1152, +4 |
| custom_width | INT | 10241024–3840 | — |
| custom_height | INT | 10241024–3840 | — |
| n | INT | 11–8 | — |
| seed | INT | 00–2147483647 | — |
| maskopt | MASK | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | — |