Skip to content

RateLimitError

HTTP 429 — the provider rate-limited the request. Retryable with backoff.

if (err instanceof RateLimitError) {
await sleep(err.retryAfter ?? 5000)
}

new RateLimitError(provider, retryAfter?, cause?): RateLimitError

string

number

Error

RateLimitError

ModelError.constructor

readonly optional cause?: Error

Original error that caused this one, if any.

ModelError.cause


code: string

Machine-readable error code (e.g., “ABORT”, “RATE_LIMIT”, “TOOL_DENIED”).

ModelError.code


readonly provider: string

Provider name (e.g., “anthropic”, “openai”).

ModelError.provider


readonly retryable: boolean

Whether this error can be retried by retry middleware.

ModelError.retryable


readonly optional retryAfter?: number

Suggested wait time in seconds before retrying, if the provider sent one.


readonly optional statusCode?: number

HTTP status code from the provider API, if available.

ModelError.statusCode