Claude API Rate Limit Retry Strategy: A Practical Guide
The short answer
When Claude's API returns a 429 Too Many Requests (or an overloaded_error from the model itself), the correct retry strategy is exponential backoff with jitter, capped at a reasonable number of attempts, combined with respecting any retry-after signal and spacing out your own request rate so you hit limits less often in the first place. Retrying immediately or in a tight loop makes rate limiting worse, not better — it increases load exactly when the API is telling you to slow down.
This applies whether you're calling Anthropic's API directly or through a proxy like SubToAPI. The retry logic lives in your client code, and the pattern below works for both.
Why Claude API requests get rate limited
Rate limits on Claude's API are usually one of three things:
- Requests per minute (RPM) — too many calls in a short window.
- Tokens per minute (TPM) — your input + output tokens exceed your tier's throughput, even with few requests.
- Model overload — the underlying model is temporarily at capacity, returned as a 529/overloaded error rather than a hard 429.
All three look similar from your code's perspective: you get a non-2xx response and need to decide whether and when to try again. The handling is almost identical, which is why most teams write one retry wrapper that covers both.
The core strategy: exponential backoff with jitter
The idea is simple: wait longer after each failed attempt, and add randomness so multiple concurrent requests don't all retry at the exact same moment (which just recreates the spike that caused the limit).
async function callWithRetry(fn, { maxAttempts = 5, baseDelayMs = 1000 } = {}) {
let attempt = 0;
while (true) {
try {
return await fn();
} catch (err) {
attempt++;
const status = err.status || err.response?.status;
const retriable = status === 429 || status === 529 || status >= 500;
if (!retriable || attempt >= maxAttempts) {
throw err;
}
const retryAfter = err.response?.headers?.get?.('retry-after');
const backoff = retryAfter
? Number(retryAfter) * 1000
: baseDelayMs * 2 ** (attempt - 1);
const jitter = Math.random() * backoff * 0.3;
const delay = backoff + jitter;
console.warn(`Attempt ${attempt} failed (${status}), retrying in ${Math.round(delay)}ms`);
await new Promise((resolve) => setTimeout(resolve, delay));
}
}
}
Key points in that implementation:
- Only retry on retriable errors. A 400 (bad request) or 401 (auth) will never succeed on retry — retrying those just burns your rate limit budget further.
- Respect
retry-afterif present. Some providers send aRetry-Afterheader telling you exactly how long to wait. Use it instead of guessing. - Cap the number of attempts. Five attempts with exponential backoff starting at 1 second gets you to roughly 16 seconds on the last wait — enough to ride out a transient spike without hanging a request indefinitely.
- Add jitter. Without it, every client that got rate limited at the same time retries at the same time, causing a second wave of 429s.
A simple backoff schedule you can reason about
If you don't want to think in code, here's the schedule the pattern above produces (ignoring jitter):
| Attempt | Delay before retry | |---|---| | 1 | 1s | | 2 | 2s | | 3 | 4s | | 4 | 8s | | 5 | 16s |
For most interactive applications (chat UIs, support tools), 2–3 attempts is enough — if the API is still rate limiting you after 6 seconds, the user is better served by a clear error message than a 20-second hang.
For batch jobs (bulk classification, document processing), push maxAttempts higher and let the job run slower rather than failing outright.
Reducing how often you hit limits in the first place
Retry logic is a safety net, not a substitute for sane request pacing. A few things that reduce 429s before they happen:
- Batch smaller calls together. If you're sending many short prompts, combining them into fewer, larger requests often uses fewer total tokens and fewer round trips.
- Queue and throttle client-side. A simple token-bucket or concurrency limiter (e.g., max 3 in-flight requests) smooths out bursts from your own app before they ever reach the API.
- Stream responses instead of waiting for full completions where possible — it reduces the time a connection holds a slot and can improve perceived throughput. See /docs/streaming for the pattern if you're on SubToAPI.
- Separate retryable background work from user-facing calls so a burst of batch jobs doesn't starve your live traffic.
Where a proxy layer helps
If you're building Claude access into a product with multiple team members or multiple apps hitting the same underlying quota, retry logic alone doesn't solve the coordination problem — you also need visibility into who's consuming what, and ideally per-key limits so one runaway script doesn't exhaust the whole account's quota.
This is one of the reasons teams put SubToAPI in front of their Claude usage: it issues separate sub_live_... keys per app or team member, so a rate-limit spike in one integration doesn't take down another, and usage metadata per key makes it obvious which client needs the backoff tuning. The retry strategy above works unchanged against SubToAPI's endpoints — same 429 semantics, same headers. Check /docs/messages for the request format and /docs/quickstart to get a key from the free trial.
Putting it together
A production-ready setup typically has three layers:
- Client-side throttling — cap concurrency and request rate before anything leaves your process.
- Retry with exponential backoff + jitter — handle the transient 429/529 cases that slip through.
- Circuit breaking / fallback messaging — if retries exhaust, fail fast with a clear user-facing message rather than retrying forever.
None of these layers is optional in a real product — skipping the first makes the second work harder than it needs to, and skipping the third turns a rate limit into a hung request.
questions
Does retrying immediately after a 429 ever work? Rarely, and it's bad practice. Rate limits are enforced over a rolling window, so an immediate retry usually hits the same window and fails again — while also counting as an extra request against your quota.
How many retry attempts should I use? 3–5 is typical. Fewer for user-facing requests where latency matters, more for background batch jobs where eventual success matters more than speed.
Is this retry pattern different for streaming requests? The retry logic applies the same way before the stream opens. Once a stream has started successfully, a mid-stream failure should generally be treated as a fresh request with its own backoff rather than resumed. See /docs/streaming for handling details.