Component ยท Data side
Rate limit policies (token, advanced, llm-cost)
BOTH Concept Gateway
What it is
The rate limit policies cap how much an LLM provider or proxy can be used. There are request-based limits (advanced-ratelimit), token-based limits (token-based-ratelimit) and budget-style limits (llm-cost-based-ratelimit, which uses llm-cost to compute cost).
Why it exists
LLM calls cost money. Limits protect budgets and stop a runaway agent from using all of a quota.
How it works
- advanced-ratelimit uses named quotas for requests, and token-based-ratelimit uses total token counts over a duration.
- llm-cost works out the cost of a call from a price table, and llm-cost-based-ratelimit enforces a budget on it.
- AMS appends llm-cost after the cost limiter, because response policies run in reverse order and cost must be computed first.
- Counters are kept in memory by default, so with more than one replica the limits apply per replica. Redis can be used instead.
Identity and access
Limits are set on the provider or proxy, not on the caller's identity.
Key facts
- Policies
- advanced-ratelimit, token-based-ratelimit, llm-cost-based-ratelimit, llm-cost
- Default backend
- Memory (Redis optional)
- Side
- Data plane (gateway policy)
- Namespace
- gateway