NovitàCorsia Eco ora su 91 modelli: lo stesso modello a un prezzo più basso

Valuta

Ricarichi sempre in euro. Le altre valute sono indicate al tasso BCE del giorno. Tassi di riferimento BCE

AccediInizia

Documentazionev1

Menu della documentazioneErrors

Errors

Every error the Nexrouting API returns: HTTP status, code, what it means and what to do, plus the error shapes and when to retry.

La documentazione è in inglese.

Errors come back as JSON with an HTTP status. All endpoints except /v1/messages use the OpenAI shape:

OpenAI shape
{  "error": {    "message": "Insufficient credits. Add credits in your Nexrouting dashboard and try again.",    "type": "insufficient_credits",    "param": null,    "code": "insufficient_credits"  }}

/v1/messages uses the Anthropic shape, which has no code. Use the HTTP status and error.type there:

Anthropic shape
{  "type": "error",  "error": {    "type": "billing_error",    "message": "Insufficient credits. Add credits in your Nexrouting dashboard and try again."  }}

Every response, errors included, has an x-request-id header; the only exception is a 405 for a wrong HTTP method. Send the ID to support when you report a problem.

Error codes

StatusCodeMeaningWhat to do
400invalid_jsonThe body is not valid JSON.Fix the body.
400invalid_bodyThe body is JSON, but not an object.Send a JSON object.
400missing_modelThere is no model in the body.Add a model ID.
400unsupported_endpointThe model doesn't support this endpoint. The message lists the endpoints it does support.Use one of those, or another model.
400, 422invalid_requestThe model provider rejected the request, for example a parameter the model doesn't accept. The message says why; param names the field when known.Change the request. Sending it again unchanged fails again.
401missing_api_keyNo key in Authorization or x-api-key.Send Authorization: Bearer <key>.
401invalid_api_keyThe key is unknown or revoked.Check the key, or create a new one.
401api_key_expiredThe key is past its expiry date.Create a new key, or change the date.
402insufficient_creditsYour balance is zero or below, or too low for this prompt.Add credits.
402key_budget_exceededThe key has spent its budget.Raise the budget, or use another key.
403account_suspendedYour organization is suspended.Contact support.
403model_not_allowedThe key may not use this model.Add the model to the key, or use another key.
404model_not_foundThe model doesn't exist or is not available right now. The message suggests alternatives.Check GET /v1/models.
404not_foundUnknown endpoint.Check the path.
405–Wrong HTTP method for this endpoint, such as GET on /v1/chat/completions. This response has an empty body and no x-request-id.Use the method from the API reference.
413request_too_largeThe body is larger than 32 MB, or the model rejected the request as too large.Send less, or split the request.
429rate_limit_exceededToo many requests per minute for this key, or the model is busy on every route.Wait the number of seconds in retry-after, then retry.
500internal_errorSomething went wrong on our side.Retry with backoff. If it keeps happening, contact support with the request ID.
503model_unavailableNo route for this model could answer.Retry after a short wait, or use another model or lane.
200 (in a stream)stream_interruptedThe connection to the model was lost during a stream.Retry the request.

In Usage you may also see status 499: the connection was closed before the answer was complete.

Error types

The type follows the HTTP status:

StatusOpenAI error.typeAnthropic error.type
400invalid_request_errorinvalid_request_error
401authentication_errorauthentication_error
402insufficient_creditsbilling_error
403permission_errorpermission_error
404invalid_request_errornot_found_error
413invalid_request_errorrequest_too_large
422invalid_request_errorinvalid_request_error
429rate_limit_errorrate_limit_error
500server_errorapi_error
503server_erroroverloaded_error

When to retry

Retry 429, 500, 503 and an interrupted stream, with exponential backoff (for example 1, 2 and 4 seconds), and honour retry-after when it is there. The OpenAI and Anthropic SDKs already retry 429 and 5xx responses a couple of times.

Don't retry 400, 401, 402, 403, 404 or 413 without changing something: the same request fails the same way. Before it returns 503, the gateway has already tried every route it has for the model, so wait a moment before you retry.

Python
import openai try:    reply = client.chat.completions.create(        model="openai/gpt-6-astra",        messages=[{"role": "user", "content": "Hello"}],    )except openai.RateLimitError as e:    print("Slow down, retry after", e.response.headers.get("retry-after"), "s")except openai.APIStatusError as e:    print(e.status_code, e.response.headers.get("x-request-id"), e.message)