Skip to content
Appmake
Kalle API docs

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

JSON
{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "max_tokens is required."
  },
  "request_id": "req_01J8Z8"
}
FieldDescription
error.typeA stable, machine-readable type. Use it in your code.
error.messageA human-readable explanation. It can change, so do not match on it.
request_idThe ID of the request. It is also in the request-id header. Include it when you contact support.

Status codes

StatusError typeWhat it meansWhat to do
400invalid_request_errorThe request is malformed or a field is wrong.Fix the request. The message names the field.
401authentication_errorThe API key is missing, wrong or deleted.Check the Authorization header and the key.
402billing_errorThe workspace has no balance left.Top up the balance in the Appmake console.
403permission_errorThe key may not use this model or feature.Use another key or ask a workspace admin.
404not_found_errorThe endpoint or the object does not exist.Check the URL and the ID.
413request_too_largeThe request body is too big.Send fewer or smaller files, or a shorter history.
429rate_limit_errorYou hit a rate limit.Wait for retry-after. See Rate limits.
500api_errorSomething went wrong on our side.Try again with backoff.
503overloaded_errorKalle is busy for a moment.Try again with backoff, or use another model.

Which errors to retry

  • Retry 429, 500 and 503, with exponential backoff and a cap on the number of attempts.
  • Do not retry 400, 401, 402, 403, 404 and 413. 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.