Skip to content

API keys are not open yet. These docs describe the API as it will work when keys open, so you can plan your integration now.

Docs

Errors

Errors come back in the OpenAI format, with a status that tells you whether to retry.

Every error has the OpenAI shape, so the official SDKs raise their usual exceptions. Messages never name an upstream provider.

JSON

{
  "error": {
    "message": "The parameter `stop` is not supported.",
    "type": "invalid_request_error",
    "param": "stop",
    "code": "unsupported_parameter"
  }
}

Codes

StatuscodeWhat happenedRetry?
400invalid_request, invalid_jsonThe body is not a valid request. param names the field.No, fix the request.
400invalid_idempotency_key, invalid_date_rangeA malformed Idempotency-Key header, or a bad from/to on /usage.No, fix the request.
400unsupported_parameterA parameter ewpire does not honor, such as stop, seed or n above 1.No, remove it.
400context_length_exceededThe prompt is longer than the model's context.No, shorten it or pick a model with a longer context.
400unsupported_contentImages sent to a model that does not read images.No.
400content_filterThe request was declined by the model's safety filter.No.
401invalid_api_keyThe key is missing, wrong or revoked.No.
404model_not_foundNo model with that id is served through the API.No.
409idempotency_key_in_useA request with the same Idempotency-Key is still running.Yes, later.
413request_too_largeThe body is over 8 MB.No.
422idempotency_key_reusedThe Idempotency-Key was used with a different body.No, use a new key.
429rate_limit_exceededToo many requests per minute for this key.Yes, after Retry-After seconds.
429insufficient_quotaNot enough credits for this request.No, add credits first.
429spend_limit_exceededThe key's daily or monthly spend limit, or your monthly limit in a team, is reached.No, until the limit resets or is raised.
500, 502server_errorSomething failed on our side or upstream.Yes, with backoff.
503model_unavailable, model_overloadedThe model is down or busy right now.Yes, or use "auto".
504timeoutThe model took too long.Yes.

Retrying

The OpenAI SDKs retry 429 and 5xx answers by themselves. Two 429 answers cannot be fixed by waiting – insufficient_quota and spend_limit_exceeded – so they carry the header x-should-retry: false, which tells the SDKs not to retry.

To retry your own requests safely, send an Idempotency-Key header: a repeat of a request that already finished returns the same answer and is not charged twice. See Chat.

A failed request is not charged.