What Is an LLM Gateway? Routing, Billing, Failover in 2026

Blog / Relays & gateways

What Is an LLM Gateway? Routing, Billing, Failover in 2026

An LLM gateway is a service that sits between your application and the APIs of several model providers. Your application only talks to the gateway. The gateway authenticates the request, picks a backend model, forwards the request, records usage, and switches to another route if a backend fails. When one API key can call models from several providers, this layer is usually what makes it possible.

This article covers where an LLM gateway sits in the request path, the four things it does, and a checklist you can use when choosing one.

Where does an LLM gateway sit in the request path?

Without a gateway, a request looks like this:

Your app → a model provider's official API

With a gateway:

Your app → gateway (one address + a key issued by the gateway) → a backend model provider's API

Your application sees only the gateway's endpoint and the key the gateway issued. Which providers are connected behind it, whose credentials are used, and where the request ends up are all decided inside the gateway.

This only works because the interfaces are compatible. A common approach is for the gateway to support both the OpenAI and Anthropic API formats, so tools already written for those formats usually need just a new endpoint address and key. For the details, see How one API key can call multiple models: interface compatibility and how gateways work.

What are the four things a gateway does?

1. Routing: who gets this request?

Routing rules can be simple, such as "send it to whichever provider owns the model you named". They can also assign requests automatically by task difficulty. AGI Plan's Prism scheduling layer is the latter kind: it assigns each request to one of four capability groups (frontier reasoning, balanced general-purpose, flagship Chinese models, and fast lightweight) based on task difficulty. Whether to let the gateway assign automatically depends on whether you want to control model selection yourself.

2. Unified billing: how do several providers' charges become one bill?

Each provider has its own pricing unit, currency, and top-up method. The gateway converts them into one unit, and you pay a single account. AGI Plan's unit is called CU. 1 CU equals 1,000 output tokens of a baseline model. For the conversion method, see What AGI Plan's CU is. If you first want to know why tokens are the billing unit, read What a token is in LLMs.

3. Failover: what happens when one provider goes down?

A gateway can detect backend failures and resend the request to another backend of the same class. Whether it does this, how it does it, and whether it quietly switches to a model with different capabilities varies by implementation, so this is something you need to ask about.

4. Key and usage management

A gateway usually lets you create multiple keys and set a purpose for each, so you can split usage by project. For ways to control spending, see How to control API spending.

Does a gateway add latency?

There is one more hop, so in theory there is a bit of extra network time. How much you notice depends on the route from the gateway to the backend and the route from you to the gateway. To quantify it, don't go by feel; measure it yourself. cdnping's online speed test measures first-connection time and round trips from your browser to various APIs. For background, see Latency when accessing AI APIs from China.

What should you check when choosing a gateway?

Here is a checklist you can tick off directly.

ItemWhat to ask or look at
Is availability published?Is there data you can download and recompute yourself, rather than just a percentage?
How is availability calculated?What are the numerator and denominator, and which kinds of failures are excluded?
Data policyIs request content written to disk, used for training, or resold?
Official authorizationIs it an official channel, and does the operator say so explicitly?
Models and regionsWhich models have regional restrictions (refer to the official pages)?
Billing transparencyHow are units converted, and can you check balance and usage at any time?

For a fuller pre-purchase check, read Are third-party AI gateways reliable? Eight things to verify before buying.

Example: AGI Plan's public availability endpoint

AGI Plan is a business partner of cdnping, so it is used as the example here. This covers only what it publishes. Treat it as an example from a party with a stake in the outcome.

AGI Plan provides an endpoint that needs no login: https://agiplan.dev/api/status/requests?month=YYYY-MM. It returns hourly success and failure counts for each capability group. The default is CSV; add format=json to get JSON.

Its published formula is: availability = successes / (successes + failures caused by the platform itself), and only 5xx responses count as platform failures. One thing to note about this formula: errors caused by the request itself, such as 4xx, are not in the denominator. When you look at any other provider's numbers, ask this question first.

You can see the results mirrored by cdnping on AGI Plan's status page, or download the raw data yourself and recompute it with the formula above.

On data policy, AGI Plan states that request content is not written to disk by default, and that content is not used for training or resold. It also says explicitly that it is not an officially authorized channel. All of the above is subject to what the official site currently says.

If I'm a beginner, what should I do next?

  1. Work out what you actually need: swapping the endpoint address in a tool like Claude Code or Codex, or calling models from your own program.
  2. Read What an API key is so you know to keep keys secret and out of public repositories.
  3. Check the gateway you plan to use against the checklist above, focusing on how availability is calculated and on the data policy.
  4. Try it with a small amount first to confirm that latency, stability, and billing match your expectations, then decide between a monthly plan and pay-as-you-go. For how to decide, see Pay-as-you-go or monthly for AI APIs.

If you want to know about AGI Plan: it is a multi-provider aggregation gateway sold as a monthly subscription, billed in RMB, with no overseas credit card required. One subscription can be used across multiple capability groups. Tools like Claude Code and Codex connect by changing a single endpoint address. Some models are marked as available only outside China; see AGI Plan's models page for specifics. For the getting-started flow, see agiplan.dev/startup. To repeat: AGI Plan is a business partner of cdnping, so use the checklist above to decide which provider to pick.

Related articles

Keep reading