Claude API Rate Limit Error: How to Fix It Fast
If you're seeing a 429 status code or a message like rate_limit_error from the Claude API, your application has hit one of Anthropic's limits: requests per minute, tokens per minute, or tokens per day, depending on your usage tier. The fix is almost never "wait and hope" — it's a combination of retry logic with backoff, smarter request shaping, and knowing which limit you're actually hitting.
This article walks through how to diagnose the specific limit you're bumping into, how to implement retries that actually work, and how to restructure your traffic so you stop getting rate limited in the first place.
Step 1: Identify which limit you're hitting
Claude's API returns rate limit errors with headers that tell you exactly what's constrained. Before writing any retry code, log these headers on every response:
curl -i https://api.anthropic.com/v1/messages \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model":"claude-opus-4","max_tokens":100,"messages":[{"role":"user","content":"hi"}]}'
Look at the response headers:
anthropic-ratelimit-requests-remaininganthropic-ratelimit-tokens-remaininganthropic-ratelimit-requests-resetanthropic-ratelimit-tokens-reset
If requests-remaining hits zero, you're sending too many calls per minute — usually a concurrency problem. If tokens-remaining hits zero, your prompts or outputs are too large relative to your tier, which is a sizing problem, not a frequency problem. These two cases need different fixes, so don't just slap a generic retry on everything and call it done.
Step 2: Implement exponential backoff with jitter
A 429 response almost always includes a retry-after header. Respect it. If it's missing, fall back to exponential backoff with jitter so you don't create a thundering herd of retries that all land at the same moment.
async function callWithRetry(fn, maxRetries = 5) {
let attempt = 0;
while (true) {
try {
return await fn();
} catch (err) {
if (err.status !== 429 || attempt >= maxRetries) throw err;
const retryAfter = err.headers?.get("retry-after");
const base = retryAfter ? Number(retryAfter) * 1000 : 2 ** attempt * 500;
const jitter = Math.random() * 300;
await new Promise((r) => setTimeout(r, base + jitter));
attempt++;
}
}
}
This handles transient spikes, but it won't save you if your steady-state traffic consistently exceeds your limit. For that, you need to control concurrency, not just retry after failure.
Step 3: Cap concurrency instead of firing requests in parallel
A very common cause of rate limit errors is code that fans out requests with Promise.all without any ceiling. If you're processing a batch of 200 documents and fire 200 concurrent Claude calls, you will get throttled almost immediately, no matter how generous your tier is.
Use a concurrency limiter:
import pLimit from "p-limit";
const limit = pLimit(5); // tune to your tier's RPM
const results = await Promise.all(
documents.map((doc) => limit(() => callWithRetry(() => sendToClaude(doc))))
);
Start conservatively (5 concurrent requests) and increase gradually while watching the ratelimit-remaining headers. This single change eliminates the majority of rate limit errors reported by teams doing batch processing.
Step 4: Reduce token volume, not just request count
If you're hitting the tokens per minute limit rather than the requests limit, backoff and concurrency control won't help much — you need to send fewer tokens per call. Common fixes:
- Trim system prompts and remove redundant instructions repeated on every call.
- Summarize or truncate long conversation history instead of resending the full transcript every turn.
- Use
max_tokensdeliberately — don't request more output than you need. - Batch smaller, independent tasks into fewer, larger calls where it makes sense, rather than many tiny calls with per-call overhead.
If your use case genuinely needs high throughput, the real fix is requesting a higher tier or usage limit increase from Anthropic directly — retry logic can't manufacture capacity that doesn't exist.
Step 5: Queue and smooth bursty traffic
Rate limits are per-minute windows, so bursty traffic patterns (e.g., a cron job that fires 50 requests at second zero of every minute) will hit limits even if your average usage is well under the cap. Smooth these bursts with a queue that spreads requests evenly across the window rather than firing them all at once. A simple token-bucket or leaky-bucket implementation in front of your Claude calls solves this without touching your retry logic at all.
Step 6: Separate concerns if you're building for a team
If multiple services, environments, or team members are calling the Claude API with the same key, rate limit errors become hard to debug — you can't tell whose traffic triggered the throttle. This is one of the problems SubToAPI solves: it sits on top of your existing Claude access and issues separate sub_live_... API keys per application or environment, with usage metadata per key so you can see exactly which service is consuming tokens and requests. You still implement backoff and concurrency control in your code, but you get visibility into which key is responsible for a spike instead of guessing. Check the quickstart or docs for setup, and pricing for plan details.
Quick checklist
- Log rate limit headers on every response before writing retry code.
- Implement backoff that respects
retry-after, with jitter as a fallback. - Cap concurrency explicitly — don't let
Promise.allfan out unbounded. - Distinguish request-limit errors from token-limit errors; fix sizing separately from frequency.
- Smooth bursty cron-style traffic with a queue.
- Use separate API keys per service so you can attribute spikes correctly.
FAQ
What does a Claude API rate limit error actually mean?
It means you've exceeded one of three caps on your account tier: requests per minute, tokens per minute, or tokens per day. The response includes headers showing which limit and how much time remains before it resets.
Does retrying automatically fix rate limit errors?
Retrying with exponential backoff fixes transient spikes, but if your steady-state traffic exceeds your limit, retries will just keep failing in a loop. You need to reduce concurrency, cut token usage, or request a higher limit.
How do I know if it's a request limit or a token limit problem?
Check the anthropic-ratelimit-requests-remaining and anthropic-ratelimit-tokens-remaining headers on the response. If requests hit zero first, it's a frequency problem; if tokens hit zero first, your prompts or outputs are too large for your tier.