# Limits and quotas

Limits are per key and reset daily:

| Limit | What it caps |
|---|---|
| `requests_per_day` | number of requests |
| `tokens_per_day` | input + output tokens |
| `spend_per_day_usd` | estimated cost |
| `max_tokens_per_request` | `max_tokens` of one request |
| `max_media_bytes_per_request` | attachment size |
| `max_media_units_per_request` | images/audio pieces per request |
| `max_video_seconds_per_request` | video duration |

What you get when you hit them:

| Code | HTTP | When |
|---|---|---|
| `RATE_LIMIT_REACHED` | 429 | daily requests already used |
| `RATE_LIMIT_WOULD_EXCEED` | 429 | this request would pass the daily limit |
| `MAX_TOKENS_EXCEEDED` | 400 | `max_tokens` over the per-request cap |
| `CONTEXT_TOO_LARGE` | 400 | prompt does not fit the model context |
| `PROVIDER_SATURATED` | 429 | all upstream slots for the model are busy |
| `PROVIDER_QUOTA_EXHAUSTED` | 429 | upstream credentials out of quota today |
| `PROVIDER_TEMPORARILY_UNAVAILABLE` | 429 / 503 | upstream rate limit or transient error |
| `PROVIDER_NOT_RESPONDING` | 503 | no answer in time |

Every `429` includes `retry_after_seconds` and a `Retry-After` header. Wait that
long before retrying: ApiX already rotated credentials internally.
