Nodes/ComfyUI-YogurtNodes/OpenRouter Generate Text
ComfyUI Node

OpenRouter Generate Text

Text Generation via OpenRouter

By yogurt7771·Created 2 years ago·Updated 4 days ago· 1
OpenRouter Generate Text
  • history
  • text
  • history
  • payload
api_key
model_nameanthropic/claude-3.5-sonnet
infrastructure_providerauto
system_prompt
prompt
temperature1.00
top_p0.00
max_tokens8192
retry_count1
chat_template<-system-> {{system_instruction}} <-/system-> <-user-> {{prompt}} <-/user->
provider_list
proxy_url
seed-1
timeout0
extra{}

Every serious LLM workflow eventually runs into the same question: which model am I actually paying for, and is it the right one for this job? YogurtOpenRouterGenerateText is the node that answers "any of them" - it calls OpenRouter's text API, so the model is just a slug you type, and swapping from Claude to GPT to some obscure open-weights runner is a one-string edit.

The controls, in the order you'll set them:

  • api_key - OpenRouter key, or blank to fall back to api_key.json / OPENROUTER_API_KEY.
  • model_name - defaults to anthropic/claude-3.5-sonnet, but any OpenRouter text model slug works.
  • system_prompt and prompt - the usual framing + user message, both multiline.
  • temperature, top_p, max_tokens (default 8192) - sampling dials.
  • infrastructure_provider - "auto" or a specific one (azure, aws, ...).
  • provider_list - comma-separated providers, e.g. openai,azure,together; empty means use infrastructure_provider.
  • seed, retry_count, timeout, proxy_url - determinism and resilience.
  • chat_template - the <-system->/<-user-> template, restructurable.

Optional: history for multi-turn and extra for raw JSON body additions. Outputs: text, history, payload.

How to think about it

The payload output is worth calling out - it's the raw response object, which means you can dig out metadata (token usage, model actually served, finish reason) that the plain text output hides. For a workflow that needs to log costs or verify which model answered, that's gold.

The model-swapping story is the real pitch. A/B testing two models on the same prompt is changing a string and re-running. When OpenRouter's routing picks a fallback provider, you barely notice. The flip side of that flexibility: the routed model may not be the one you typed - OpenRouter can substitute within its rules - and payload is how you confirm what actually ran.

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, find it under "Yogurt Nodes/LLM". Needs the openai package and an OpenRouter key.

Two practical notes. First, the default claude-3.5-sonnet is an older, cheaper model - fine for plumbing, but check OpenRouter's current catalog for what's best today. Second, max_tokens at 8192 is generous; if you're building a loop that calls this node per image, per-item cost adds up fast. Keep the ceiling tight and you'll thank yourself later.

CategoryYogurtNodes/LLM

Inputs (16)

NameTypeDefaultDescription
api_keySTRINGAPI key for accessing OpenRouter API
model_nameSTRINGanthropic/claude-3.5-sonnetOpenRouter model name
infrastructure_providerCOMBOautoInfrastructure provider (auto, azure, aws, etc.) - Optional
system_promptSTRINGSystem-level prompt that affects the overall conversation style
promptSTRINGMain prompt content input by the user
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_countINT11–10Number of retries when request fails
chat_templateSTRING<-system-> {{system_instruction}} <-/system-> <-user-> {{prompt}} <-/user->Content template for the generated text
provider_listSTRINGProvider list (comma separated, e.g: 'openai,azure,together'), empty means use infrastructure_provider
proxy_urlSTRING代理URL,格式: protocol://user:pass@addr:port,支持http,https,socks5,socks5h
seedINT-1-1–2147483647Random seed for generation (-1 for random)
timeoutINT00–2147483647Timeout for the request in seconds, 0 means no timeout
historyoptHISTORY
extraoptSTRING{}Extra parameters for the request, in JSON format

Outputs (3)

NameTypeDescription
textSTRING
historyHISTORY
payload*