# Errors and limits

> For the complete documentation index, see [llms.txt](https://inkstudioai.com/developers/llms.txt). Every page has a markdown version: add `.md` to its URL.

Error codes, HTTP status codes, rate limits, and the daily generation limit of the API.

## Error format

Every error is JSON with the HTTP status that matches the code:

```json
{ "error": "No generations left. Buy a plan to keep generating.", "code": "paywall", "pricingUrl": "https://inkstudioai.com/pricing" }
```

Some codes add fields, as the table shows.

## Error codes

| Code | HTTP | Meaning |
| --- | --- | --- |
| `unauthorized` | 401 | No key, an unknown key, or a revoked key. |
| `validation` | 400 | A field is missing, has the wrong type, or is too long. |
| `paywall` | 402 | No active plan and no free generation left. Adds `pricingUrl`. |
| `plan_required` | 403 | A credit pack needs an active plan. Adds `pricingUrl`. |
| `rate_limited` | 429 | Too many requests. Adds `retryAfterSeconds` and sets the `Retry-After` header. |
| `daily_limit` | 429 | The account reached its daily API generation limit. Adds `retryAfterSeconds`. |
| `moderation` | 422 | The content check blocked the prompt. Adds `reason` and `field` when known. |
| `provider` | 502 | The image provider failed. No generation is charged. |
| `timeout` | 504 | The image provider took too long. No generation is charged. |
| `not_found` | 404 | The resource does not exist. |
| `upload` | 500 | `POST /generations`: the image upload failed. No generation is charged. |
| `unknown` | 500 | `POST /generations`: an unexpected error while the design was made. |
| `server_error` | 500 | An unexpected error. |
| `authorization_pending`, `slow_down`, `access_denied`, `expired_token` | 400 | Device login states. See [Authentication](https://inkstudioai.com/developers/authentication.md). |

Streamed generations use other codes in their `error` event. See [Generate tattoo designs](https://inkstudioai.com/developers/generations.md).

## Limits

- Each API key: 60 requests per minute.
- Each account: 50 API generations per UTC day. The count starts again at midnight UTC.
- Device login: `POST /auth/device` 10 requests per minute per IP address, `POST /auth/token` 60 requests per minute per IP address.
- Public gallery: 60 requests per minute per IP address.

## Retry

- On `429`, wait for the number of seconds in `retryAfterSeconds` or the `Retry-After` header.
- On `502` or `504`, you can send the request again. The failed request did not use a generation.
- On `500`, you can send the request again once. A failed image or upload gives the generation back. If the error repeats, stop and report it.
- Do not send `400`, `401`, `402`, `403`, or `422` requests again without a change.
