Developer

Errors

What each error means and what to do about it.

Errors use standard HTTP status codes and a JSON body with a stable code and a readable message. When a chat, search, or billing request body fails validation, the error adds a details list that points at the fields to fix.

Error body
{
  "error": {
    "code": "insufficient_scope",
    "message": "API key is missing required scope: kb:search"
  }
}

Error codes

StatusCodeMeaningWhat to do
400invalid_requestThe request is malformed or breaks a limit.Read the message and any details, fix the request, and send it again.
401missing_api_keyNo bearer token was sent.Add the Authorization header.
402payment_requiredThe balance is empty or cannot cover max_tokens.Add funds, or lower max_tokens.
403insufficient_scopeThe key lacks a scope or knowledge scope the request needs.Create a key with that scope.
403invalid_api_keyThe key is malformed, unknown, revoked, or expired.Check the key or create a new one.
413request_too_largeThe upload is larger than the limit.Split the document or compress it.
429rate_limitedThe key reached its per minute limit or monthly token cap.Wait and retry with exponential backoff.
500server_errorSomething failed on our side.Retry with backoff.
502billing_provider_errorA checkout session could not be created.Retry in a moment.
502model_errorThe model service returned an error or could not be reached.Retry with backoff.
503billing_not_configuredPurchases are not available in this environment.Use the environment where billing is set up.
503retrieval_unavailableRetrieval could not run.Retry, or set citations.required to false to answer without sources.
504model_timeoutThe model took too long to answer.Retry, or lower max_tokens.

Retrying

Retry 429, 500, 502, 503, and 504 with exponential backoff and a little jitter. Do not retry 400, 401, 402, or 403 without changing the request, the key, or the balance.