Getting 429 rate_limit_error from the Anthropic API? Start here:
- Honor the
retry-afterheader and retry with exponential backoff + jitter — most 429s clear in seconds. - Read the
anthropic-ratelimit-*headers to see whether you hit requests, input tokens, or output tokens (Claude limits them separately). - Don’t confuse it with
529 Overloaded— that’s Anthropic’s capacity, not your limit. Different fix; see below.
Anthropic returns HTTP 429 with type: "rate_limit_error" when you exceed your account’s per-minute allowance. Claude meters three things separately — requests per minute (RPM), input tokens per minute (ITPM), and output tokens per minute (OTPM) — so you can be well under your request count and still get throttled on tokens. Almost every 429 is recoverable with backoff; the rest is a tier upgrade.
What this error means
{
"type": "error",
"error": {
"type": "rate_limit_error",
"message": "Number of request tokens has exceeded your per-minute rate limit."
}
} The response carries headers that tell you exactly which ceiling you hit and when it resets:
| Header | What it tells you |
|---|---|
| retry-after | Seconds to wait before retrying (honor this first) |
| anthropic-ratelimit-requests-remaining | Requests left in the current window |
| anthropic-ratelimit-input-tokens-remaining | Input tokens left this minute |
| anthropic-ratelimit-output-tokens-remaining | Output tokens left this minute |
| anthropic-ratelimit-*-reset | RFC-3339 time the bucket refills |
429 vs 529 — don’t treat them the same
A 429 is about your usage; a 529 is about Anthropic’s capacity.
| 429 rate_limit_error | 529 Overloaded | |
|---|---|---|
| Cause | You exceeded your RPM/ITPM/OTPM | Anthropic is at capacity globally |
| Under your control? | Yes — throttle or tier up | No — just back off and retry |
| Fix | Backoff + reduce rate / raise tier | Backoff with longer waits; failover |
If you’re chasing 529s rather than 429s, use the dedicated Claude 529 Overloaded fix.
Common causes
- Bursty concurrency. A parallel fan-out or retry storm exceeds RPM in one window even when your average rate is fine.
- Token throughput, not request count. Long prompts (big context, documents, tool results) burn ITPM fast; large generations burn OTPM. Check which header hit zero.
- Low tier. New accounts start at Tier 1 with modest limits that rise as you spend and age.
- Shared key across workloads. One key for app + cron + dev means a batch job starves live traffic.
How to fix it
Exponential backoff that honors retry-after
The official SDKs retry 429/529 automatically (twice by default). Raise that, and add your own loop for control:
import anthropic, time, random
client = anthropic.Anthropic(max_retries=5) # SDK retries 429/529 with backoff
def chat_with_backoff(messages, model="claude-sonnet-4-6", max_attempts=6):
for attempt in range(max_attempts):
try:
return client.messages.create(model=model, max_tokens=1024, messages=messages)
except anthropic.RateLimitError as e:
if attempt == max_attempts - 1:
raise
retry_after = None
if e.response is not None:
retry_after = e.response.headers.get("retry-after")
delay = float(retry_after) if retry_after else (2 ** attempt) + random.random()
time.sleep(delay)
msg = chat_with_backoff([{"role": "user", "content": "Hello"}])
print(msg.content[0].text) import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({ maxRetries: 5 });
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
async function chatWithBackoff(messages, { model = "claude-sonnet-4-6", maxAttempts = 6 } = {}) {
for (let attempt = 0; attempt < maxAttempts; attempt++) {
try {
return await client.messages.create({ model, max_tokens: 1024, messages });
} catch (err) {
if (err?.status !== 429 || attempt === maxAttempts - 1) throw err;
const retryAfter = Number(err?.headers?.["retry-after"]);
const backoff = Number.isFinite(retryAfter)
? retryAfter * 1000
: 2 ** attempt * 1000 + Math.random() * 1000;
await sleep(backoff);
}
}
}
const msg = await chatWithBackoff([{ role: "user", content: "Hello" }]);
console.log(msg.content[0].text); Throttle proactively and watch the headers
Read anthropic-ratelimit-*-remaining on each response and slow down as any bucket nears zero — cheaper than absorbing 429s. For batch work, put requests behind a token bucket sized just under your tier’s RPM and token limits.
Tier up or cut token throughput
- Raise your tier by adding credits and accumulating spend — limits scale with tier. See the Anthropic Claude rate limits reference.
- Use the Message Batches API for non-realtime work — separate, higher throughput at a discount, off your live budget.
- Cut tokens with prompt caching for long, repeated prefixes (system prompts, few-shot, big context) so they don’t recount against ITPM every call.
- Route tolerant work to a smaller model (e.g. Haiku) with higher headroom.
How to prevent it
- Throttle every batch behind a limiter under your real ceilings.
- Adapt to the remaining-token headers instead of waiting for the 429.
- Cache repeated context to shrink ITPM.
- Separate keys per workload so bulk jobs can’t starve live traffic.
Uncapped, jitter-free retries make 429s worse: clients retry in lockstep, re-saturate the limit, and compound. Always cap attempts and randomize the backoff.
Related errors and providers
- Claude 529 Overloaded — the capacity-side sibling.
- OpenAI 429 rate limit and Gemini RESOURCE_EXHAUSTED — the same class on other providers.
- Sizing a move onto Claude? See OpenAI vs Anthropic pricing and the OpenAI → Anthropic migration guide.
Keep traffic flowing when Claude rate-limits by failing over to another provider. OpenRouter routes across providers on 429s behind one OpenAI-compatible API — a useful pressure valve for bursty load. (Affiliate link; you can build equivalent failover with the code above.)
What to do next
- Honor
retry-afterand add capped backoff with jitter. - Read the
anthropic-ratelimit-*headers to know whether requests, input, or output tokens hit zero. - Throttle batch work under your tier limits and cache repeated context.
- Tier up or use the Batches API if you’re consistently at the ceiling.