Skip to main content
Documentation

Documentation menu

Errors

The error body, every HTTP status and code the gateway returns, which are safe to retry and the headers that help.

Last updated 2026-11-04

Errors use the OpenAI error shape on every endpoint except /v1/messages (see below):

json
{
  "error": {
    "message": "Insufficient wallet balance for this request. Top up your wallet and retry.",
    "type": "insufficient_quota",
    "code": "insufficient_balance",
    "param": null
  }
}
  • code is the stable machine-readable value. Branch on code (and the HTTP status), not on message.
  • type is the OpenAI-compatible category.
  • param names the offending field when there is one, otherwise null.
  • Messages are fixed text. They never contain internal ids, stack traces or any part of your request.
  • Every response, success or error, has an x-request-id header. Quote it to support.
  • When a retry makes sense later, a Retry-After header gives the number of seconds to wait.

Codes

HTTPcodetypeWhen
400invalid_requestinvalid_request_errorThe body failed validation, is not valid JSON or UTF-8, the content type is not JSON, n is not 1, or the request cannot fit the context window. param names the field when known.
400context_length_exceededinvalid_request_errorThe input plus max_tokens exceeds the model's context window.
401invalid_api_keyauthentication_errorMissing, malformed, unknown, revoked or expired key.
402insufficient_balanceinsufficient_quotaThe wallet cannot cover the hold for this request. The provider is never called and nothing is charged.
403model_not_allowedpermission_errorThe key is restricted to other models.
403ip_not_allowedpermission_errorThe key has an IP allowlist and your address is not on it.
403org_suspendedpermission_errorThe organization is suspended.
403org_blockedpermission_errorThe organization has outstanding unpaid usage above the allowed limit. Top-ups do not clear it automatically: contact support with the request id.
404model_not_foundinvalid_request_errorThe model does not exist or is not available.
404not_foundinvalid_request_errorUnknown endpoint.
405method_not_allowedinvalid_request_errorWrong HTTP method for the endpoint.
408client_stalledapi_errorThe client stopped reading a stream (reported inside the stream).
409idempotency_conflictinvalid_request_errorThe Idempotency-Key was used with a different request.
409idempotency_in_progressinvalid_request_errorA request with this key is still running.
409idempotency_replay_unavailableinvalid_request_errorThe request with this key already completed, but its response can no longer be replayed.
413request_too_largeinvalid_request_errorThe body is larger than 2 MiB.
429rate_limitedrate_limit_errorPer-key or per-organization rate limit, too many concurrent requests, or too many failed authentication attempts. Has Retry-After.
429key_cap_exceededrate_limit_errorThe key reached its monthly spending cap. Has Retry-After (seconds until the next month).
499client_closed_requestapi_errorThe client closed the request.
500internal_errorapi_errorAn unexpected gateway error.
502upstream_errorapi_errorThe model provider failed. The hold is released and you are not charged (before output started).
503gateway_disabledapi_errorThe API is temporarily switched off by the operator. Has Retry-After: 30.
503no_upstreamapi_errorNo provider is available for this model.
503model_unavailableapi_errorThe model is temporarily unavailable.
503service_unavailableapi_errorThe service is shutting down or briefly unable to complete the request. Retry shortly.
504upstream_timeoutapi_errorThe provider timed out (non-streaming requests time out after 120 seconds). You are not charged.

403 org_blocked and 402 insufficient_balance are different. insufficient_balance means the wallet is too low for this request, so top up and retry. org_blocked means the organization has accumulated unpaid usage above a limit and needs a person to look at it.

/v1/messages error bodies

POST /v1/messages returns the Anthropic envelope, which has no code field. Use the HTTP status from the table above. See Messages for the error.type mapping.

json
{
  "type": "error",
  "error": { "type": "rate_limit_error", "message": "Rate limit exceeded." },
  "request_id": "req_0123456789abcdef"
}

Errors inside a stream

If a stream fails after the 200 was sent, the error arrives as the last event, as described in Streaming.

What to retry

StatusRetry?
400, 401, 402, 403, 404, 405, 413No. Fix the request, key, balance or permissions first.
409Not as is. See Idempotency.
429Yes, after the Retry-After interval. A key_cap_exceeded means waiting for the next month or raising the cap.
500, 502, 503, 504Yes, with exponential backoff and jitter.

More in Best practices.

bash
curl -sS https://api.ticonai.com/v1/chat/completions \
  -H "Authorization: Bearer $AIP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "model": "no-such-model", "messages": [{ "role": "user", "content": "hi" }] }'