API reference

Errors

The error body

A failed request returns an HTTP status and a JSON body in one shape. type names the kind of failure and stays the same between releases, so branch on it. message is for people and may change. request_id matches the request-id header; send it to support when you ask about a request.

JSON
{
  "error": {
    "type": "invalid_request",
    "message": "messages must hold at least one message."
  },
  "request_id": "req_01"
}

A request that fails before a stream begins returns this body with an ordinary status. A failure after the stream has begun arrives as an error event with the same body.

Statuses

Status Type Cause Fix
400 invalid_request The body is not valid JSON, a field is missing, or a value has the wrong type. Read message, correct the body and send it again.
401 authentication_error The key is missing, mistyped or revoked. Look at the Authorization header and the key on the Keys page. Make a new key if it was revoked.
403 permission_error The key is valid but not allowed to do this, such as reading another account's file. Use a key from the account that owns the resource.
404 not_found The path, or the id of a model, file, batch or session, does not exist. Look at the id and the path. List files, sessions or models to find the right one.
413 request_too_large The request is larger than the endpoint accepts. Send less text or fewer files. Count tokens first to see the size.
429 rate_limit_error The key or the account has used its allowance for now. Retry after the time in the retry-after header. See rate limits.
500 api_error Something went wrong on Antarya's side. Retry after a short wait. If it keeps failing, send the request_id to support.
503 overloaded Antarya is busy and cannot take the request now. The message reads "Antarya is busy. Try again in a moment." Retry after a short wait, a little longer each time.

Retrying

Retry 429, 500 and 503. Wait for retry-after when the reply has it, and wait a little longer after each further failure. Do not retry 400, 401, 403, 404 or 413: the same request fails the same way. The Python and TypeScript SDKs retry these statuses for you.

Next steps