
TL;DR: you need an LLM gateway when more than one app calls more than one model provider, or when spend, failover, and access control have grown past a spreadsheet and a shared API key. You can skip it when one app calls one model and the team fits around one table. A gateway earns its place by turning model access into one managed choke point. It adds little when the setup it manages has one door and one key.
Most teams reach this decision through pain, not planning. A second product starts calling a second provider. A contractor needs access for one week and keeps it for six months. A provider outage at 2 a.m. pages someone who has to edit code to switch models. Each event feels small. Together, they describe a system with no single place to see who spends what, which model serves which request, or how traffic moves when a provider fails. A gateway puts that control in one layer. The rest of this article explains what that layer does, how the main options differ, and how to adopt one without breaking a system that already ships.
Keep one decision rule in mind as you read. A gateway pays for itself through central control: one key system, one routing policy, one spend ledger, one failover path. A single app on a single model gets none of those benefits at any scale worth the extra hop. Start with the direct SDK and environment keys. Add a gateway the week you add a second provider, a second team, or a second budget.
An LLM gateway sits between your apps and the model providers they call. Your code sends every request to one endpoint, in one request format, with one key. The gateway forwards each request to the provider you configured, translates the format when the provider needs it, and returns the response through the same endpoint. Providers change behind the gateway. Your app code stays put.
LiteLLM describes this shape in plain terms: one API covers 100+ LLM providers, plus MCP tools and A2A agents, according to its docs at docs.litellm.ai. The count matters less than the contract. One integration pattern replaces a drawer full of SDKs, auth schemes, and retry quirks. A team that adds a new provider edits gateway config, not app code, and the change ships without a deploy of every service that calls models.
Three jobs define the layer. Routing picks the provider and model for each request. Keys and budgets decide who may call what and how much they may spend. Logging records every call so spend, latency, and errors stay visible in one place. Guardrails can plug into the same path, but they sit on top of the gateway job, not inside its definition.
Two boundaries keep the concept clean. A gateway is not an agent framework. LangChain and LangGraph orchestrate multi-step agent behavior, tool calls, and memory. A gateway moves single requests and applies policy to them. A gateway is also not an observability tool. Langfuse and LangSmith trace, score, and evaluate calls. A gateway generates the traffic those tools read. Confusing the three buys the wrong tool for the job. Teams that want routing and budgets buy a gateway. Teams that want traces buy observability and wire it to the gateway output.
Model behavior still differs across providers, even behind one API. Output format, tool calling, and latency vary by model, and a gateway cannot erase those gaps. Our earlier guide on structured-output behavior across providers shows where the same request shape yields different results. Treat the gateway as a control plane, not a uniformity promise. Your evals still need to run per model, and your prompts still need per-model checks.
Routing turns a static provider choice into a policy. LiteLLM documents named strategies for its router: Weighted Pick, Rate Limit Aware, Least Busy, Latency Based, and Cost Based, with Weighted Pick as the default and the recommended pick for production, per the LiteLLM routing docs. Each strategy answers a different question. Weighted Pick spreads load across deployments by weight. Latency Based sends traffic to the fastest endpoint at that moment. Cost Based picks the cheapest deployment that fits the request. Rate Limit Aware backs off deployments near their limits before they start failing.
Failover gives routing its production value. A provider error should move traffic, not wake a human. LiteLLM builds cooldowns, fallbacks, timeouts, and retries with fixed and exponential backoff across deployments and providers. OpenRouter states its version in one line: if a provider returns an error, OpenRouter falls back to the next provider for the same model, per the OpenRouter FAQ. The mechanism differs, but the outcome matches: one bad provider stops serving your users only when every fallback has failed, not when the first one trips.
OpenRouter adds per-request routing variants that change provider order without config edits. The :nitro variant sorts providers by throughput for faster responses. The :floor variant sorts by price and favors the cheapest options. The :exacto variant sorts with quality-first signals tuned for tool-calling reliability. A team can send bulk classification traffic through :floor and tool-heavy agent traffic through :exacto, with the same model name in both calls. Routing becomes a call-site decision, not a deploy.
Cost control runs through virtual keys. LiteLLM gives each app or person a virtual key with a budget and a rate limit, per the virtual keys docs. Its walkthrough hands the search team a key with a $200 monthly budget. The pattern scales to real org charts: one key per team, one key per environment, one key per customer tier. Spend shows up per key, so a cost spike points at a team and a feature, not at a shared account with ten owners.
Routing also shapes cost in ways a price table hides. Cost-based routing moves cheap, tolerant traffic to cheap models and reserves frontier models for requests that need them. Prompt caching cuts repeat-token spend on top of routing, and the two levers stack: routing picks the cheap path, caching shrinks the tokens that travel it. Neither lever fixes a prompt that sends a full document on every call. Gateway policy manages spend. Prompt design still owns it.
Three gateways cover most production setups, and they differ in shape more than in slogan. LiteLLM suits teams that want to self-host and keep the control plane inside their own infrastructure. Portkey suits teams that want a managed control plane with deep spend and access tooling. OpenRouter suits teams that want instant access to many models with pass-through pricing and no hosting work. The table below lines up the differences that decide the pick.
| Feature | LiteLLM | Portkey | OpenRouter |
|---|---|---|---|
| Deployment | Self-hosted proxy, open source core | Managed SaaS control plane | Managed SaaS, no hosting |
| Model count claim | 100+ providers behind one API | Over 250 models via one interface | Many providers per model, one endpoint |
| Routing and fallback | Named strategies, cooldowns, retries | Routing, fallbacks, and load balancing | Auto fallback, :nitro, :floor, :exacto variants |
| Budget and spend tracking | Virtual keys with budgets and rate limits | Budgets, spend tracking, and access controls | Credits, pass-through pricing, BYOK option |
| Data retention controls | Self-hosted logs stay in your stack | Guardrails and access policies | Zero-data-retention routing policies |
| Pricing shape | Hosting cost plus optional enterprise terms | Managed plan pricing | No markup on inference, fee on credit purchase |
Pick LiteLLM when your team runs its own infrastructure and wants the gateway inside its network, with full control over logs and config. Pick Portkey when you want a managed gateway with broad model coverage; its docs present it as a unified interface for over 250 AI models, with tools for control, visibility, and security, per the Portkey docs. Pick OpenRouter when you want the shortest path to many models with pass-through pricing and no server to run. OpenRouter passes through provider pricing with no markup on inference, though it charges a fee when you purchase credits, per its FAQ. Its bring-your-own-key terms add a $25,000 monthly allowance with no BYOK fee, and usage past that allowance carries a 5% fee on what the same model and provider would cost on OpenRouter. Treat the credit-purchase fee as an open item: the FAQ confirms a fee exists but states no percentage for it, so confirm the number at signup before you budget around it.
Model counts deserve a skeptical read. LiteLLM cites 100+ providers and Portkey cites over 250 models, and both numbers move as providers join and leave. Count the models your team ships with, not the catalog total. A gateway with 250 models you never call gives you nothing that a gateway with 20 models you call daily lacks. Check the three models your roadmap needs, check their tool-calling and structured-output behavior, and let that short list decide.
Key hygiene gives a gateway its clearest security win. Apps hold gateway keys, not provider keys. A leaked app key exposes one virtual key with one budget and one rate limit, and you revoke it in one place. A leaked provider key exposes the whole provider account until someone rotates it across every service that embedded it. Central keys also end the quiet sprawl where each service owner keeps a private key file and no one can list who holds access.
Data controls work at the same choke point. OpenRouter documents zero-data-retention routing: a provider with a zero-data-retention policy stores your data for no period of time, and OpenRouter privacy settings can restrict traffic to endpoints that carry that policy, per the zero-data-retention guide. Enforcement runs at four levels: global, per model group, per guardrail, or per request. A team handling regulated input can set the global rule to zero-retention endpoints and carve out per-request exceptions for low-risk traffic, with the policy visible in one config instead of scattered across services.
Logging cuts both ways, so read the retention terms before you trust the layer. A gateway that logs prompts for spend tracking holds your users’ text in its store. Self-hosted options keep those logs in your stack, under your retention policy. Managed options hold them under theirs, and you should know the window, the region, and the deletion path before regulated traffic flows through. Ask the vendor three questions: what fields does the log hold, how long does each field live, and who can export it.
Guardrails plug into the gateway path at the point where every request already passes. Content filters, PII redaction, and topic blocks apply once, for every app, instead of once per service with drift between copies. Pair that control with grounding and hallucination controls at the app layer. A gateway filter blocks bad input and bad output categories. Grounding fixes wrong answers. Both layers matter, and neither replaces the other.
A gateway migration fails when it moves all traffic at once. Move one workflow first, and pick the workflow that hurts most: the one with the worst failover story or the loosest budget. Run it through the gateway while the old direct path still serves the rest of your traffic. Compare latency, error rates, and spend for that workflow before you widen the cutover. A gateway that adds 50 milliseconds to every call needs that fact on the table before it touches your latency-sensitive path.
Shadow traffic gives you a second safety net. Send a copy of live requests through the gateway without serving its responses, then compare outputs against the direct path. Mismatches surface format gaps, model alias errors, and header quirks before users meet them. Dual-run the risky models, not the whole fleet. Shadow traffic costs tokens, so scope it to a sample and a window, then stop it.
Budgets belong in the rollout before features do. Set a virtual key per team and per environment with a budget that pages someone when it hits 80%, not when it hits 100% and the key dies mid-day. Set spend and latency alerts on the same dashboard your on-call already watches. A gateway without alerts just moves the surprise from the provider bill to the gateway bill.
Keep a direct-provider escape hatch and test it. A gateway outage should degrade to a direct call for your top workflow, not to a full outage. Document the hatch, store the provider key outside the gateway, and run a drill each quarter where the team flips one workflow to direct and back. An escape hatch you never test is a rumor, not a plan.
Measure time to first token and output quality before and after the cutover, per workflow. A gateway adds a hop, and that hop costs milliseconds. Most teams accept the cost for the control it buys. Some latency-critical paths will not, and those paths can stay direct with a documented exception. Wire gateway traces into your LLM observability stack so latency, errors, and spend stay visible after the migration team moves on. A gateway without traces hides the problems it was bought to expose.
An LLM gateway earns its keep in one sentence: one API, one key system, one routing policy, one spend ledger for every model your apps call. LiteLLM fits teams that self-host. Portkey fits teams that want a managed control plane with broad coverage. OpenRouter fits teams that want fast access with pass-through pricing. All three beat a drawer of shared provider keys the moment a second team, a second provider, or a second budget enters the picture.
Your next step fits in one sprint. Pick the single workflow that needs failover or a hard budget most. Route it through one gateway, set its key budget and its alerts, and watch its spend log for two weeks. Expand to the next workflow only when the log proves the value. Central control grows one workflow at a time, and that pace keeps production safe while the gateway proves itself.