Skip to main content
Every error response includes a machine-readable code, a canonical type, and the request_id for support correlation.

Prerequisites

  • An Arbytra API key
  • Python 3.10+ with the OpenAI SDK (pip install openai) or the arbytra SDK (pip install arbytra)
    • OR Node.js 18+ with the OpenAI SDK (npm install openai) or @arbytra/sdk (npm install @arbytra/sdk)

Error types

All Arbytra errors extend ArbytraAPIError. The envelope is canonical (see Errors): The SDK provides these typed exception classes:
Dispatch on type + HTTP status for exception class, then on code for precise handling within a class. Never branch on message text; see Errors for retry policy by code.
See the Python SDK Reference or TypeScript SDK Reference for complete error class fields and hierarchy.

Handle errors

Catch typed exceptions:

Use built-in retries

The SDK automatically retries transient errors with exponential backoff:
When the server returns a Retry-After header (common with 429 responses), the SDK uses that value instead of the calculated backoff interval.

Retry manually

For request-level control over backoff or error filtering, implement custom retry logic:

Retry asynchronously

Retry with async/await:
TypeScript is inherently async. See the TypeScript tabs in Retry manually.
Side effects and retries: When using tools or multi-step workflows, consider whether retries are safe. A retried request that triggers a tool call may execute the tool twice. For idempotency-sensitive operations, either disable automatic retries (max_retries=0) or implement your own deduplication logic.

Fall back to another model

Catch the error from your primary model and retry with a different one:

Use circuit breakers

A circuit breaker stops sending requests after repeated failures and re-tests after a timeout:

Set timeouts

Log errors

Log errors for debugging:

Map OpenAI SDK errors

If you use the OpenAI SDK directly (with base_url pointed at Arbytra), you can convert OpenAI errors to typed Arbytra errors using map_openai_error():
You get typed error fields (status_code, code, response_headers) and fine-grained isinstance checks, even when using the OpenAI client. map_openai_error() is Python-only. TypeScript users should use the Arbytra SDK directly for typed errors. See OpenAI Compatibility for OpenAI SDK error mapping.