API & SDK

Handle errors and usage limits

Respond correctly to authentication, validation, network, and rate-limit errors.

Updated August 3, 2026 Β· 9 min

Distinguish responses

  • 401: missing or invalid API key.
  • 403: forbidden resource or network.
  • 404: agent or conversation not found.
  • 422: invalid body, parameter, or identifier.
  • 429: request limit exceeded.

SDKs expose typed errors with API status and detail.

Handle limits and retries

For 429, wait for Retry-After and enforce client-side limits. Retry transient, idempotent operations with backoff. Do not automatically retry a started stream or response creation when acceptance is uncertain. Use Idempotency-Key where supported.

Log HTTP status, error code, and an internal operation ID, excluding keys, sensitive content, and unnecessary personal data.