Nodes/ComfyUI-OllamaPromptsGeneratorTlant/OpenRouter API (Tlant V1)
ComfyUI Node

OpenRouter API (Tlant V1)

Every LLM Under One Node — With a Cache That Doesn't Waste Your Credits

By Tlant·Created 2 years ago·Updated 5 months ago· 2
OpenRouter API (Tlant V1)
  • images
  • response_text
  • reasoning_content
model_namexiaomi/mimo-v2-flash
base_urlhttps://openrouter.ai/api/v1/chat/completions
api_key
system_promptYou are a helpful assistant.
user_prompt
temperature0.70
max_tokens2048
seed0
remove_think_tagsfalse
proxy_url
top_p1.00
timeout300
image_detailauto
user_prompt_input
system_prompt_input

OpenRouter is the "one key for a hundred models" service - Google, Anthropic, DeepSeek, xAI, all behind a single API key and a single endpoint. This node puts that inside your graph: pick a model, type a prompt, and the response lands as a string you can feed straight into your text encoder. It's also the most polished node in the Tlant pack, and the caching behavior is the reason why.

How it works

The headline feature is the cache. ComfyUI re-executes a node when IS_CHANGED says its inputs changed, and this node hashes every input - including the image tensor, which it fingerprints by shape plus sum. Same inputs, same seed, same output: the API call is skipped entirely and you get the cached result. Bump the seed and it makes a fresh call. For prompt-rewriting workflows where you iterate on one variable, that means you only pay for calls you actually change - a real credit-saver with paid models.

The request itself is a standard chat-completions call: system prompt, user prompt, temperature, top_p, max_tokens, optional images. For vision models, images are encoded to base64 PNGs and sent as data: URLs with an image_detail level (auto/low/high). It sets the OpenRouter-required attribution headers (HTTP-Referer pointing at ComfyUI, X-Title naming the pack), prints token usage to the console, and - the genuinely thoughtful part - parses out reasoning_content separately from the final answer.

Inputs that matter

  • model_name (default xiaomi/mimo-v2-flash) - OpenRouter's vendor/model identifier, e.g. google/gemini-2.5-pro-preview.
  • api_key - your sk-or-v1-... key. No key, no calls.
  • system_prompt / user_prompt - the conversation. Both have optional _input variants that get appended when wired, so you can drive them from other nodes.
  • seed - change to force a fresh call, keep fixed to hit the cache.
  • remove_think_tags - strips <think>...</think> blocks from the answer.
  • proxy_url - for setups where OpenRouter needs a proxy (e.g. socks5://127.0.0.1:1080).
  • images - optional IMAGE input for vision models; supports batches.

Outputs: response_text (the answer) and reasoning_content (a reasoning model's chain-of-thought, when the provider returns one - the node also pulls it out of <think> tags in the text if the field is missing).

Install

Same pack as the other fifteen:

cd ComfyUI/custom_nodes
git clone https://github.com/Tlant/ComfyUI-OllamaPromptsGeneratorTlant

restart, then grab a key at openrouter.ai and paste it in. Dependencies are just requests/aiohttp.

Where people get burned

  • Empty prompts return empty. With no user_prompt and no images, the node bails early with ("", "") - silent, but it's telling you it has nothing to send.
  • The cache can mask changes. Because the hash is over raw inputs, changing an upstream node that computes a prompt only matters if the resulting string actually changes. If you're tweaking a LoRA and expecting a new call, the string hasn't changed - that's by design, and it's also the cache working exactly as documented.
  • Timeout is real. Default 300 seconds, and a slow reasoning model on a big vision request can get close. Errors come back as response_text, not as a crash.
  • Reasoning content can be long. Wire reasoning_content through ReasoningLLMOutputCleaner before it goes anywhere near a prompt widget, or you'll be encoding chain-of-thought.

It's the one node in this pack that competes with the dedicated LLM API packs, and the caching alone makes it worth having.

CategoryTlant/API

Inputs (16)

NameTypeDefaultDescription
model_nameSTRINGxiaomi/mimo-v2-flashOpenRouter model identifier, e.g. google/gemini-2.5-pro-preview
base_urlSTRINGhttps://openrouter.ai/api/v1/chat/completionsAPI endpoint URL
api_keySTRINGOpenRouter API key (sk-or-v1-...)
system_promptSTRINGYou are a helpful assistant.System prompt to set model behavior
user_promptSTRINGUser prompt / instruction
temperatureFLOAT0.700–2Controls randomness. Lower = more deterministic
max_tokensINT20481–128000Maximum number of tokens in the response
seedINT00–18446744073709550000Change seed to force re-execution; keep fixed to use cache
remove_think_tagsBOOLEANfalseRemove <think>...</think> blocks from output
proxy_urlSTRINGOptional proxy. e.g. http://127.0.0.1:1080 or socks5://127.0.0.1:1080
top_pFLOAT1.000–1Nucleus sampling threshold
timeoutINT30010–1200Request timeout in seconds
image_detailCOMBOautoImage detail level for vision models
imagesoptIMAGEOptional image input for vision models. Supports batch.
user_prompt_inputoptSTRINGExternal user prompt input, will be appended to user_prompt
system_prompt_inputoptSTRINGExternal system prompt input, will be appended to system_prompt

Outputs (2)

NameTypeDescription
response_textSTRINGThe model's text response
reasoning_contentSTRINGReasoning content returned by reasoning models (if available)