429 with error_code: rate_limit_exceeded.
Retry policy (recommended)
- Retry only on retryable responses (typically
429and transient5xx) - Use exponential backoff with jitter
- Add a max retry count and a max backoff cap
Documentation Index
Fetch the complete documentation index at: /docs/llms.txt
Use this file to discover all available pages before exploring further.
Handle 429s safely with exponential backoff and jitter.
429 with error_code: rate_limit_exceeded.
429 and transient 5xx)delay_ms = min(max_delay, base_delay * 2^attempt) + random(0, jitter)
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
async function withRetries(requestFn, { maxRetries = 5 } = {}) {
let attempt = 0;
while (true) {
const resp = await requestFn();
if (resp.status !== 429 && resp.status < 500) return resp;
if (attempt >= maxRetries) return resp;
const base = 250 * 2 ** attempt;
const jitter = Math.floor(Math.random() * 250);
await sleep(Math.min(5_000, base + jitter));
attempt += 1;
}
}