A year or two ago, most applications called one model from one provider, with the API key sitting in an environment variable and the cost showing up on a single invoice. That arrangement has quietly come apart. A typical product now calls several models from several providers, for chat, embeddings, extraction and agent steps, and each new team that adopts AI repeats the same plumbing: another copy of the keys, another retry loop, another dashboard that shows part of the spend.
The AI gateway has emerged as the layer that gathers that plumbing into one place. This guide explains what an AI gateway is, what it does with each request, how it differs from an API gateway and an LLM router, and the signals that tell a team it is time to put one in front of its models.
What is an AI gateway?
An AI gateway is a layer between your applications and the AI models they call. Every model request passes through it, so the concerns that would otherwise be repeated in every service (credentials, routing, failover, rate limits, budgets, content checks and logging) are handled once. Applications keep the API they already speak, almost always the OpenAI-compatible one, and point it at the gateway's base URL instead of a provider's.
You will also see the term LLM gateway. It names the same layer with a narrower scope, language models only, while AI gateway is used when the same layer also fronts embeddings, images, speech or the tools an agent calls. Most products, including ours, use the two interchangeably.
What an AI gateway does
The work an AI gateway takes on falls into a handful of jobs. Not every gateway does all of them, and the ones that matter most depend on whether the problem is reliability, cost, safety or audit.
| Job | What it means in practice |
|---|---|
| One API | Applications call one endpoint with one key, in the OpenAI request shape, whatever provider serves the model. |
| Credentials | Provider keys and cloud accounts live in the gateway, not in each service, and each application gets its own gateway key. |
| Routing and fallback | A request goes to the model and provider the policy chooses, and moves to another when a provider fails or rate-limits it. |
| Limits and budgets | Requests per minute, spend per key or project, and caps per agent session, enforced before a provider is called. |
| Guardrails | Prompts, responses and tool results are checked for unsafe content or prompt injection, and flagged or blocked. |
| Records | A record per request: model, tokens, cost, latency and, when the gateway chose the model, why. |
| Governance | Rules set once for the organization and inherited by every team and key, with changes audited. |
The common thread is that each job is easier, and more trustworthy, when it happens at the one point every request already passes through. A budget enforced in each service can be skipped by the service that forgot it; a budget enforced at the gateway cannot.
How a request moves through an AI gateway
The order of operations matters more than it first appears, because a check placed after the model call cannot prevent what it detects. A well-built AI gateway handles a chat request in roughly this sequence:
- Authenticate the key and find which application, project and organization it belongs to.
- Resolve the policy that applies to that key: which models it may use, how one is chosen, what is inspected, and what it may spend.
- Check the prompt against the input guardrails, before any model sees it.
- Check the limits: the key's rate, and whether the request's maximum possible cost still fits in its budget.
- Choose the model and provider, either the one the request named or the one the routing policy picks, with fallbacks ready.
- Call the provider, streaming the answer back as it is generated, and move to the next candidate if the call fails.
- Check the response against the output guardrails, before it reaches the caller when the policy blocks.
- Record and settle: write the usage, the cost and the decision, and replace the reserved cost with the real one.
Step 4 deserves a closer look, because it is where gateways differ most. A token limit can only be counted exactly after the response arrives, so a gateway that counts afterwards lets a burst of concurrent requests overshoot it. Microsoft's own documentation for the Azure API Management token limit policy says so plainly: concurrent requests "can temporarily exceed the configured token limit". Reserving each request's maximum cost before it is served closes that gap, at the price of occasionally refusing a request whose worst case does not fit.
AI gateway, API gateway and LLM router
Three terms are often used loosely around this layer, and they describe different things.
An API gateway fronts your own services: it authenticates callers, routes by path to the right backend and limits requests by count. It treats each request as opaque. Amazon API Gateway is a typical example. It knows nothing about tokens, models or the cost of an answer, which is why AI features have been added to several API gateways as plugins. We compare the two in detail in AI gateway vs API gateway.
An LLM router decides which model should answer a given request, usually by reading the prompt and weighing quality against cost. Some routers only recommend a model and leave the call to you. A router can live inside a gateway, and increasingly does; the distinction is covered in LLM gateway vs LLM router.
An AI gateway is the layer every model call passes through. It may contain a router, but its first job is control: who may call what, what it may spend, what is inspected and what is recorded.
Hosted or self-hosted
AI gateways come in two shapes, and the choice is mostly about who operates the request path.
| Hosted AI gateway | Self-hosted AI gateway | |
|---|---|---|
| Running it | Nothing to deploy; the vendor operates it | You deploy, scale, patch and monitor it |
| Time to adopt | Change a base URL and a key | Days to weeks, plus ongoing operation |
| Where model calls run | The vendor's provider accounts, your provider keys, or your own cloud accounts | Your provider keys and your own infrastructure |
| Data path | Through the vendor, under its retention terms | Inside your network |
| Upgrades | Continuous, by the vendor | When you schedule them |
The line between the two has blurred. A hosted gateway that can serve on your own Azure OpenAI, AWS Bedrock or Google Vertex account keeps the model calls inside your cloud contract while someone else runs the gateway, and zero data retention settings keep prompts out of the gateway's storage. For many teams that removes most of the reason to operate one themselves.
Signs you need an AI gateway
An AI gateway earns its place when the plumbing around model calls starts to cost more attention than the calls themselves. The signals tend to arrive together:
- Keys in several places. Provider keys are copied into multiple services, and rotating one means a coordinated deploy.
- More than one provider. Different teams have picked different models, and nobody can compare their cost or quality on one screen.
- Spend you cannot attribute. The invoice arrives as one number, and a runaway agent loop is discovered on it rather than prevented.
- Outages that become incidents. One provider's rate limit or downtime takes a feature down, because nothing moves the request elsewhere.
- Questions you cannot answer. A customer or an auditor asks what was sent to which model, and the answer is spread across application logs, if it exists at all.
- Agents. Agent loops multiply calls, tools and spend, and they need limits per run that no single provider enforces.
A single prototype calling one model rarely needs a gateway. The second team, the second provider or the first serious budget usually does.
What to look for in an AI gateway
Feature lists converge quickly, so the useful questions are about behaviour under pressure rather than about the presence of a checkbox.
- Are limits maximums or estimates? Ask whether concurrent requests can pass a budget, and how the gateway prevents it.
- Does it check what providers actually do? Providers differ in which request fields they honor, even for the same model; a gateway that only trusts declared support will route a JSON schema request to a deployment that ignores it. We measured how often that happens in Same model, different behavior.
- Can a team loosen a rule set above it? Inheritance should let lower levels tighten, not quietly undo, an organization's policy.
- What is recorded, and for how long? Per-request records should cover cost and the model that actually served, with retention you can turn off.
- Where can the model calls run? Managed models, your own provider keys, and your own cloud accounts each suit different workloads; the best answer lets one policy use all three.
- How does it fail? On a provider error, does it move to another model or provider, and does it tell you it did?
How AI gateways are priced
Hosted AI gateways charge in a few recognizable ways, and the differences matter more as volume grows. Some resell model access and add a fee or margin on the tokens; some charge a platform fee per request or per month and let your own provider bill the tokens; some meter the number of requests they log. Self-hosted gateways are usually free to download and cost what it takes to run, monitor and upgrade them, which is mostly engineering time.
Two questions cut through the comparison. First, who bills the tokens: if you bring your own provider keys or cloud accounts, the gateway should add nothing to them, and its own fee should be visible separately. Second, what happens at the limit: a plan that refuses requests when its allowance runs out behaves very differently in production from one that keeps serving at a known overage rate. Our own plans are on the AI gateway pricing page.
Adopting an AI gateway without a big-bang migration
Because an AI gateway speaks the API your code already uses, adoption can be gradual, one service at a time.
- Point one service at the gateway. Change its base URL and key, and keep naming the same model, so behaviour does not change while you confirm requests flow and records appear.
- Move the provider keys. Connect them to the gateway and remove them from the service, so rotation and revocation happen in one place.
- Set limits that match today's usage. Add a rate limit and a spend cap per key a little above what the service already uses, so a runaway client is stopped without touching normal traffic.
- Turn on checks in watch mode. Start guardrails in a log-only mode and read what they would have blocked before letting them block anything.
- Only then change model choice. Once the records show what each request costs and how it performs, let the routing policy pick models, or add fallbacks for the ones you pin.
Each step can be reverted by changing a base URL back, which keeps the risk of the change small.
How Inferbase approaches it
Inferbase is a hosted AI gateway built around those questions. It exposes one OpenAI-compatible API in front of managed models, your own keys for fourteen providers, and your own Azure, Bedrock or Vertex accounts. Configurations set for the organization, a project or a key decide routing, guardrails and request settings, with locks lower levels cannot loosen; budgets and spend caps are reserved before each request is served; and every request is recorded, with the routing decision when the gateway chose the model. The AI gateway overview walks through each part, and the enterprise AI gateway page lists the organization controls.
