# Errors and retries

Use the status, error code, and response headers together to decide what to do next.

## HTTP status

| Status | What to check |
| --- | --- |
| 400 | Check the request and whether the model supports the requested interface and parameters. |
| 401 | Check the API key and the API URL. |
| 402 | Check your MIA Points balance. |
| 403 | Check key status and access. |
| 404 | Check the endpoint and model ID. |
| 409 | Check whether a request or continuation conflicts with an earlier one. |
| 413 | Reduce the request size, attachments, or conversation history. |
| 429 | Check the error code for a limit or capacity rejection. |
| 502, 503 | The service could not complete the request. Check the retry guidance below. |
| 504 | The request timed out. For long generations, use streaming. |

Error bodies follow the requested API's format. `x-mia-error-code`, when present, identifies the error across API formats. Responses from an intermediary may not include MIA's error body or headers.

## Error codes

When `x-mia-error-code` is present, use it with the HTTP status:

| Code | Status | Next action |
| --- | --- | --- |
| `vk_invalid`, `vk_expired` | 401 | Check the key and create a new one if needed. |
| `vk_disabled` | 403 | Check key status in API Keys. |
| `insufficient_credit` | 402 | Add MIA Points. |
| `quota_exceeded` | 429 | Check the key's Points limits. |
| `rate_limit` | 429 | Check retry headers before trying again. |
| `model_not_found` | 404 | Copy a current model ID from Explore or the model list. |
| `parameter_capability_unavailable` | 400 | The message names the field and why no route can carry it. Change that field or use another interface the model supports. |
| `request_too_large` | 413 | Reduce the request size. |
| `request_conflict` | 409 | Check the request identity and continuation. |
| `supplier_state_not_portable` | 400 | Start a new turn with portable history. |
| `provider_timeout` | 504 | Use streaming for long generations; check retry guidance. |

## Content safety rejections

When a model provider rejects a prompt, input media, or generated result under its content safety policy, the response is a 400 with `x-mia-upstream-error-reason`:

| Reason | Meaning |
| --- | --- |
| `content_real_person` | An input image or video may contain a real person. |
| `content_copyright` | An input or the generated result may be subject to copyright restrictions. |
| `content_counterfeit` | The generated result may contain counterfeit documents or credentials. |
| `content_sensitive` | The request or result did not pass the provider's content safety review. |

`x-mia-upstream-error-code`, when present, is the provider's documented label, for example `InputImageSensitiveContentDetected.PrivacyInformation`; its `Input` or `Output` prefix tells you whether the provider rejected what you sent or what it generated. Repeating the same request does not change the result.

## Retry safely

`x-should-retry: false` means do not automatically retry. `Retry-After`, when present, gives a delay; it does not override a `false` retry instruction. An absent retry header does not establish that a retry is safe.

For paid generation, disable automatic SDK retries. A timeout or lost connection can leave the outcome unknown; do not repeat the request automatically. You can provide an `Idempotency-Key` to identify a request, but it does not make replay safe. An already accepted request cannot be automatically replayed with the same identity.

## Get help

For a persistent problem, [contact MIA](https://mia.ambr.io/contact) with the endpoint, model ID, status, error code, and request ID if available. Do not send your API key or private request content.
