Error codes
What every status code means and what to do about it.
Error shape
All errors return JSON of the form:
json
{
"type": "error",
"error": {
"type": "billing_error",
"code": "insufficient_quota",
"message": "Solde insuffisant : rechargez votre clé sur https://api-ai.app/pricing — Insufficient balance: top up your key at https://api-ai.app/pricing"
}
}Status codes
| Code | error.type | What it means | What to do |
|---|---|---|---|
| 401 | authentication_error | The API key was copied with wrapping quotes or smart quotes. | Remove all quotes and pass the raw mdf-… value. See Authentication for the correct header format. |
| 402 | billing_error | Insufficient balance — the key has no remaining credit. | Do not retry. Top up the existing API-AI key, then send the request again. |
| 403 | permission_denied | The request was refused for this key. | Contact support at admin@minedom-france.fr. |
| 404 | not_found_error | Unknown route or endpoint path. | Check the endpoint path. |
| 429 | rate_limit_error | Too many requests: the rate allowed for this key has been exceeded. | Wait for the time given by the Retry-After header, then retry with your requests spaced out. |
| 500 | api_error | Reserved. The gateway does not currently emit 500 — internal errors surface as 502 / 503 / 504. | If you ever see one, retry with backoff (500ms / 1s / 2s) and report it. |
| 502 | upstream_error | Upstream returned 5xx, often around tool_choice corner cases. | Our shim already retries 2× — if you see this client-side, retry once. |
| 503 | overloaded_error | Upstream capacity is temporarily saturated (“no available accounts”). | Retry with backoff; this is a temporary upstream capacity signal. |
| 504 | timeout_error | Upstream did not produce headers within 120s. | Switch to streaming for long non-stream calls — see /docs/guides/streaming. |
Retry strategy
- 5xx. Exponential backoff: 500ms · 1s · 2s. Stop after three attempts.
- 402 — Insufficient balance. Retrying will not help; top up the existing API-AI key first.
- 504 on a long non-stream request. Enable
stream: trueso the first event arrives before the header timeout.
Last updated: October 2, 2026Found a bug? admin@minedom-france.fr