Nodes/ComfyUI-YogurtNodes/OpenRouter Generate Image
ComfyUI Node

OpenRouter Generate Image

Image Generation via OpenRouter

By yogurt7771·Created 2 years ago·Updated 9 days ago· 1
OpenRouter Generate Image
  • image
  • image1
  • image2
  • image3
  • image4
  • history
  • image
  • images
  • num_images
  • text
  • history
api_key
model_nameopenai/gpt-image-2
system_prompt
prompt
temperature1.00
top_p0.00
max_tokens8192
retry_count1
providerauto
provider_list
chat_template<-system-> {{system_instruction}} <-/system-> <-user-> {{prompt}} <-/user->
proxy_url
seed-1
aspect_ratioauto
timeout0
image_sizeauto
extra{}
return_texttrue
sizeauto
qualityauto
backgroundauto
output_formatauto
output_compression-1
n1
moderationauto

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 to api_key.json / OPENROUTER_API_KEY).
  • model_name - defaults to google/gemini-2.5-flash-image-preview.
  • prompt and system_prompt - what to draw and how to frame it.
  • temperature, top_p, max_tokens - sampling dials (max_tokens defaults to 8192).
  • provider and provider_list - infrastructure preference. provider is a single choice like azure; provider_list takes 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 + image1image4 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.

CategoryYogurtNodes/LLM

Inputs (31)

NameTypeDefaultDescription
api_keySTRINGAPI key for accessing OpenRouter API
model_nameSTRINGopenai/gpt-image-2OpenRouter model name for image generation
system_promptSTRINGSystem-level prompt that affects the overall image generation style
promptSTRINGMain prompt content for image generation
temperatureFLOAT1.000–2Sampling temperature, higher values produce more random outputs
top_pFLOAT0.000–1Sampling probability threshold, controls output diversity
max_tokensINT81920–32768Maximum number of tokens in the generated text
retry_countINT1Number of retries when request fails
providerCOMBOautoInfrastructure provider preference
provider_listSTRINGProvider list (comma separated, e.g: 'openai,azure,together'), empty means use provider
chat_templateSTRING<-system-> {{system_instruction}} <-/system-> <-user-> {{prompt}} <-/user->Content template for the image generation prompt
proxy_urlSTRING代理URL,格式: protocol://user:pass@addr:port,支持http,https,socks5,socks5h
seedINT-1-1–2147483647Random seed for generation (-1 for random)
aspect_ratioCOMBOautoAspect ratio for generated images
timeoutINT00–2147483647Timeout for the request in seconds, 0 means no timeout
image_sizeCOMBOautoNormalized image size tier (model dependent)
imageoptIMAGE
image1optIMAGE
image2optIMAGE
image3optIMAGE
image4optIMAGE
historyoptHISTORY
extraoptSTRING{}Extra parameters for the request, in JSON format
return_textoptBOOLEANtrueWhether to request/return text output (controls modalities: image+text vs image only)
sizeoptSTRINGautoExact Images API size, such as 2048x2048; overrides image_size
qualityoptCOMBOautoImage rendering quality (model dependent)
backgroundoptCOMBOautoImage background mode (model/provider dependent)
output_formatoptCOMBOautoGenerated image format (model/provider dependent)
output_compressionoptINT-1-1–100JPEG/WebP compression from 0 to 100; -1 uses the provider default
noptINT11–10Number of images requested from the Images API
moderationoptCOMBOautoOpenAI image moderation level

Outputs (5)

NameTypeDescription
imageIMAGE
imagesIMAGE
num_imagesINT
textSTRING
historyHISTORY