OpenRouter Generate Text
Text Generation via OpenRouter
- history
- text
- history
- payload
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 toapi_key.json/OPENROUTER_API_KEY.model_name- defaults toanthropic/claude-3.5-sonnet, but any OpenRouter text model slug works.system_promptandprompt- 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 useinfrastructure_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.
Inputs (16)
| Name | Type | Default | Description |
|---|---|---|---|
| api_key | STRING | API key for accessing OpenRouter API | |
| model_name | STRING | anthropic/claude-3.5-sonnet | OpenRouter model name |
| infrastructure_provider | COMBO | auto | Infrastructure provider (auto, azure, aws, etc.) - Optional |
| system_prompt | STRING | System-level prompt that affects the overall conversation style | |
| prompt | STRING | Main prompt content input by the user | |
| 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 | 11–10 | Number of retries when request fails |
| chat_template | STRING | <-system-> {{system_instruction}} <-/system-> <-user-> {{prompt}} <-/user-> | Content template for the generated text |
| provider_list | STRING | Provider list (comma separated, e.g: 'openai,azure,together'), empty means use infrastructure_provider | |
| 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) |
| timeout | INT | 00–2147483647 | Timeout for the request in seconds, 0 means no timeout |
| historyopt | HISTORY | — | |
| extraopt | STRING | {} | Extra parameters for the request, in JSON format |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |
| history | HISTORY | — |
| payload | * | — |