---
title: "Rate limits"
url: "/docs/proxy/rate_limits"
canonical_url: "https://docs.litellm.ai/docs/proxy/rate_limits"
type: "docs"
last_updated: "2026-12-02"
related:
  - "/docs/proxy/ui_team_soft_budget_alerts"
  - "/docs/proxy/dynamic_rate_limit"
---
# Rate limits

> Index of all LiteLLM docs: https://docs.litellm.ai/llms.txt


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](./budgets.md). [Dynamic rate limits](./dynamic_rate_limit.md) share a model's capacity across keys and teams, [Input and output token rate limits](./io_token_rate_limits.md) cap input and output tokens separately on a deployment, and [Rate limit tiers](./rate_limit_tiers.md) assign reusable limits to keys.

## Set rate limits {#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`:

```yaml
general_settings:
  master_key: os.environ/LITELLM_MASTER_KEY
  token_rate_limit_type: "output"  # Options: "input", "output", "total" (default)
```

| Value | Description |
|-------|-------------|
| `total` | Count total tokens (prompt + completion). **Default behavior.** |
| `input` | Count only prompt/input tokens |
| `output` | Count 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.

```shell
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.

```shell
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:

| Priority | Source |
| --- | --- |
| 1 | Request `max_tokens` or `max_completion_tokens` |
| 2 | Key `default_estimated_output_tokens_per_model[model]` |
| 3 | Key `default_estimated_output_tokens` |
| 4 | Team `default_estimated_output_tokens_per_model[model]` |
| 5 | Team `default_estimated_output_tokens` |
| 6 | Built-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.
:::

**Per Team**

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

```shell
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**](https://docs.litellm.ai/api-reference/#tag/team~20management/new_team_team_new_post)

**Per Team Per Model**

**Set rate limits per model for a team**

Use `model_rpm_limit` and `model_tpm_limit` to set rate limits per model for all keys belonging to a team. These limits apply across all keys in the team and are inherited by keys unless overridden at the key level.

Use `/team/new` or `/team/update` with `model_rpm_limit` and `model_tpm_limit` as dictionaries mapping model names to their limits:

```shell
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",
  "model_rpm_limit": {"gpt-6.1-sol": 100, "gpt-6-luna": 200},
  "model_tpm_limit": {"gpt-6.1-sol": 10000, "gpt-6-luna": 20000}
}'
```

**Update existing team with per-model limits:**

```shell
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",
  "model_rpm_limit": {"gpt-6.1-sol": 100, "gpt-6-luna": 200},
  "model_tpm_limit": {"gpt-6.1-sol": 10000, "gpt-6-luna": 20000}
}'
```

**Alternative: Use metadata**

You can also pass per-model limits via the `metadata` field:

```shell
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",
  "metadata": {
    "model_rpm_limit": {"gpt-6.1-sol": 100, "gpt-6-luna": 200},
    "model_tpm_limit": {"gpt-6.1-sol": 10000, "gpt-6-luna": 20000}
  }
}'
```

**Resolution order:** When a key belongs to a team, rate limits are resolved as: **Key metadata > Key model_max_budget > Team metadata**. Keys can override team-level per-model limits with their own `model_rpm_limit` or `model_tpm_limit`.

#### Per-model rate limits and fallbacks

By default, when a request goes over a key, team, organization, project or customer `model_rpm_limit` / `model_tpm_limit` and `router_settings.fallbacks` has an entry for that model, LiteLLM retries the request on the fallback model. The fallback model is admitted against the caller's own per-model limits for it, and the client gets a 200 from the fallback with `x-litellm-attempted-fallbacks: 1` and `x-litellm-fallback-reason: rate_limit:<scope>`, for example `rate_limit:model_per_end_user` when a customer's per-model limit caused the hop. Limits that are not model-specific, such as a customer's or key's overall `tpm_limit`, still return 429 on every model.

To make per-model key, team, organization and project limits a hard cap that returns 429, set:

```yaml
general_settings:
  disable_fallbacks_on_per_model_rate_limits: true
```

Other local rate limits (for example a key's overall `rpm_limit`) keep their existing fallback behavior.

**Verify:** Make a `/chat/completions` request and check response headers `x-litellm-key-remaining-requests-{model}` and `x-litellm-key-remaining-tokens-{model}` for the model-specific limits.

[**See the API reference**](https://docs.litellm.ai/api-reference/#tag/team~20management/new_team_team_new_post)

**Per Internal User**

Use `/user/new` or `/user/update` to persist rate limits across multiple keys for internal users.

```shell
curl --location 'http://0.0.0.0:4000/user/new' \
--header "Authorization: Bearer $LITELLM_API_KEY" \
--header 'Content-Type: application/json' \
--data '{"user_id": "krrish@berri.ai", "tpm_limit": 20, "rpm_limit": 4}'
```

[**See the API reference**](https://docs.litellm.ai/api-reference/#tag/Internal~20User~20management/new_user_user_new_post)

**Expected Response**

```json
{
    "key": "sk-sA7VDkyhlQ7m8Gt77Mbt3Q",
    "expires": "2024-01-19T01:21:12.816168",
    "user_id": "krrish@berri.ai"
}
```

**Per Key**

Use `/key/generate` if you want them for just that key.

```shell
curl --location 'http://0.0.0.0:4000/key/generate' \
--header "Authorization: Bearer $LITELLM_API_KEY" \
--header 'Content-Type: application/json' \
--data '{"max_parallel_requests": 10, "tpm_limit": 20, "rpm_limit": 4}'
```

**Expected Response**

```json
{
    "key": "sk-ulGNRXWtv7M0lFnnsQk0wQ",
    "expires": "2024-01-18T20:48:44.297973",
    "user_id": "78c2c8fc-c233-43b9-b0c3-eb931da27b84"  // auto-generated
}
```

**Per API Key Per model**

**Set rate limits per model per api key**

Set `model_rpm_limit` and `model_tpm_limit` to set rate limits per model per api key. Here `gpt-6.1-sol` is the `model_name` set on the [litellm config.yaml](configs.md).

```shell
curl --location 'http://0.0.0.0:4000/key/generate' \
--header "Authorization: Bearer $LITELLM_API_KEY" \
--header 'Content-Type: application/json' \
--data '{"model_rpm_limit": {"gpt-6.1-sol": 2}, "model_tpm_limit": {"gpt-6.1-sol": 1000}}'
```

**Expected Response**

```json
{
    "key": "sk-ulGNRXWtv7M0lFnnsQk0wQ",
    "expires": "2024-01-18T20:48:44.297973"
}
```

**Verify the model rate limits on this key**

Make a `/chat/completions` request and check that the `x-litellm-key-remaining-requests-<model>` header comes back.

```shell
curl -i http://localhost:4000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-ulGNRXWtv7M0lFnnsQk0wQ" \
  -d '{
    "model": "gpt-6.1-sol",
    "messages": [
      {"role": "user", "content": "Hello"}
    ]
  }'
```

**Expected headers**

```shell
x-litellm-key-remaining-requests-gpt-6.1-sol: 1
x-litellm-key-remaining-tokens-gpt-6.1-sol: 179
```

These headers show 1 request and 179 tokens remaining on `gpt-6.1-sol` for key `sk-ulGNRXWtv7M0lFnnsQk0wQ`.

**Per Agent**

Set rate limits on agents registered with the [Agent Gateway](../a2a.md).

**Agent-level limits** cap total throughput across all sessions:

```shell
curl -X POST 'http://0.0.0.0:4000/v1/agents' \
--header "Authorization: Bearer $LITELLM_API_KEY" \
--header 'Content-Type: application/json' \
--data '{"agent_name": "my-agent", "agent_card_params": {"name": "my-agent", "description": "My agent", "url": "http://my-agent:8080", "version": "1.0.0"}, "tpm_limit": 100000, "rpm_limit": 100}'
```

**Session-level limits** cap throughput per individual session:

```shell
curl -X POST 'http://0.0.0.0:4000/v1/agents' \
--header "Authorization: Bearer $LITELLM_API_KEY" \
--header 'Content-Type: application/json' \
--data '{"agent_name": "my-agent", "agent_card_params": {"name": "my-agent", "description": "My agent", "url": "http://my-agent:8080", "version": "1.0.0"}, "session_tpm_limit": 50000, "session_rpm_limit": 50}'
```

Update the limits on an existing agent with `PATCH /v1/agents/{agent_id}`:

```shell
curl -X PATCH 'http://localhost:4000/v1/agents/<agent_id>' \
  -H "Authorization: Bearer $LITELLM_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "tpm_limit": 200000,
    "rpm_limit": 200,
    "session_tpm_limit": 50000,
    "session_rpm_limit": 50
  }'
```

To cap the number of calls or the dollar spend in one session, see [agent session budgets](./users.md#agents).

**For customers**

:::info

You can also create the budget in the Admin UI, on the **Budgets** page with **Create Budget**.

:::

Use this to set rate limits for the `user` passed to `/chat/completions`, without needing to create a key for every customer. See [Customers](./customers.md) for how customer identity works.

#### Step 1. Create Budget

Set a `tpm_limit` on the budget (you can also pass `rpm_limit` if needed). Both are optional; a budget with neither set applies no LiteLLM TPM or RPM limit to its customers, and only provider rate limits apply.

```shell
curl --location 'http://0.0.0.0:4000/budget/new' \
--header "Authorization: Bearer $LITELLM_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
    "budget_id" : "free-tier",
    "tpm_limit": 5
}'
```

#### Step 2. Create `Customer` with Budget

We use `budget_id="free-tier"` from Step 1 when creating this new customer.

```shell
curl --location 'http://0.0.0.0:4000/customer/new' \
--header "Authorization: Bearer $LITELLM_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
    "user_id" : "customer-1",
    "budget_id": "free-tier"
}'
```

#### Step 3. Pass `user_id` id in `/chat/completions` requests

Pass the `user_id` from Step 2 as `user="customer-1"`.

```shell
curl --location 'http://localhost:4000/chat/completions' \
    --header "Authorization: Bearer $LITELLM_API_KEY" \
    --header 'Content-Type: application/json' \
    --data '{
    "model": "llama3",
    "user": "customer-1",
    "messages": [
        {
        "role": "user",
        "content": "gm"
        }
    ]
}'
```

### 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:

```json
{
  "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](#hard-rate-limit-enforcement-fail-closed) 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`:

```yaml
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.

## Related pages

- [Team Soft Budget Alerts](https://docs.litellm.ai/docs/proxy/ui_team_soft_budget_alerts.md)
- [Dynamic TPM/RPM Allocation](https://docs.litellm.ai/docs/proxy/dynamic_rate_limit.md)
