Skip to main content

Token based rate limiting

You're reading AI Gateway 2026.09.24. The newest release is 1.2.0. Go to the newest release

A single application can exhaust a shared model quota in minutes, and the request count tells you nothing about how much of that quota it used. One request can carry a sentence or a whole document, so a cap of 1,000 requests an hour holds two very different workloads to the same number.

Token based rate limiting counts the tokens the model processed rather than the calls the client made. It tracks LLM consumption closely enough to protect a shared quota, and it caps the client that consumes the most instead of the client that calls the most.

Where token limits apply​

You attach a token based rate limit policy in the operationPolicies block of an LlmProxy, to cap one application, or of an LlmProvider, to cap every proxy that consumes it.

Token based limits read usage from the model's response, so they take effect in the response phase. The request that crosses the threshold still reaches the model, and the gateway rejects the next one.

Rate limiting policies​

This policy is documented in the Policy Hub, the versioned reference for every API Platform policy. For policy categories and how policies chain, see the Policy Hub overview.

PolicyWhat it does
Token-Based Rate LimitCaps usage by token count rather than request count

To cap spend in currency rather than in tokens, see Cost control and budgets. For MCP traffic, which is limited per tool, resource, prompt, or JSON-RPC method, see MCP governance.

Request based limiting​

If you also need a ceiling on the number of calls a client can make, the gateway carries two request based policies. Both apply before the call goes upstream, and both work on any API rather than only on LLM traffic.

PolicyWhat it does
Rate Limit - BasicCaps requests per time window
Rate Limit - AdvancedMulti-dimensional quotas with GCRA or fixed-window algorithms, Redis backend support, and weighted limiting

Use either alongside a token based limit when a client should be held to both a call ceiling and a consumption ceiling.

Was this page helpful?