JAS OpenRouter Image Edit [set OPENROUTER_API_KEY]
Edit with OpenAI or Gemini through OpenRouter
- image
- images
OpenRouter's pitch is one API key for a whole shelf of models, and this node takes it literally: a single dropdown swaps between openai/gpt-5.4-image-2 and google/gemini-3.1-flash-image-preview, both image edit calls billed through your one OPENROUTER_API_KEY. No per-provider keys, no separate OpenAI and Google accounts, no Comfy account and no Comfy credits. If you already live in the OpenRouter ecosystem, this is the edit node that matches your billing setup.
The tradeoff for that convenience is that you're routing through OpenRouter's chat-completions-style API rather than the providers' native image endpoints, and the node is honest about the limits. It asks the upstream API for what it wants; the upstream model decides what it honors.
How it works
The node takes your image tensor, base64-encodes it as a data URL, and sends it as a content part in a chat request to openrouter.ai/api/v1/chat/completions with modalities: ["text", "image"]. Your system_prompt becomes a system message. The image-config params (aspect_ratio, quality) ride along in image_config, and a nonzero seed goes in the payload. The response's image is decoded back to a tensor.
The interesting behavior is preserve_source_size (default on) and the aspect_ratio = "source" option. With source selected, the node derives the aspect ratio from your input image and also sends its exact WIDTHxHEIGHT as image_config.size - then crossing its fingers. The README spells out the catch: that's a request to the upstream API, and the final returned size still depends on what the selected model and provider actually honor.
The inputs that matter
- image - the input, from Load Image. No mask support here; edits are prompt-driven.
- model - the dropdown that decides whether you're talking to OpenAI or Google.
- prompt - the edit instruction.
- aspect_ratio -
source(derive from the image) or the standard ratios from 1:1 to 21:9. - quality - low/medium/high, default medium.
Plus seed, system_prompt, and base_url (defaults to OpenRouter; you could point this at another OpenAI-compatible aggregator). Output is a single images tensor for Save Image or downstream work.
Installing it
One of six nodes in the comfyui_jas_nodes pack. ComfyUI Manager: search "comfyui_jas_nodes". By hand:
cd ComfyUI/custom_nodes
git clone https://github.com/reducm/comfyui_jas_nodes
cd comfyui_jas_nodes
python -m pip install -r requirements.txt # only `requests`
Set the key and restart ComfyUI:
export OPENROUTER_API_KEY="your-key"
Common issues
The README's debugging notes are your troubleshooting cheat sheet here. If OpenRouter returns text instead of an image, that usually means the model refused the request or answered in text only - the node surfaces it as-is rather than pretending. If you picked source and the output size looks wrong, remember the caveat: the node sent your source dimensions, but the upstream model decides. And if preserve_source_size errors out, you've hit the one case that can't work - it needs an input image, and text-to-image can't provide one. Your image and prompt go to OpenRouter and then to the provider, subject to whatever filters sit at the source. For "one key, both families" convenience it's hard to beat; just don't expect surgical, mask-based region edits, because there's no mask input on this one.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| prompt | STRING | — | |
| base_url | STRING | https://openrouter.ai/api/v1/chat/completions | — |
| model | COMBO | openai/gpt-5.4-image-2 | 2 options: openai/gpt-5.4-image-2, google/gemini-3.1-flash-image-preview |
| aspect_ratio | COMBO | 1:1 | 11 options: source, 1:1, 2:3, 3:2, 3:4, 4:3, +5 |
| quality | COMBO | medium | 3 options: low, medium, high |
| preserve_source_size | BOOLEAN | true | — |
| seed | INT | 00–2147483647 | — |
| system_prompt | STRING | Edit the input image according to the user's request while preserving key subject identity where appropriate. | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | — |