Skip to content
Sign in

API and SDKs

Errors

Every error in the OpenAI, Anthropic and Gemini formats side by side, the body each comes in, and which ones to retry.

On this page

A request that fails is answered with an HTTP status and a body in the shape of the format it was sent in. The causes are the same on every endpoint; each format names them in its own words. What one endpoint refuses in particular is on that endpoint's page, under Errors.

Status codes

Each row is one cause, with the status and the code, type or status name it has in each format. The video endpoints (xAI format) answer as the OpenAI format does.

  • OpenAI · xAI
    400invalid_request
    Anthropic
    400invalid_request_error
    Gemini
    400INVALID_ARGUMENT

    The request is malformed, or asks for something the endpoint refuses. The error's message says what.

    Retry?No

  • OpenAI · xAI
    413context_length_exceeded
    Anthropic
    400invalid_request_error
    Gemini
    400INVALID_ARGUMENT

    The input is longer than the model's context window.

    Retry?No

  • OpenAI · xAI
    400unsupported_client
    Anthropic
    400invalid_request_error
    Gemini
    400FAILED_PRECONDITION

    The client is unsupported or too old for this model. Follow the error's message: update Codex to the latest version, or use the official Claude Code client.

    Retry?No

  • OpenAI · xAI
    401invalid_api_key
    Anthropic
    401authentication_error
    Gemini
    401UNAUTHENTICATED

    The key is missing, mistyped or revoked. Check it in API keys.

    Retry?No

  • OpenAI · xAI
    402insufficient_credits
    Anthropic
    402billing_error
    Gemini
    402FAILED_PRECONDITION

    Plan credits, the available balance or the key's monthly limit can't cover the request's estimated cost. Top up on Billing.

    Retry?After topping up

  • OpenAI · xAI
    404model_not_found
    Anthropic
    404not_found_error
    Gemini
    404NOT_FOUND

    No model has this ID, or the model isn't available right now. See Models.

    Retry?No

  • OpenAI · xAI
    429rate_limit_exceeded
    Anthropic
    429rate_limit_error
    Gemini
    429RESOURCE_EXHAUSTED

    The provider is rate-limiting the model, or the model is busy for more than 5 minutes. Retry after Retry-After.

    Retry?After Retry-After

  • OpenAI · xAI
    500internal_error
    Anthropic
    500api_error
    Gemini
    500INTERNAL

    Impact itself failed. Retry.

    Retry?Yes

  • OpenAI · xAI
    502upstream_error
    Anthropic
    502api_error
    Gemini
    502INTERNAL

    The provider returned an error. Retry.

    Retry?Yes

  • OpenAI · xAI
    503server_is_overloaded
    Anthropic
    529overloaded_error
    Gemini
    503UNAVAILABLE

    Every source of the model is busy for now. Retry after Retry-After, with backoff.

    Retry?After Retry-After

  • OpenAI · xAI
    503upstream_unavailable
    Anthropic
    503overloaded_error
    Gemini
    503UNAVAILABLE

    No source in the key's billing order serves this model.

    Retry?No

  • OpenAI · xAI
    504upstream_timeout
    Anthropic
    504api_error
    Gemini
    504DEADLINE_EXCEEDED

    The provider didn't answer in time, or the request passed the 30-minute limit. Retry.

    Retry?Yes

An address or method the API doesn't serve is a 404 too: with an empty body under /v1, in the Gemini format under /v1beta. A video downloaded before its job is done is a 409: Videos.

A model that declines to answer is usually not an error. The response succeeds, with finish_reason set to content_filter on Chat Completions, stop_reason set to refusal on /v1/messages and finishReason set to SAFETY on generateContent; on /v1/responses a model other than GPT answers with status set to incomplete. A prompt that a provider refuses outright is a 400 invalid_request. So is an image prompt that a model's safety system blocks; a blocked video is a job that ends failed with that code.

When a provider fails a request paid from your plan credits or balance, the message is Impact's own description of the failure. When your own account serves the request (BYOK), you get the provider's message as it was sent.

Error bodies

The status says what kind of failure it is, the body says which one. Tell errors apart by the code in the body; message is written for a person to read.

OpenAI format

The OpenAI-format endpoints and the video endpoints answer with an error object: code is the code in the table, message says what went wrong, type is OpenAI's broader class of error, and request_id is the request's ID.

{  "error": {    "code": "invalid_request",    "message": "n above 1 isn't supported.",    "type": "invalid_request_error",    "request_id": "gen_5b1f0c9e2a7d4e63b8a4c2f1d09e7a35"  }}

Anthropic format

/v1/messages answers with type set to error, an error object holding the type in the table and a message, and request_id beside it.

{  "type": "error",  "error": {    "type": "invalid_request_error",    "message": "messages: Expected at least one message"  },  "request_id": "gen_5b1f0c9e2a7d4e63b8a4c2f1d09e7a35"}

Gemini format

The /v1beta endpoints answer in Google's google.rpc.Status: error.code repeats the HTTP status, error.status is the name in the table. The body has no place for the request's ID: read it from the x-request-id header.

{  "error": {    "code": 400,    "message": "contents must not be empty.",    "status": "INVALID_ARGUMENT"  }}

When it is known when the model will be free, a 429 or 503 says so twice: in the Retry-After header, and as a RetryInfo in error.details, which Google's clients read.

{
  "error": {
    "code": 503,
    "message": "The service is overloaded right now and has no free capacity for this model. Please try again shortly. If this keeps happening, contact Impact support: https://t.me/impact_sup",
    "status": "UNAVAILABLE",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.RetryInfo",
        "retryDelay": "15s"
      }
    ]
  }
}

Retrying

Retry 429 and 5xx with exponential backoff, and wait for Retry-After when the response has it. The official OpenAI and Anthropic SDKs already do; raise maxRetries (max_retries in Python) for more attempts. Google's SDKs retry only when asked: set retryOptions in the client's httpOptions (retry_options in Python), or retry in your own code. The last line of each row of the table says whether the same request can succeed if sent again. A 503 upstream_unavailable is the exception among the 5xx: no source in the key's billing order serves the model, so retrying changes nothing.

A failure after a stream has started arrives inside the stream, as the status is already 200: Errors mid-stream.

Every response and every error carries the request's ID in the x-request-id header. Look it up in Logs, and quote it when you write to support: Request IDs.

When the model is busy

A request to a busy model first waits a short time for it. When every source of a model stays busy, the response says when to retry, in the way each format's clients understand. The free models answer the same way when their capacity is used up for now.

  • OpenAI format. 503 server_is_overloaded with Retry-After. When it stays busy for more than 5 minutes: 429 rate_limit_exceeded with Retry-After.
  • Anthropic format. 529 overloaded_error with retry-after. When it stays busy for more than 5 minutes: 429 rate_limit_error with x-should-retry: false.
  • Gemini format. 503 UNAVAILABLE with a RetryInfo and Retry-After. When it stays busy for more than 5 minutes: 429 RESOURCE_EXHAUSTED.

A model in short supply is shared between the people using it. While others are waiting for it, requests from an account that has had more than an even share of it over the last few minutes are answered with a 429 and a Retry-After of at most a minute: rate_limit_exceeded in the OpenAI format, rate_limit_error in the Anthropic format, RESOURCE_EXHAUSTED with a RetryInfo in the Gemini format. Wait that long before sending again; the model goes to the others meanwhile.

A stream that has already started gets the overload inside it: Errors mid-stream.

Codes in Logs

Logs show each failed request that reached a model with its code from the table, in the OpenAI format's words whatever format the request came in. Three codes mean something else there:

Code in LogsWhat happened
upstream_unavailableAlso every request refused because the model was busy, whichever status it was answered with.
request_interruptedThe request stopped before it finished, usually because the client closed the connection. Logs show it as Cancelled.
request_timeoutThe request passed the 30-minute limit; the client got upstream_timeout: as a 504, or inside the stream if it had started.