> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wardin.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Rate Limits

> Per-key RPM and TPM limits enforced atomically in Redis.

Rate limits cap requests per minute (RPM) and tokens per minute (TPM) per virtual key. Like budgets, they are enforced atomically in Redis before the request reaches a provider.

## Limit types

| Limit | Unit                | Resets                         |
| ----- | ------------------- | ------------------------------ |
| RPM   | Requests per minute | Every 60-second rolling window |
| TPM   | Tokens per minute   | Every 60-second rolling window |

Both limits use Redis atomic counters with a 60-second TTL. The check and increment happen in a single Lua script — no race condition across replicas.

## When limits are hit

```json theme={null}
{
  "error": {
    "type": "rate_limit_exceeded",
    "message": "Rate limit exceeded: 60 requests per minute.",
    "retry_after": 23,
    "code": 429
  }
}
```

`retry_after` is the number of seconds until the current window resets.

## Setting limits

### Dashboard

**Console → Keys & Limits** — edit the key and set RPM/TPM in the Rate limits section.

### REST API

```bash theme={null}
curl -X PATCH https://api.wardin.ai/v1/keys/key_01j... \
  -H "Authorization: Bearer wardin_sk_ADMIN_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "rpmLimit": 60,
    "tpmLimit": 100000
  }'
```

Set either field to `null` to remove that limit.

## User-level limits

In addition to per-key limits, you can set limits on a **user** account that cap their total usage across all keys they own. Configure the per-user caps in **Console → Keys & Limits**.

## Recommended limits by use case

| Use case               | Suggested RPM          | Suggested TPM |
| ---------------------- | ---------------------- | ------------- |
| Interactive developer  | 60                     | 200,000       |
| CI / automation        | 20                     | 500,000       |
| Production application | null (use budget only) | null          |

For production applications, monthly budget is usually the right control; RPM/TPM are better suited for preventing runaway loops.
