An AI gateway is a middleware layer that sits between your applications and AI model providers. Instead of each application integrating directly with OpenAI, Anthropic, AWS Bedrock, Vertex, and whatever comes next, every request flows through one service that speaks a unified LLM API and applies policy on the way through.
"Gartner defines an AI gateway as a technology or platform that acts as an intermediary between applications and various artificial intelligence (AI) services or models. Its purpose is to simplify and manage access to AI capabilities, providing a central point to enable security, governance and observability of AI workloads."
It runs as a network service rather than a library inside each application. Because the gateway owns the network path, it can enforce budgets, rotate keys, reroute traffic during an outage, and produce a single audit trail without any application redeploying.
The sections below cover which capabilities belong in a gateway, how it differs from adjacent tools it gets confused with, when the extra hop is worth paying for, and what to evaluate. For the architecture of the proxy itself, including streaming behavior, provider normalization, and deployment topologies, see LLM gateway.
Why direct integration stops working
The first integration is easy. With N applications and M providers, you get N times M integrations, each carrying its own copy of authentication, retry policy, timeout handling, logging, and cost accounting.
Duplicated code is the visible cost. The larger one is that policy becomes unenforceable. Without a central path, nobody can answer "what did the support team spend on GPT-5 last month", revoke one team's access without a deploy, cap a runaway agent loop, or shift traffic off a degraded provider in minutes. No amount of refactoring inside individual repositories fixes that.
The capability model
Products in this category vary. This page groups what they do into seven capabilities, each one something you would otherwise build once per application.
| Capability | What it does | Why it belongs at the gateway |
|---|---|---|
| Unified API | One request schema across providers, for example an OpenAI-compatible one | Model choice becomes configuration instead of a code change |
| Routing and load balancing | Distributes across keys, regions, deployments, and model tiers | Only the shared layer knows global load and quota state |
| Failover and resilience | Retries, fallback chains, circuit breaking on provider errors | Provider incidents are absorbed centrally, not patched per app |
| Governance and cost control | Virtual keys, per-team budgets, rate limits, access rules | Spend limits are meaningless if any service can bypass them |
| Caching | Exact and semantic caching, plus prompt cache awareness | A shared cache can answer a repeat prompt from any application, not just the one that made it first |
| Guardrails and safety | PII redaction, content filtering, prompt injection checks | Compliance controls must be unavoidable to be credible |
| Observability | Logs, traces, token and cost metrics across all traffic | Comparing providers requires one consistent measurement point |
Shared caching and centralized observability are easy to overlook. A shared cache can serve hits across every application behind it. Provider comparison needs one measurement point, because if each team measures latency and cost differently, migration decisions get made on anecdote.
Some gateways, including Bifrost and Azure API Management, also broker tool access through the Model Context Protocol, which puts function calling permissions under the same governance as model access.
AI gateway vs API gateway vs LLM orchestration
These four categories are easy to confuse, partly because "AI middleware" can describe all of them.
| API gateway | AI gateway | LLM orchestration SDK | Model serving engine | |
|---|---|---|---|---|
| Examples | Kong, NGINX, Envoy Gateway | Bifrost, Agent Router (formerly Envoy AI Gateway) | LangChain, LlamaIndex | vLLM, SGLang, llama.cpp |
| Runs as | Network proxy | Network proxy | In-process library | GPU server process |
| Understands | HTTP routes and headers | Models, tokens, prompts, streams | Chains, agents, retrieval | Weights, batching, KV cache |
| Unit of control | Requests per second | Tokens, spend, model, team | Application logic | GPU memory and throughput |
| Language coupling | None | None | One language per SDK | None |
| Enforceable centrally | Yes | Yes | No, apps can bypass it | Yes, per model |
The distinctions that matter in practice:
Against an API gateway. A conventional API gateway routes on paths and headers and limits requests, not tokens; a request-per-second limit is not a spend limit. Some API gateway products now add AI features on top. Azure API Management, for example, adds token limit policies, load balancing across model backends, and semantic caching, which is why the line between the two categories is blurring. If you go that route, check how token limits behave on streaming responses, including whether a request's tokens are counted before it runs or only after it completes.
Against an orchestration SDK. LangChain and similar frameworks build chains, agents, and retrieval pipelines. They can also switch providers, which is why they get compared to gateways, but they run inside your process. A library cannot enforce a budget on a team that declines to import it, cannot see traffic from a Go service if it is a Python library, and cannot be changed without a deploy. The two compose, with the SDK building the application and the gateway governing its traffic.
Against a serving engine. vLLM and its peers perform inference on GPUs you own. A gateway performs no inference at all. If you self-host models, the serving engine sits behind the gateway. The Kubernetes Gateway API Inference Extension, an official Kubernetes project for self-hosting generative models, applies the gateway pattern in front of model servers.
Where it sits in the stack
The gateway is a horizontal layer. Everything that calls a model goes through it, including background jobs and evaluation harnesses, so its cost data is complete.
Who needs one
A gateway adds a network hop, an operational dependency, and a component to run.
You probably do not need one yet if you have a single application calling a single provider, no compliance requirement, and spend small enough that nobody asks about it. A retry wrapper and a metrics counter cover you, and adding a gateway is pure overhead.
The value appears when one of these becomes true:
- Multiple applications. The moment credential and retry logic exists in three repositories, centralizing pays for itself.
- Multiple providers. Provider comparison, fallback, and migration all need one place to switch.
- Multiple teams. Per-team budgets and access control require an enforcement point that teams cannot route around.
- Compliance or audit obligations. Voluntary frameworks such as the NIST AI Risk Management Framework call for accountability structures and documented processes, which are easier to evidence at one chokepoint.
- A provider outage already hurt you. The second incident is the one that justifies failover.
Self-hosted vs managed
| Self-hosted (open source) | Managed SaaS | |
|---|---|---|
| Data path | No extra third party in the path (prompts still reach your model provider) | Prompts transit a third party |
| Operations | You run, scale, and upgrade it | Vendor operated |
| Latency | Same VPC; overhead depends on the gateway, so benchmark it | Extra public network round trip |
| Customization | Full, including source changes | Limited to configuration |
| Failure coupling | Your incident | Your incident, someone else's fix |
The data path can matter more than cost. Every prompt and completion crossing a managed gateway includes whatever your users typed, which can mean customer records, source code, or health data. If you have strict data-handling requirements, consider an open source AI gateway deployed in your own VPC, which keeps the data path internal while still outsourcing the ongoing work of tracking provider API changes.
What to evaluate
- Latency overhead at the proxy hop. Measure added p99 under concurrency, not average. Single-digit milliseconds against a two second provider call is noise. Two hundred milliseconds is a tax on every request forever.
- Behavior when the gateway is down. Ask explicitly. Options are horizontal replicas, a client-side direct-to-provider fallback, or accepting a hard dependency. Any of the three works if it is documented.
- Provider and modality coverage. Chat is table stakes. Check embeddings, reranking, audio, images, and batch, since gaps push teams back to direct integration.
- Streaming fidelity. Verify that time to first token is preserved, that usage totals still arrive, and that client cancellation propagates upstream.
- Governance granularity. Check whether limits are expressed in tokens and currency rather than request counts, and whether they can be scoped per key, team, model, and environment.
- Deployment and extensibility. Self-hosted or managed, and whether custom logic requires forking or a supported plugin interface.
Common failure modes
The gateway becomes a single point of failure. Every request now depends on it. Run multiple replicas, keep state external, health check a real provider path, and test the outage before it happens.
Lowest-common-denominator APIs hide provider features. A gateway that only supports the intersection of provider capabilities makes reasoning controls, cache directives, and safety settings unreachable. Insist on a passthrough escape hatch for vendor-specific fields.
Centralization without ownership. A gateway with no team responsible for it drifts into an unpatched dependency in the critical path of everything.
Dashboards mistaken for quality. A gateway measures cost, latency, and errors. It does not tell you whether answers are correct. That requires LLM evaluation on top of the traffic it captures.
Bifrost
Bifrost is an open-source (Apache 2.0) AI gateway written in Go, built for high-throughput production workloads. It works as a drop-in replacement across supported providers, with retries and fallbacks, exact and semantic caching, virtual keys and budgets, per-key MCP tool filtering, and OpenTelemetry export. Guardrails are available in Bifrost Enterprise. Published benchmarks report less than 15 µs of added latency per request on average at 5,000 RPS. Use them as a starting point, then measure p99 on your own traffic as described above. The buyer's guide and enterprise deployment pages cover the evaluation and topology questions above.
Key takeaways
- A single app on a single provider does not need one. Value starts at multiple apps, providers, teams, or compliance obligations.
- Self-hosting removes a third party from the prompt path, which can matter more than price.
- Evaluate added p99 latency and documented behavior when the gateway itself is down, before evaluating features.
Sources and further reading
- Gartner: AI gateways market definition
- Richardson, API Gateway pattern, the architectural ancestor of the category
- NIST AI Risk Management Framework and its Generative AI Profile (NIST AI 600-1), voluntary guidance currently under revision
- OWASP Top 10 for Large Language Model Applications (2025)
- IBM: What is an AI gateway?, IBM's definition of the category
- AI gateway in Azure API Management, an AI gateway built on an existing API gateway
- Agent Router, formerly Envoy AI Gateway, an open source implementation built on Envoy and now an Agentic AI Foundation project
- Kubernetes Gateway API Inference Extension, inference-aware routing for self-hosted models
- Circuit Breaker pattern, Azure Architecture Center
- OpenAI Chat Completions API reference, the schema behind OpenAI-compatible endpoints
- OpenAI: Responses vs. Chat Completions, OpenAI's recommended API for new projects
- LangChain overview and vLLM documentation, the adjacent layers
- Model Context Protocol, an open standard for connecting AI applications to external systems
- Bifrost MCP gateway
- NIST AI 100-1, AI RMF 1.0 (PDF)
- Bifrost source code on GitHub
- LLM Gateway Buyer's Guide
- Bifrost vs LiteLLM benchmarks
- Bifrost performance benchmarks
- Enterprise deployment
- Bifrost documentation