Σφάλματα
Every error response has the same shape:
{ "error": { "code": "validation_failed", "message": "limit must be between 1 and 100" } }
codeis stable. Branch on it in your code.messageis an English explanation for people. It can change at any time, so don’t parse it.detailsis an object that some errors add, such as the ID of an existing file on a name conflict or the period end when a spending limit is reached. The API reference says which.
Common codes
| Status | Code | Meaning |
|---|---|---|
| 400 | invalid_query |
A query parameter is malformed. |
| 400 | invalid_body |
The body is missing, isn’t JSON or doesn’t match the schema. |
| 401 | unauthenticated |
The API key is missing, mistyped, expired or revoked. |
| 402 | usage_limit_reached |
The organisation or the service identity used up its AI credits. |
| 402 | billing_restricted |
The organisation’s subscription is unpaid. |
| 403 | insufficient_scope |
The key lacks the scope, or the operation can’t be used with a key at all. |
| 403 | forbidden |
The space role isn’t enough, for example a viewer uploading. |
| 404 | not_found |
The resource doesn’t exist, or the caller can’t see it. |
| 409 | conflict |
The request conflicts with the current state. |
| 412 | precondition_failed |
An If-Match header doesn’t match the current revision. |
| 422 | validation_failed |
A field or parameter has an invalid value. The message names it. |
| 429 | rate_limited |
Too many requests with this key. See Rate limits. |
| 500 | internal |
Something went wrong on Ivy’s side; the message has no details. |
| 503 | agent_unavailable |
The assistant isn’t available right now. |
| 503 | sandbox_unavailable |
Code runs aren’t available on this installation. |
| 503 | storage_unavailable |
File storage isn’t available right now. |
invalid_body can also come with 415 (no JSON content type) or 422 (valid JSON, wrong types).
usage_limit_reached has details with scope_type (whose limit was reached, for example service_identity for the identity’s own budget), period_end and can_raise_limit.
Many operations have more specific codes, such as name_taken (409) when a file of that name exists, run_in_progress (409) while an earlier run is still going, or invalid_model (422) when sending a message. The API reference lists the codes of each operation, taken from the API’s typed responses, so they always match what the API returns.
Errors in a stream
Once a stream has started, the HTTP status is already 200. Errors after that arrive as an error event with the same code and message fields, and the stream ends. A cancelled run ends with the code cancelled. See Event streams.
When to retry
429: wait for the number of seconds in theRetry-Afterheader, if there is one, then retry.503: retry with exponential backoff.500: retry reads. Retry writes only when repeating them is safe: sending a message with the sameclient_message_id, or starting a run with the sameclient_run_id, is. See Idempotency.- Any other
4xx: fix the request first; repeating it gives the same answer.