OpenRouter Generate Image
Image Generation via OpenRouter
- image
- image1
- image2
- image3
- image4
- history
- image
- images
- num_images
- text
- history
OpenRouter's whole pitch is one API key, many models - you don't maintain separate accounts with every provider, you just call openrouter.ai with a model slug. YogurtOpenRouterGenerateImage is that pitch wired into your graph: pick a model by name, generate an image, and get back a proper IMAGE tensor.
Day-one inputs:
api_key- your OpenRouter key (or fall back toapi_key.json/OPENROUTER_API_KEY).model_name- defaults togoogle/gemini-2.5-flash-image-preview.promptandsystem_prompt- what to draw and how to frame it.temperature,top_p,max_tokens- sampling dials (max_tokens defaults to 8192).providerandprovider_list- infrastructure preference.provideris a single choice likeazure;provider_listtakes comma-separated providers (openai,azure,together) and wins when set.seed,aspect_ratio,image_size- the last defaults to "1k" and is gemini-only for now.retry_count,timeout,proxy_url- resilience.
Optional: image + image1–image4 for edits, history, extra for raw JSON, and return_text - a BOOLEAN that controls whether the response is image+text or image only. Outputs: image, images, num_images, text, history.
Why route through OpenRouter?
Convenience is the honest answer: one key, one billing account, and the ability to swap image models by changing a string instead of reconfiguring a client. If you're already paying for OpenRouter for text, the image node is the same bill. The provider_list/provider controls are the real differentiator - when a model is down at one provider, you can pin the fallback without leaving the node.
That said, the defaults tell you a lot: gemini-2.5-flash-image-preview as the image default and claude-3.5-sonnet for the text twin. OpenRouter is best understood as a router - you get the models OpenRouter has contracts with, not every model ever. If your heart is set on a specific provider's API, the pack's dedicated nodes (YogurtOpenAIGenerateImage, YogurtQwenGenerateImage) are there instead.
Install and keys
Ships in ComfyUI-YogurtNodes. ComfyUI Manager → search ComfyUI-YogurtNodes → install, or:
cd ComfyUI/custom_nodes
git clone https://github.com/yogurt7771/ComfyUI-YogurtNodes.git
cd ComfyUI-YogurtNodes
pip install -r requirements.txt
Restart ComfyUI; it's under "Yogurt Nodes/LLM". Requires the openai Python package (OpenRouter speaks the OpenAI wire protocol) and an OpenRouter key from openrouter.ai/keys.
Gotchas: not every model slug OpenRouter offers is image-capable - the node expects a model that returns images, and you'll get an error or empty output if you point it at a text-only model. And image_size being "gemini only for now" means it's silently ignored by models that don't support it. When in doubt, stick with the default model and read the model's page on OpenRouter before you swap.
Inputs (31)
| Name | Type | Default | Description |
|---|---|---|---|
| api_key | STRING | API key for accessing OpenRouter API | |
| model_name | STRING | openai/gpt-image-2 | OpenRouter model name for image generation |
| system_prompt | STRING | System-level prompt that affects the overall image generation style | |
| prompt | STRING | Main prompt content for image generation | |
| temperature | FLOAT | 1.000–2 | Sampling temperature, higher values produce more random outputs |
| top_p | FLOAT | 0.000–1 | Sampling probability threshold, controls output diversity |
| max_tokens | INT | 81920–32768 | Maximum number of tokens in the generated text |
| retry_count | INT | 1 | Number of retries when request fails |
| provider | COMBO | auto | Infrastructure provider preference |
| provider_list | STRING | Provider list (comma separated, e.g: 'openai,azure,together'), empty means use provider | |
| chat_template | STRING | <-system-> {{system_instruction}} <-/system-> <-user-> {{prompt}} <-/user-> | Content template for the image generation prompt |
| proxy_url | STRING | 代理URL,格式: protocol://user:pass@addr:port,支持http,https,socks5,socks5h | |
| seed | INT | -1-1–2147483647 | Random seed for generation (-1 for random) |
| aspect_ratio | COMBO | auto | Aspect ratio for generated images |
| timeout | INT | 00–2147483647 | Timeout for the request in seconds, 0 means no timeout |
| image_size | COMBO | auto | Normalized image size tier (model dependent) |
| imageopt | IMAGE | — | |
| image1opt | IMAGE | — | |
| image2opt | IMAGE | — | |
| image3opt | IMAGE | — | |
| image4opt | IMAGE | — | |
| historyopt | HISTORY | — | |
| extraopt | STRING | {} | Extra parameters for the request, in JSON format |
| return_textopt | BOOLEAN | true | Whether to request/return text output (controls modalities: image+text vs image only) |
| sizeopt | STRING | auto | Exact Images API size, such as 2048x2048; overrides image_size |
| qualityopt | COMBO | auto | Image rendering quality (model dependent) |
| backgroundopt | COMBO | auto | Image background mode (model/provider dependent) |
| output_formatopt | COMBO | auto | Generated image format (model/provider dependent) |
| output_compressionopt | INT | -1-1–100 | JPEG/WebP compression from 0 to 100; -1 uses the provider default |
| nopt | INT | 11–10 | Number of images requested from the Images API |
| moderationopt | COMBO | auto | OpenAI image moderation level |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| images | IMAGE | — |
| num_images | INT | — |
| text | STRING | — |
| history | HISTORY | — |