Docs menu

Docs / Concepts

What is an AI gateway

An AI gateway puts many models behind one API and one key. How Cent AI does it, from the key check to the charge.

Last updated


The idea

An AI gateway is a service that sits between your application and AI models. Your application talks to one API with one key, and the gateway sends each request to the model you asked for, returns the answer and accounts for it.

Without a gateway, each model provider means another account, another key, another SDK setting and another bill. With a gateway, you change models by changing the model field, and usage and cost for all of them are in one place.

How Cent AI works

PartIn Cent AI
One keyThe same API key, cai_<secret>, works across the models of the catalog. See Authentication
Three API formatsOpenAI Chat Completions and Responses at https://api.cent-ai.dev/v1, Anthropic Messages at https://api.cent-ai.dev. Existing SDKs and tools work by changing the base URL and the key
Many modelsChat models listed by GET /v1/models, each with a stable public name such as glm-5.3 or claude-opus-5
Price per tokenFour public rates per model: input, cache read, cache write and output. See Pricing
PrepaidRequests are paid from a prepaid USD balance or a one-time budget pack of $1.99, $9.99 or $99. Payments are made by hand, with no automatic renewal. See Balance
Cost per requestEvery response carries usage.cost, the amount charged. See Request cost

What happens to a request

  1. Key check. The key in Authorization: Bearer or x-api-key is checked. A wrong key returns 401.
  2. Key and project rules. The key's IP and model allowlists, the rate limit of 600 requests per minute, the key's spending limits and the project budget are checked.
  3. Balance. If no balance is available for the model, the request returns 402 and is not sent to a model.
  4. Route. Each model has one or more routes to a model provider. Cent AI picks a route. If a model has more than one route and the first fails before the answer starts, Cent AI tries the next one.
  5. Answer. The answer streams back to you in the format you called. Your request parameters are passed to the model unchanged.
  6. Charge. When the request ends, Cent AI charges it from the token counts the model reported, at the prices in effect when the request was received, and adds usage.cost to the response.

A request rejected in steps 1 to 3, or one that fails before a model accepts it, costs $0.

Conversations and the cache

Coding agents and chat apps resend the whole conversation on every turn. Cent AI sends the next turns of a conversation to the route that served the previous turn, so the model's prompt cache can be hit. Cache rates apply only when the model reports cache tokens. Cent AI does not promise a cache hit rate. See Prompt caching.

What you can see

  • Requests page: every request with its model, status, tokens per rate, rates used and cost. The x-request-id header of a response is the ID shown there.
  • Usage page: totals per day, model, key and project.
  • Content: not stored for successful requests by default; failed requests are kept as encrypted error records for 30 days. See Request data privacy.

Next steps