Loading
Loading
All errors use the OpenAI format, so the official SDKs parse them for you. Anthropic and Google errors are mapped to the same envelope, with the provider’s status preserved.
The error body is error with the fields message, type, code and param. Rely on code: the message text may change.
{ "error": { "message": "Insufficient balance: 1.20 RUB available, about 3.50 RUB required for this request. ...", "type": "billing_error", "code": "insufficient_funds", "param": null }}
import openai try: client.chat.completions.create(model="mistralai/mistral-nemo", messages=[...])except openai.APIStatusError as error: print(error.status_code, error.code) # e.g.: 402 insufficient_funds
| HTTP | Code | What to do |
|---|---|---|
| 400 | invalid_request | The body failed validation; the field is in error.param. The body limit is 1 MB. |
| 400 | content_policy_violation | The request was refused by moderation; categories are in error.message. Change the content. Details. |
| 401 | missing_api_key | No Authorization: Bearer sk-max-… header. |
| 401 | invalid_api_key | No such key. Check that you copied all of it. |
| 402 | insufficient_funds | Not enough credits to hold for the request. Add credits. |
| 402 | key_limit_reached | The key hit its monthly spend limit. Raise the limit in the dashboard. |
| 403 | api_key_disabled | The key is disabled, revoked or expired. Enable it or issue a new one in the dashboard. |
| 403 | model_not_allowed | This key isn’t allowed to use this model. Change the model or the key’s model list. |
| 403 | account_suspended | The account is suspended. Contact . |
| 403 | account_under_review | API access is paused while we review compliance with the rules. Contact . |
| 403 | end_user_suspended | The end user (the user field) is suspended for a period after repeated violations; the period is in error.message. Other users keep working. |
| 403 | end_user_blocked | The model provider blocked this end user for a policy violation. Their requests are refused; other users keep working. |
| 404 | model_not_found | No such id in the catalog, the model is disabled or it has no working route. Take the id from GET /v1/models. |
| 404 | unknown_endpoint | No such method. . |
| 429 | rate_limited | Too many requests per minute from the key, or a 429 from the provider. Wait as many seconds as Retry-After says. |
| 500 | internal_error | Something failed on our side. Retry; if it keeps happening, contact support with the x-maxai-request-id. |
| 502 | upstream_error | The provider didn’t respond or returned an error. Retry or pick another model. |
| 502 | upstream_auth_failed | A problem on our side with our key at the provider. Try again later. |
| 503 | upstream_unavailable | The provider is temporarily unavailable. Try again later or pick another model. |
| 503 | service_unavailable | The API is overloaded or temporarily unavailable. Try again later. |
| 503 | moderation_unavailable | The image prompt can’t be checked right now. Retry in a few seconds. |
Retry-After. Retrying other 4xx errors is pointless: fix the request.Contact with the x-maxai-request-id from the response, the error code and the time of the request. No need to send prompt texts: we don’t store them.