Try Bifrost Enterprise free for 14 days.
Request access
[ AI Gateway ]

What is an AI gateway?

Quick answer

An AI gateway is a middleware layer between your applications and AI model providers, including large language model (LLM) providers. It gives callers one consistent API and applies routing, failover, caching, token and spend limits, safety checks, and logging in one place, instead of inside each application.

Updated 2026-09-07

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."

Source: Gartner, AI gateways market definition

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.

py

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.

Diagram
[ RENDERING DIAGRAM ]

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.

CapabilityWhat it doesWhy it belongs at the gateway
Unified APIOne request schema across providers, for example an OpenAI-compatible oneModel choice becomes configuration instead of a code change
Routing and load balancingDistributes across keys, regions, deployments, and model tiersOnly the shared layer knows global load and quota state
Failover and resilienceRetries, fallback chains, circuit breaking on provider errorsProvider incidents are absorbed centrally, not patched per app
Governance and cost controlVirtual keys, per-team budgets, rate limits, access rulesSpend limits are meaningless if any service can bypass them
CachingExact and semantic caching, plus prompt cache awarenessA shared cache can answer a repeat prompt from any application, not just the one that made it first
Guardrails and safetyPII redaction, content filtering, prompt injection checksCompliance controls must be unavoidable to be credible
ObservabilityLogs, traces, token and cost metrics across all trafficComparing 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 gatewayAI gatewayLLM orchestration SDKModel serving engine
ExamplesKong, NGINX, Envoy GatewayBifrost, Agent Router (formerly Envoy AI Gateway)LangChain, LlamaIndexvLLM, SGLang, llama.cpp
Runs asNetwork proxyNetwork proxyIn-process libraryGPU server process
UnderstandsHTTP routes and headersModels, tokens, prompts, streamsChains, agents, retrievalWeights, batching, KV cache
Unit of controlRequests per secondTokens, spend, model, teamApplication logicGPU memory and throughput
Language couplingNoneNoneOne language per SDKNone
Enforceable centrallyYesYesNo, apps can bypass itYes, 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

Diagram
[ RENDERING DIAGRAM ]

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 pathNo extra third party in the path (prompts still reach your model provider)Prompts transit a third party
OperationsYou run, scale, and upgrade itVendor operated
LatencySame VPC; overhead depends on the gateway, so benchmark itExtra public network round trip
CustomizationFull, including source changesLimited to configuration
Failure couplingYour incidentYour 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

  1. 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.
  2. 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.
  3. Provider and modality coverage. Chat is table stakes. Check embeddings, reranking, audio, images, and batch, since gaps push teams back to direct integration.
  4. Streaming fidelity. Verify that time to first token is preserved, that usage totals still arrive, and that client cancellation propagates upstream.
  5. 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.
  6. 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