Skip to main content

Rate limits

Rate limits cap how fast a caller can send traffic. You can set a tokens-per-minute limit (tpm_limit) and a requests-per-minute limit (rpm_limit) on a key, an internal user, a team, an agent, or a customer, a cap on concurrent requests (max_parallel_requests) on a key, and per-model limits (model_tpm_limit, model_rpm_limit) on keys and teams. To cap spend in dollars instead, see Budgets. Dynamic rate limits share a model's capacity across keys and teams, Input and output token rate limits cap input and output tokens separately on a deployment, and Rate limit tiers assign reusable limits to keys.

Set rate limits​

Rate limits apply to any key, user, or team that has tpm_limit or rpm_limit set, and to any key with max_parallel_requests, regardless of role. The master key has no limits unless you configure them, so test with a virtual key that carries explicit limits.

TPM Rate Limit Type (Input/Output/Total)​

By default, TPM (tokens per minute) rate limits count total tokens (input + output). You can configure this to count only input tokens or only output tokens instead.

Set token_rate_limit_type in your config.yaml:

general_settings:
master_key: os.environ/LITELLM_MASTER_KEY
token_rate_limit_type: "output" # Options: "input", "output", "total" (default)
ValueDescription
totalCount total tokens (prompt + completion). Default behavior.
inputCount only prompt/input tokens
outputCount only completion/output tokens

This setting applies globally to all TPM rate limit checks (keys, users, teams, etc.).

Estimated Output Tokens (requests without max_tokens)​

TPM limits are enforced by reserving tokens before the call and reconciling against real usage after it. When a request omits max_tokens / max_completion_tokens, LiteLLM has to guess how many output tokens to reserve, and the built-in guess is a single static estimate shared by every key, team and model.

That guess is wrong in both directions. If your model really emits more than the estimate, concurrent requests are all admitted against an under-reservation and the window overruns the limit once they finish. If it emits far less, the over-reservation blocks requests the budget could have served.

Declare what your models actually emit with default_estimated_output_tokens (one value) and default_estimated_output_tokens_per_model (a map of model name to value). Both are settable on a key and on a team.

curl --location 'http://0.0.0.0:4000/key/generate' \
--header "Authorization: Bearer $LITELLM_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"team_id": "my-prod-team",
"tpm_limit": 1000000,
"default_estimated_output_tokens": 2048,
"default_estimated_output_tokens_per_model": {
"gpt-6.1-sol": 4096,
"gpt-6-luna": 1024
}
}'

The same two fields work on /team/new and /team/update, and both are editable from the Admin UI on the key and team settings pages.

curl --location 'http://0.0.0.0:4000/team/update' \
--header "Authorization: Bearer $LITELLM_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"team_id": "my-prod-team",
"default_estimated_output_tokens": 4096,
"default_estimated_output_tokens_per_model": {"gpt-6.1-sol": 8192}
}'

Resolution order for the reserved output budget, first match wins:

PrioritySource
1Request max_tokens or max_completion_tokens
2Key default_estimated_output_tokens_per_model[model]
3Key default_estimated_output_tokens
4Team default_estimated_output_tokens_per_model[model]
5Team default_estimated_output_tokens
6Built-in static estimate

Values must be positive integers, and the management endpoints reject anything else with a 422 naming the offending field. A value that is missing, or malformed because it was written straight into metadata rather than through these fields, falls through to the next tier, so a key that declares nothing behaves exactly as it does today. Embedding requests are unaffected since they produce no output tokens.

tip

Size the estimate from your observed output distribution for that model, around the p95, not from its maximum context. Declaring more than the model emits throttles traffic the budget could have served: if the declared value plus the input estimate exceeds the limit the request is charged against, every such request is refused, and the proxy logs the reservation and the limit at debug level so you can see why. Declaring less than the model emits is worse than declaring nothing, because the reservation is then smaller than the built-in estimate and more concurrent requests are admitted before the real usage lands.

note

The proxy already hard-caps generation for tenants whose smallest applicable TPM limit is under 4096, by injecting a max_tokens of a quarter of that limit. A declaration larger than that cap raises it, so you are never truncated below what you said your model emits. A declaration smaller than it is ignored, because an estimate describes the typical response and must not silently truncate the long tail.

Use /team/new or /team/update to persist rate limits across multiple keys for a team.

curl --location 'http://0.0.0.0:4000/team/new' \
--header "Authorization: Bearer $LITELLM_API_KEY" \
--header 'Content-Type: application/json' \
--data '{"team_id": "my-prod-team", "tpm_limit": 20, "rpm_limit": 4}'

See the API reference

Rate limits for video generation​

Veo is priced per second of generated video, not per token, so RPM is the limit that applies to it. Creating a video, editing a video, each status check and downloading the content on the /v1/videos routes each count as one request against the key's and the team's rpm_limit. A client that polls for status every few seconds uses many more requests than the number of videos it creates, so set rpm_limit for the polling rate as well as for new videos.

A tpm_limit does not block video calls, because they report 0 tokens. Spend goes on the generation request at the model's per-second price. For example, a 4 second vertex_ai/veo-3.1-lite-generate-001 video adds $0.20 to the key, and status checks add $0. An edit is charged on the edit request for the length of the video it returns.

When a video call goes over an RPM limit, the proxy returns a 429 with a retry-after header and a message that names the limit it hit:

{
"error": {
"message": "Rate limit exceeded for api_key: <hashed key>. Limit type: requests. Current limit: 3, Remaining: 0. Limit resets at: 2026-11-30 17:03:52 UTC",
"type": "throttling_error",
"param": null,
"code": "429"
}
}

When the team's limit is the one hit, the message starts with Rate limit exceeded for team: <team_id>.

Multi-instance rate limiting​

Across several proxy instances, the tpm, rpm, and max_parallel_requests counters are shared through Redis, so every instance enforces the same limit. Point every instance at the same Redis with general_settings.coordination_redis or the REDIS_* environment variables. See Hard rate limit enforcement for what happens while Redis is unreachable.

Hard rate limit enforcement (fail closed)​

Across several instances, the tpm, rpm, and max_parallel_requests counters live in Redis (general_settings.coordination_redis or the REDIS_* environment variables) so every instance enforces the same limit. While Redis is unreachable, each instance falls back to counters in its own memory and keeps serving, so a key with rpm_limit: 2 is admitted up to 2 requests per instance, N times the limit across N instances, until Redis is back.

For deployments where a configured rate limit must be a hard ceiling even while Redis is down, set fail_closed_rate_limit_enforcement:

general_settings:
fail_closed_rate_limit_enforcement: true

With it enabled, a request whose counters cannot be verified against Redis is rejected with a 503 instead of being admitted against a per-instance counter. It is a 503 rather than a 429 so clients and load balancers can tell a Redis outage from a rate limit. The setting changes nothing while Redis answers, requests that carry no rate limit are unaffected, and post-request accounting stays best effort, so a request that was already admitted is never failed after the fact.

Leave the setting off (the default) to keep serving through a Redis outage on per-instance limits. Without Redis the setting has no effect: a proxy that starts with it on and no Redis configured logs a warning and keeps enforcing limits per instance. The legacy limiter selected by LEGACY_MULTI_INSTANCE_RATE_LIMITING=true ignores the setting as well.