# What is an AI API gateway, and when do you need one?

> An AI API gateway gives you one key and one URL for several model providers. What it does, what it does not, and when to go direct.

- Published: 2026-10-08
- Author: Gael — Tchavi founder
- Canonical: https://tchavi.com/en/blog/what-is-an-ai-api-gateway

---


You need an AI API gateway if you want to use several model providers with one key, one invoice and one calling code, or if you cannot pay the providers directly. You do not need one if you use a single provider and your bank card goes through without trouble.

I build Tchavi, so I am not neutral. But I would rather tell you straight away what these tools do not do: a gateway does not make the token cheaper, and it adds a network hop. If you do not know why you want one, you can do without.

This article sets out the definitions, describes the three ways to have one, and gives you a simple test for deciding.

## In short

- **Tchavi, an OpenAI-compatible AI API gateway you pay for with mobile money, gives you one key and one URL (`https://tchavi.com/api/v1`) for the models of several providers**, in text, image, audio and video.
- **An AI API gateway is a service placed between your application and the model providers.** It receives your requests, forwards them to the right provider, bills you and keeps a log.
- **It is not cheaper per token than a direct call**, and it adds a network hop. What it gives you is a single key, a local payment method, a usage log and the freedom to switch models by changing one field.
- **Go direct** if you have one provider and a card that works. **Take a gateway** if you have several, or if the international card is your real blocker.
- **There are three categories**: a proxy you host yourself, a managed gateway, or your own code.

## What an AI API gateway is

**An AI API gateway is an intermediary service that exposes a single address and a single key, and relays each request to the provider of the model you asked for.**

Without one, your code talks to OpenAI with the OpenAI key, to Anthropic with the Anthropic key, to Google with the Google key. Each has its own account, invoice, request format and limits.

With one, your code talks to one address:

```js
const res = await fetch('https://tchavi.com/api/v1/chat/completions', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    Authorization: `Bearer ${process.env.TCHAVI_API_KEY}`,
  },
  body: JSON.stringify({
    model: 'gpt-5-mini', // change this field to change model
    messages: [{ role: 'user', content: 'Hello' }],
  }),
});
```

One field, `model`, decides who answers. Nothing else moves.

## What a gateway does

Each function below has a one-sentence definition.

**The single key is an access key that replaces each provider's accounts.** You no longer manage three dashboards and three keys to rotate. If a key leaks, you revoke one.

**The base URL is the single address your client sends its requests to.** If your client follows the OpenAI format, you only need to change this address and the key. On Tchavi, the [base URL doc](https://tchavi.com/en/docs/base-url) shows the common SDKs.

**Unified billing is a single balance, debited on each request according to the model used.** You follow one line of spending for all providers. On Tchavi, this balance is in credits, topped up with mobile money, and each response carries an `X-Credits-Used` header with the cost of the call.

**The usage log is the list of your requests with their model, tokens and cost.** It is what lets you answer "why did the bill double on Tuesday". On Tchavi, the Usage page of the dashboard lists each request with its model, token counts and the credits debited, and you can open the detail of each one.

**Per-key controls are rules attached to a key rather than to the whole account.** The idea: one key per project or per client, which you can cut off without stopping the rest. On Tchavi, you create several keys for different projects, and rate limits follow your account tier ([rate limits](https://tchavi.com/en/docs/rate-limits)).

**Format translation is the conversion of a request from one API format to another.** A concrete example: Claude Code only speaks the Anthropic format. A gateway that can receive that format can accept it and serve it. On Tchavi, that is the `/v1/messages` endpoint, which lets you [connect Claude Code](https://tchavi.com/en/docs/coding-agents).

**Provider fallback is the automatic switch to another host when the first one fails.** This is the function that separates a production gateway from a simple relay. Depending on the gateway, fallback is a setting you configure or a decision made by the service. Always check what yours does, and above all whether it tells you when it changes the model without saying so. On Tchavi, each model ID is served by itself: you choose the model, the gateway does not replace it.

## What a gateway does not do

**It does not lower the token price.** The provider bills the gateway, the gateway bills you, and it takes a margin. Tchavi is not cheaper than a direct call to OpenAI or Anthropic: if you have a card that goes through, direct will be more economical. Exact prices are on each model's page, and I go through them in [this article on prices in FCFA](https://tchavi.com/fr/blog/prix-api-ia-fcfa-2026) (in French).

**It adds a network hop.** Your request goes through one more server before reaching the provider. On a chat call that lasts several seconds, the difference is hard to feel. On a call that has to answer in a few dozen milliseconds, it matters. And the gateway is one more component that can go down.

**It does not erase the differences between models.** A common format does not make all models equivalent: a parameter a model does not handle stays a parameter it does not handle. On Tchavi, a request a model does not support fails with a clear error, rather than being silently emulated.

## The three ways to have one

**A self-hosted proxy is software you install and run on your own server.** You keep full control, including over the logs. In exchange, you manage the machine, the updates, the security of your provider keys, and above all you still need an account and a payment method with each provider. It solves the single key and the format, not the card problem.

**A managed gateway is a service hosted by a third party, which you connect to with a key.** You install nothing. The service holds the provider accounts, the billing and the log. This is Tchavi's category. The trade-off: you trust a third party with the traffic and the availability.

**Building your own is code you write in your backend.** A function that picks the provider, a dictionary of keys, a Postgres table for costs. For two models and one developer, it is perfectly reasonable, and it stays so until the day you have to follow changes in prices, formats and limits across five providers.

|                               | Self-hosted      | Managed                | Home-made        |
| ----------------------------- | ---------------- | ---------------------- | ---------------- |
| You install and maintain      | Yes              | No                     | Yes              |
| Provider accounts to open     | One per provider | None                   | One per provider |
| Solves payment without a card | No               | Depends on the service | No               |
| Control of the logs           | Full             | The service's own      | Full             |

## When you need one, and when to go direct

Ask yourself four questions.

**You use a single provider and your card goes through: go direct.** You pay less, and you avoid a network hop and an intermediary. This is the most common case, and nobody should sell you a gateway here.

**You want to compare or switch models often: take a gateway.** Testing a model from another provider comes down to changing a model name, with no new account and no new code.

**You have several kinds of output, text, image, audio: a gateway makes life simpler.** One key, one balance, one log for everything.

**Your bank card is the blocker: a gateway that accepts mobile money is often the only door.** This is the real issue for many developers in Africa. Providers ask for an international card; yours is declined, capped, or you do not have one. In that case, the token price comes second to the question "can I even pay?". I covered this in [Paying for an AI API without a Visa card](https://tchavi.com/fr/blog/payer-api-ia-sans-carte-visa) (in French). There is also the exchange rate: a provider bills in dollars, your bank converts with its fees, and your budget in shillings or kwacha moves without you doing anything.

## Where Tchavi stands

Here is what is true today, checked against the documentation:

- **OpenAI-compatible.** You change the base URL and the key, and the rest of your code does not move. Requests and responses follow the OpenAI format ([principles](https://tchavi.com/en/docs/principles)).
- **An Anthropic endpoint.** `/v1/messages` exists for Claude Code and Anthropic-format clients. The base URL then stops at `/api` ([coding agents](https://tchavi.com/en/docs/coding-agents)).
- **Payment in mobile money.** You top up a credit balance, with no subscription. Operators and countries are on the [payments](https://tchavi.com/en/docs/payments) page.
- **Several kinds of models.** Text, image, audio, embeddings, video and decisions go through the same key.
- **A usage log.** Each billed request appears there with its model, tokens and credits. The `GET /v1/models` discovery endpoints are not billed and not counted as usage ([models](https://tchavi.com/en/docs/models)).
- **Headers on every response.** `X-Credits-Used`, `X-Credits-Remaining` and `X-Request-Id`, to follow a specific call.

What Tchavi does not do: be cheaper than a direct call, or spare you from choosing your model.

## FAQ

### What is an AI API gateway?

It is a service that sits between your application and the model providers. You send it your requests with a single key; it relays them to the model you asked for, bills you and keeps a log.

### Is an AI API gateway cheaper than a direct call?

No. The gateway takes a margin on the provider's price. It saves you time and gives you access, not money per token.

### Does a gateway slow down my requests?

It adds a network hop. On a chat call of several seconds, it is rarely noticeable. For a very latency-sensitive use, measure before you choose.

### When is it better to call the provider directly?

When you use a single provider and your bank card works. You pay less and have one intermediary fewer.

### Can I use my existing OpenAI code with a gateway?

Yes, if it is compatible with the OpenAI format. You change the base URL and the API key. With Tchavi, the URL is `https://tchavi.com/api/v1`.

### Is a gateway useful if I have no international bank card?

It is often its main reason. On Tchavi, you top up with mobile money and pay for your calls in credits, with no card.

[create your account and top up KES 250](https://tchavi.com/en/register?next=%2Fdashboard%2Fbilling%3Famount%3D250%26currency%3DKES%26from%3Dblog-gateway-en)

> _This article is part of the series "Building an AI product from Africa". Tchavi is an OpenAI-compatible AI API gateway: one key gives access to over 100 text, image, audio and video models, and you pay for it with mobile money, no bank card ([countries and operators](https://tchavi.com/en/docs/payments)). More guides on [the blog](https://tchavi.com/en/blog). Follow us: [LinkedIn](https://www.linkedin.com/company/tchavi) and [X](https://x.com/tchaviai)._

