Errors

What a failed call returns in the model API and the management API, and every error code AI uses.

In the model API

Chat and model calls answer failures in OpenAI’s shape, so OpenAI’s SDKs raise them as errors with the message and code:

{
  "error": {
    "message": "The project has used the 100000 AI units its plan allows this month.",
    "type": "unit_limit_reached",
    "code": "unit_limit_reached",
    "param": null
  },
  "requestId": "01m3c081dbf3j55x7hsa7wc1yj"
}
  • code is the contract. Branch on it. type holds the same code.
  • param names the field at fault, when there is one. The message lists every field that is wrong.
  • message is a sentence for a person and may be reworded at any time.
  • When a failure is worth trying again, the answer has a Retry-After header with the seconds to wait.

In the management API

Usage and limits calls answer failures with a problem document, like every other Digitospace API. See Problems.

{
  "type": "https://docs.digitospace.com/problems/validation-failed",
  "title": "Validation failed",
  "status": 422,
  "code": "validation_failed",
  "detail": "1 field(s) are invalid",
  "instance": "/v1/projects/01k5ztq3jb9y2a1m9v2xw8e0ha/limits",
  "requestId": "01m3c081dbf3j55x7hsa7wc1yj",
  "retryable": false,
  "issues": [
    {
      "field": "unitsPerMonth",
      "code": "out_of_range",
      "message": "Use a whole number from 0 to 1,000,000,000,000, or null to use the plan's"
    }
  ]
}

Codes

CodeStatusRetryableWhen
already_exists409noSomething with that identity already exists
answer_cut_off400noThe answer reached its token limit before its JSON finished; allow more output tokens
answer_invalid502yesThe model did not answer with JSON that matches the schema; the answer still counts toward your AI units
challenge_failed403yesA web page’s challenge was wrong, used, or expired; ask for a new one
conflict409noThe request clashes with the current state
context_too_long422noThe messages and max_tokens do not fit in the model’s context
forbidden403noThe key or your access does not allow this in the project
internal500noSomething went wrong on our side
invalid_request400noThe request is malformed, such as a field we do not recognise or a bad range
key_limit_reached403noThe web key used its AI units for the day or month
key_not_found401noThe web key does not exist or was revoked
method_not_allowed405noThe route exists but not for that method; see Allow
model_not_found404noThere is no model with that name
model_unavailable503yesThe model, and every one of its fallbacks, cannot answer right now, or it stopped partway through a stream
not_found404noThe route does not exist
origin_not_allowed403noThe web key does not work from the page’s address
payload_too_large413noThe body is over 8 MB for a chat call, or 1 MB for a management call
prompt_exists409noThe project already has a prompt with that name; save a new version of it instead
prompt_in_use409noA task uses the prompt; change or delete the task first
prompt_limit_reached403noThe project already holds 100 prompts; delete one first
prompt_not_found404noThe project has no prompt with that name, or no such version of it
rate_limited429yesThe project sent more requests or tokens this minute than its plan allows; see Retry-After
session_expired401yesA web page’s visit expired; start a new one
task_disabled403noThe task is turned off; turn it on in the console
task_exists409noThe project already has a task with that name
task_limit_reached403noThe project already holds 100 tasks; delete one first
task_not_allowed403noThe web key may not run that task
task_not_found404noThe project has no task with that name
tokens_over_limit403noOne call asks for more tokens than the plan allows in a whole minute
too_many_sessions429yesToo many new visits came from one network this hour; see Retry-After
unauthenticated401noThe bearer token is missing or not one we accept
unavailable503yesSomething the request depends on is not available right now
unit_limit_reached403noThe call could go over the AI units the project may use this month
unsupported_media_type415noThe body is not application/json
validation_failed422noFields are wrong; the message or issues says which
visitor_limit_reached429yesOne visitor used their requests a minute or AI units a day; see Retry-After
web_key_limit_reached403noThe project already holds 20 web keys; revoke one first
web_key_not_found404noThe project has no web key with that ID

Last updated