Skip to main content
Every error has the same JSON shape, with a stable machine-readable code:

Error codes

A request with a wrong HTTP method keeps its 405 status and uses the INVALID_REQUEST code. Invalid requests (400 and 413) are rejected before any inference runs, and don’t count toward quotas.

Retrying

  • Retry 502, 503, 504 and connection errors with exponential backoff and jitter. Honor Retry-After when present. Keep retries few: the API already retries its model backend.
  • For 429 RATE_LIMITED, wait for the number of seconds in Retry-After before sending more requests.
  • Don’t retry 400, 401, 404, 413 or 429 QUOTA_EXCEEDED automatically: the same request will fail again.
  • 500 INTERNAL_ERROR is not retried by the SDK. If it persists, contact support with the request id.
See Production best practices.

Errors in the Python SDK

The Python SDK raises one exception class per code, and retries 502, 503 and 504 once by default: All of them inherit from krun.APIError and krun.KrunError, and carry error_code, status_code, message and request_id. See Python SDK errors.