Skip to main content
The SDK throws typed errors for every failure mode. Use instanceof checks to handle specific cases.

Error hierarchy

Error properties

All APIError subclasses include:

Retry behavior

The client automatically retries requests that fail with these status codes: 408, 409, 429, 500, 502, 503, 504. Retries use exponential backoff starting at 500ms, capped at 8 seconds, with random jitter. If the server sends a Retry-After header, the client respects that timing instead. By default, the client retries up to 2 times (3 total attempts). You can configure this:
If all retries are exhausted, the SDK throws the last error it received.

Handling specific errors

Cancellation

Pass an AbortSignal to cancel a request: