Connecting OpenRouter to n8n: every AI model behind a single key
Published 30 July 2026 · 3 min read
Every AI provider has its own API, key, format and n8n node: OpenAI and Claude, Gemini, Mistral, Perplexity… Multiplying credentials works, but as soon as you want to compare models, fail over during an outage, or optimize costs request by request, the bookkeeping gets painful. OpenRouter answers exactly that problem: a single OpenAI-compatible API giving access to hundreds of models from every major provider behind one key. And picking the model dynamically per request is no gimmick: work by Ong et al. published in 2024 ("RouteLLM: Learning to Route LLMs with Preference Data", see on Google Scholar) shows that smart routing between a strong and a weak model cuts costs by more than half without degrading answer quality — the very principle this kind of gateway makes accessible without training anything.
Creating the credential in n8n
- Create an account at openrouter.ai, top it up with a few euros and generate a key under Keys.
- In n8n, add an OpenRouter Chat Model node (it's a sub-node: it plugs into an AI Agent, an LLM Chain, a Text Classifier…).
- Create the OpenRouter API credential with your key, then pick the model from the dropdown.
Models are named provider/model: openai/gpt-4o-mini, anthropic/claude-sonnet-4-5, google/gemini-2.5-flash, mistralai/mistral-small… Switching models = editing that string. That's the whole value of the system: your workflows become provider-independent.
Worth knowing: since OpenRouter's API is OpenAI-compatible, n8n's OpenAI nodes also work by pointing their base URL at https://openrouter.ai/api/v1 — handy for existing workflows you don't want to rewire.
Choosing a model without dogma
OpenRouter's catalog lists each model's price per million input and output tokens, its context window and its throughput. Three reflexes:
- Short, bounded tasks (classification, extraction, rewriting): a budget model is almost always enough — the practical takeaway of the FrugalGPT study by Chen, Zaharia and Zou published in 2023 ("FrugalGPT: How to Use Large Language Models While Reducing Cost and Improving Performance", see on Google Scholar), which matches a large model's performance at a fraction of the cost by cascading cheaper ones.
- Reasoning, synthesis, long-form writing: save frontier models for the steps where the difference shows, like the synthesis stage of a long-document summarization pipeline.
- Prototyping: the
:freevariants of some models let you test a workflow without burning credits — with rate limits that rule them out for production.
The openrouter/auto meta-model delegates the choice to OpenRouter, which routes the request to a suitable model: convenient to start with, but in production an explicit choice per workflow step is usually better — the tests described in our n8n evaluations guide will tell you objectively which model is enough where.
Fallback and high availability
API outages and saturation are the number-one cause of AI workflow failures in production. OpenRouter mitigates the problem at its layer: if a model's primary provider is down, the request can be served by another host of the same model. That doesn't replace a real application-level plan B: our multi-provider fallback guide still applies — the difference being that with OpenRouter, failing over means changing a model parameter rather than maintaining two credentials and two branches. Combine both levels for critical flows, with the usual retries and timeouts and an Error Workflow as the safety net.
Keeping costs under control
OpenRouter's dashboard breaks spend down by model, key and day — create one key per environment or per critical workflow and you get free cost accounting. On the n8n side, complement it with our method for tracking AI call costs per workflow, and keep the classic reflexes: deduplicate before calling, cache recurring answers, and respect rate limits to avoid bursts of 429 errors.
Credential security
An OpenRouter key gives access to your entire credit balance: treat it like any production secret. Store it exclusively in n8n's credential manager, never in a Code node or a plaintext variable, and apply the practices from our guide to securing API credentials in n8n — all the more important on a self-hosted instance shared by several users.
Verdict
OpenRouter has become the standard shortcut for multi-model n8n workflows: one credential, hundreds of models, a provider switch that amounts to editing a string. Keep direct APIs for high-volume single-model workloads and for provider-specific features (files, assistants), and OpenRouter for everything else — which, in most automation stacks, is most of it.
FAQ
Frequently asked questions
Why go through OpenRouter rather than each provider's API?
Three practical reasons: a single credential to manage in n8n instead of one per provider; the ability to switch models by editing a string rather than rewiring a node and a key; and built-in routing and fallback mechanisms when a provider is saturated. The trade-off is an extra intermediary: for heavy usage on a single model, the provider's direct API remains a sound choice.
How does OpenRouter billing work?
You top up an account with credits, then each call is metered at the per-token price of the model used, aligned with the underlying providers' rates (OpenRouter earns its margin through fees on credit purchases). The dashboard breaks down consumption by model and by key, which pairs well with per-workflow cost tracking on the n8n side.
Are OpenRouter's free models good enough for production?
No. The free variants (suffix :free) come with strict rate limits and can change without notice: perfect for prototyping a workflow, unsuitable for a production flow. For production, use the paid models, optionally with OpenRouter's price/performance routing to optimize the bill.
What happens to the data I send through OpenRouter?
OpenRouter relays your requests to the provider of the chosen model, and its privacy settings let you exclude providers that would use data for training. For genuinely sensitive data, the same reflexes apply as with any API: minimize what you send, anonymize upstream, or keep those flows on a local model.
Bundle FlowKit Complet
€269