What is an LLM gateway? The 2026 guide
By Felix Wunderlich -
Updated August 16, 2026. Definitions and vendor claims verified at publish time.
TL;DR: an LLM gateway is a service that sits between your application and the model providers, giving you one API, one set of credentials and one bill for many models. Your code points at the gateway's base URL instead of each provider's SDK, and the gateway handles model routing, failover between providers, per-request logging, cost tracking and access control at that single point. "AI gateway", "LLM router" and "LLM proxy" describe overlapping parts of the same job.
Almost no production AI application stays on one model, and that is the whole reason this category exists. Providers ship incompatible APIs, deprecate models on their own schedules, have outages at inconvenient times and bill you separately, so teams converge on a single layer that absorbs all of that instead of spreading it through the codebase. This guide defines that layer, separates it from its neighbors, and covers when you actually need one and how to choose between building, buying and open source. Disclosure up front: Opper runs a hosted LLM gateway, so this guide has a vendor behind it, but the definitions apply to the whole category and every competitor claim links to a primary source.
What is the difference between an LLM gateway, an LLM router and an LLM proxy?
The terms get used interchangeably, and they describe different amounts of the same stack. A proxy translates requests between API formats, a router decides which model serves each request, and a gateway packages both plus the operational layer around them. All three rely on the same underlying switch, your code calling a different base URL.
| Term | Core job | What it typically leaves out |
|---|---|---|
| LLM proxy | Forwards requests and translates between API formats, so OpenAI-style code can reach other providers | Choosing models, failover policy, cost controls |
| LLM router | Decides which model or provider serves each request, by rule, price or capability | Authentication, logging, billing, the rest of the operational layer |
| Load balancer | Spreads identical requests across instances or keys of the same backend | Anything cross-provider, it has no model awareness |
| LLM gateway | Puts all of the above behind one API: translation, routing, failover, observability, cost and access control | Inference itself, a gateway calls model providers, it does not host models |
"AI gateway" is the broadest label of all. It is favored by API-management and edge vendors extending existing gateway products to AI traffic, and it can cover image, speech and other model types beyond language models. As of 2026 the two terms describe largely the same products, which is why our buying guides for AI gateways and LLM gateways overlap heavily.
What does an LLM gateway actually do?
A gateway does five jobs, roughly in the order teams discover they need them:
- One API for many models. The gateway exposes a single endpoint and addresses models by name, typically in a
provider/modelformat, so switching models becomes a string change rather than a new SDK integration. Good gateways speak the formats your code already uses, so adoption is a base URL swap. - Routing. Rules decide which model serves which request, by capability, price, region or an alias you control, so you can move traffic between models without a deploy.
- Failover. When a provider degrades, the gateway retries the same or an equivalent model on another provider. This is the feature that turns a provider outage from an incident into a log line.
- Observability and cost control. Every request passes one point, so the gateway can record model, tokens, latency and cost per request, attribute spend to teams or keys, and enforce budgets. Consolidated billing across providers falls out of the same position.
- Compliance and access control. The same choke point is where you enforce which providers, regions and retention behavior are allowed. One thing to keep straight: the gateway's own hosting region does not decide where inference happens, the route to the model provider does, so a gateway needs per-route region control for residency to mean anything. We cover how that works in practice on our compliance page.
When do you need an LLM gateway?
Not on day one: a prototype talking to a single provider through that provider's SDK is the right architecture, and adding a gateway there is premature. The trigger points are predictable, and most teams hit one of them within the first months of production traffic: the second model, because now you have two SDKs and two billing dashboards, the first provider outage, because now you want failover you can configure rather than code, the first cost review, because per-request attribution across providers is miserable to retrofit, and the first security review, because someone asks where prompts flow and what is retained, and the answer is scattered across provider policies.
The usual counterargument is latency, and it is weaker than it sounds. We measured it in our April 2026 latency benchmark: of the two gateways tested against calling OpenAI directly, one matched the direct endpoint on time to first token within confidence intervals and the other, OpenRouter, was 70ms faster than going direct, while the choice of serving region moved time to first token by more than a second in the same benchmark, a far bigger lever than the gateway hop.
Should you build, buy or go open source?
Building your own thin proxy is a reasonable first step and a poor long-term home, because the maintenance surface, new providers, API changes, failover logic, dashboards, grows quietly until it competes with product work. We wrote up the full economics in Buy to Build: renting the AI gateway, so this article keeps it to one paragraph: build when the gateway is your product, otherwise rent the layer and spend the engineering elsewhere.
If you want open source, the honest recommendation is LiteLLM: the core gateway is MIT-licensed and, in its own words, production-grade, you self-host it on your own infrastructure with your own Postgres and Redis, it supports a vendor-stated 140+ providers, and a paid tier adds SSO and audit logs. The trade is that you operate it, upgrades, provider API changes and scaling included. Here is how the main options divide, with the ten-way rankings living in the LLM gateway and AI gateway guides:
| Option | Category | Pricing model | Where prompts flow |
|---|---|---|---|
| Opper | Hosted gateway and control plane | No markup on inference, fee on credit purchases, see pricing | Platform in AWS Stockholm, EU routes end to end, no prompts stored by default |
| OpenRouter | Hosted model marketplace | No markup on tokens, fee on credit purchases | No prompt logging at the gateway unless you opt in, retention at the underlying provider varies by route |
| LiteLLM | Self-hosted open-source gateway | MIT-licensed and free, paid tier for SSO and audit logs | Your own infrastructure |
| Cloudflare AI Gateway | Edge platform add-on | Core features free, fee on unified-billing credit purchases | Request and response logging on by default, capped log storage per plan |
How does Opper implement an LLM gateway?
Opper is one implementation of the pattern above, and since the product page covers the commercial side, here are just the mechanics. Adoption is the base URL swap this article keeps describing, your existing SDK pointed at one endpoint:
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.opper.ai/v3/compat",
api_key=os.environ["OPPER_API_KEY"],
)
response = client.chat.completions.create(
model="openai/gpt-5-mini",
messages=[{"role": "user", "content": "Hello"}],
)
The same base URL serves the OpenAI Chat Completions, Anthropic Messages, Gemini generateContent and OpenAI Responses formats, per the drop-in SDK docs, and models are addressed as provider/model across 700+ models. Behind the endpoint sit the jobs from the list above: aliases and automatic fallback that reroutes a failed request within roughly 180ms, with published uptime data rather than claims, per-request tracing of model, tokens, latency and cost, and the residency posture documented on the compliance page: platform in AWS Stockholm, EU routes end to end, and no prompts stored by default, only the metadata that powers analytics. Pricing is no markup on inference, with the details on the pricing page.
Common questions about LLM gateways
Why use an LLM gateway instead of calling provider APIs directly?+
A single direct integration is the right call until you need something a second endpoint breaks: another model, a fallback, or a cost report. A gateway gives you one API and one set of credentials across providers, failover that does not require a deploy, and per-request records of model, tokens, latency and cost. If you are certain you will only ever call one provider, you can skip it.
What is the difference between an LLM gateway and an LLM router?+
An LLM router is the decision component, it picks which model or provider serves each request. An LLM gateway is the broader service that contains a router plus the operational layer around it: authentication, failover, logging, cost tracking and access control. A proxy translates requests between API formats, and all three rely on the same underlying switch, your code pointing at a different base URL. Vendors use the labels loosely, so compare features rather than names.
Is an AI gateway the same as an LLM gateway?+
As of 2026 they largely describe the same product category. "AI gateway" is the broader label, used by API-management and edge vendors extending existing gateway products to AI traffic, and it can cover image, speech and other model types. "LLM gateway" emphasizes the developer stack around language models. The buying guides split the same way, see our rankings of the best AI gateways and the best LLM gateways.
Is there an open-source LLM gateway?+
Yes. LiteLLM is the most established, an MIT-licensed proxy and gateway you self-host on your own infrastructure with your own Postgres and Redis, supporting a vendor-stated 140+ providers, with a paid tier for SSO and audit logs. Running it means operating it, upgrades, provider API changes and scaling are yours. For the wider field, hosted and open source, see the best LLM gateways in 2026.
Does an LLM gateway add latency?+
Not uniformly, in our testing. Our April 2026 latency benchmark compared two gateways against calling OpenAI directly: Opper matched the direct endpoint on time to first token within confidence intervals, OpenRouter was 70ms faster than going direct, and the choice of serving region moved latency far more than the extra hop did. Each gateway makes its own trade-offs, so test the one you are evaluating on your own workload.
When should you replace a home-built LLM proxy with a commercial gateway?+
When maintaining it competes with product work. A home-built proxy usually starts as a thin translation layer and quietly grows failover logic, provider quirks, dashboards and key management, and the switch tends to happen at the second or third provider integration or after the first on-call incident it causes. We cover the full economics in Buy to Build: renting the AI gateway.
Which is the best LLM gateway?+
It depends on four axes: the pricing model, where your prompts flow and what is retained, whether you want self-hosted or hosted, and how actively the product is developed. We maintain sourced rankings of the best LLM gateways and the best AI gateways, with primary-source citations for every claim, so you can weigh those axes yourself.
Do LLM gateways store my prompts?+
It varies more than any other property in the category, so read retention policies rather than landing pages. Some gateways log full request bodies by default, some store only metadata, and some let you toggle logging per key. Opper's default is that no prompts or completions are stored, only the metadata that powers analytics, such as model, token counts, latency and cost, documented on the compliance page.
Route a request through one
The fastest way to understand the category is to make one call through it. Create a free Opper account, point your existing OpenAI, Anthropic or Gemini SDK at the base URL above following the drop-in SDK docs, and browse the 700+ models behind it, or start from the gateway product page if you are evaluating rather than experimenting.