What is OpenRouter?
A unified gateway exposing hundreds of models from many providers behind one OpenAI-compatible endpoint.
Tema 05 · 6 modules
One API to reach hundreds of LLM models from many providers. What OpenRouter is, how to integrate it, routing and fallbacks, costs and going to production.
OpenRouter · Fonaments
One integration that reaches hundreds of models.
A unified gateway exposing hundreds of models from many providers behind one OpenAI-compatible endpoint.
OpenRouter · Fonaments
Why wiring up each provider on its own gets expensive.
Without a router you juggle N SDKs, N keys, N bills and N limits. A router collapses it all into one integration.
OpenRouter · Fonaments
The trade-off between flexibility and direct control.
The router gives flexibility, fallbacks and unified billing; going direct gives lowest latency and provider-specific features. When each makes sense.
OpenRouter · Primers passos
From signup to your first key, with no billing surprises.
Create the account, understand the prepaid-credit model and generate an API key that never leaves the server.
OpenRouter · Primers passos
From key to your first model response, two ways.
Your first chat-completions request via curl and the OpenAI SDK pointed at OpenRouter, with model choice and reading the response.
OpenRouter · Models i routing
Hundreds of models from many providers, one identifier.
Hundreds of models from many providers behind one API. How they're named, who serves them and how you list them.
OpenRouter · Models i routing
An ordered list of models in case the first one fails.
The "models" array defines an ordered fallback chain. If the first fails, OpenRouter tries the next. Resilience with no extra code.
OpenRouter · Models i routing
You decide which backend serves each model.
The "provider" object controls which backend serves a model — order, fallbacks, required params, price/throughput sorting and data policy.
OpenRouter · Costos i límits
One balance, one bill — and the real price of every token.
You pay per token at each model's rate, from one prepaid balance. One bill for every provider and the real cost of each call.
OpenRouter · Costos i límits
What limits exist — and how to spend less without losing quality.
How balance-tied limits work and the real levers you have to spend less without losing quality.
OpenRouter · Integració
Hundreds of models behind an endpoint you already know.
OpenRouter speaks OpenAI's chat-completions schema, so you reuse the official SDK by only changing base_url and api_key.
OpenRouter · Integració
The same features as OpenAI, with a per-model caveat.
SSE streaming and tool calling work like on OpenAI, but support varies per model — check it before relying on it.
OpenRouter · Producció
When a model goes down, the app must keep answering.
In production a model or provider will fail; build a fallback chain, set timeouts and degrade gracefully.
OpenRouter · Producció
Know what you spend, where and why — before the bill tells you.
Measure cost and tokens per call, tag traffic, protect keys and set spend limits before the bill catches you.