Errors
When a request fails, Kalle answers with an HTTP status code and a JSON error that says what went wrong. Read the status first: it tells you whether trying again can help.
The error object
{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "max_tokens is required."
},
"request_id": "req_01J8Z8"
}| Field | Description |
|---|---|
error.type | A stable, machine-readable type. Use it in your code. |
error.message | A human-readable explanation. It can change, so do not match on it. |
request_id | The ID of the request. It is also in the request-id header. Include it when you contact support. |
Status codes
| Status | Error type | What it means | What to do |
|---|---|---|---|
400 | invalid_request_error | The request is malformed or a field is wrong. | Fix the request. The message names the field. |
401 | authentication_error | The API key is missing, wrong or deleted. | Check the Authorization header and the key. |
402 | billing_error | The workspace has no balance left. | Top up the balance in the Appmake console. |
403 | permission_error | The key may not use this model or feature. | Use another key or ask a workspace admin. |
404 | not_found_error | The endpoint or the object does not exist. | Check the URL and the ID. |
413 | request_too_large | The request body is too big. | Send fewer or smaller files, or a shorter history. |
429 | rate_limit_error | You hit a rate limit. | Wait for retry-after. See Rate limits. |
500 | api_error | Something went wrong on our side. | Try again with backoff. |
503 | overloaded_error | Kalle is busy for a moment. | Try again with backoff, or use another model. |
Which errors to retry
- Retry
429,500and503, with exponential backoff and a cap on the number of attempts. - Do not retry
400,401,402,403,404and413. The same request will fail again until you change something.
Errors in a stream
When stream is true, errors before the first event come back as a normal response with a status code. Errors after that arrive as an error event with the same error object, and the stream ends. See Streaming.