Claude API Rate Limit 429 Error Handling Guide
A 429 status code from the Claude API means you've hit a rate limit — either requests per minute, tokens per minute, or a concurrency cap tied to your account tier. It's not a bug in your code and not necessarily a sign you need a bigger plan; it's Anthropic's way of telling you to slow down or spread load more evenly.
Handling 429s correctly means doing three things: reading the response headers to understand which limit you tripped, backing off in a way that doesn't hammer the API harder than before, and designing your application so a temporary rate limit doesn't turn into a failed user request. This article covers all three, plus how to reduce how often you see 429s in the first place.
Why Claude API returns 429 errors
Anthropic enforces several limit types simultaneously:
- Requests per minute (RPM) — how many API calls you can make in a 60-second window
- Input tokens per minute (ITPM) — total tokens sent across requests in that window
- Output tokens per minute (OTPM) — total tokens generated in that window
- Concurrent requests — how many requests can be in flight at once on some tiers
Limits scale with your usage tier and spend history, not just your plan name. A new account on a paid tier will have lower limits than an account that's been spending consistently for weeks, even on the same nominal tier. This catches a lot of teams off guard during launch week — traffic spikes right when limits are at their lowest.
Reading the rate limit response
A 429 response includes headers that tell you exactly what happened:
HTTP/1.1 429 Too Many Requests
retry-after: 12
anthropic-ratelimit-requests-limit: 50
anthropic-ratelimit-requests-remaining: 0
anthropic-ratelimit-requests-reset: 2024-06-01T12:00:00Z
anthropic-ratelimit-tokens-limit: 40000
anthropic-ratelimit-tokens-remaining: 0
anthropic-ratelimit-tokens-reset: 2024-06-01T12:00:00Z
The retry-after header is the simplest signal — it tells you how many seconds to wait before retrying. The anthropic-ratelimit- headers let you proactively throttle your own request rate before* you get a 429, which is far better than reacting after the fact.
async function callClaude(payload) {
const res = await fetch("https://api.anthropic.com/v1/messages", {
method: "POST",
headers: {
"x-api-key": process.env.ANTHROPIC_API_KEY,
"anthropic-version": "2023-06-01",
"content-type": "application/json",
},
body: JSON.stringify(payload),
});
if (res.status === 429) {
const retryAfter = Number(res.headers.get("retry-after")) || 5;
throw new RateLimitError(retryAfter);
}
return res.json();
}
Handling 429s in production
1. Respect retry-after exactly
Don't guess at a delay. If the header says 8 seconds, wait at least 8 seconds. Retrying earlier just extends the window where you're rate limited, since the limit counter hasn't reset yet.
2. Queue requests instead of firing them all at once
If your app sends batches of requests (bulk summarization, background jobs, multi-user chat at scale), put them through a queue with a concurrency cap rather than issuing them in parallel. A simple token-bucket or sliding-window limiter on your own side keeps you under Anthropic's limits most of the time, which means fewer 429s to handle at all.
class RateLimiter {
constructor(maxPerMinute) {
this.max = maxPerMinute;
this.timestamps = [];
}
async acquire() {
const now = Date.now();
this.timestamps = this.timestamps.filter(t => now - t < 60000);
if (this.timestamps.length >= this.max) {
const wait = 60000 - (now - this.timestamps[0]);
await new Promise(r => setTimeout(r, wait));
return this.acquire();
}
this.timestamps.push(now);
}
}
3. Separate retryable errors from fatal ones
A 429 is retryable. A 400 (bad request) or 401 (auth) is not — retrying those just wastes time and can mask a real bug. Make sure your error handling branches on status code rather than treating every non-200 response the same way.
4. Degrade gracefully for end users
If a user-facing request hits a rate limit after a reasonable retry window, show a clear message ("busy right now, try again in a few seconds") instead of a generic error. For background jobs, re-queue rather than drop the task.
5. Separate token-heavy and latency-sensitive traffic
If you're running both big batch summarization jobs and live chat on the same API key, the batch jobs will eat your tokens-per-minute budget and cause the chat requests to 429. Splitting traffic across separate keys — or separate rate limit pools — keeps one workload from starving the other.
Reducing how often you hit 429s
Handling the error well is necessary, but reducing frequency matters more at scale:
- Trim prompts — shorter system prompts and context windows reduce ITPM consumption per call
- Cap
max_tokenson requests that don't need long outputs, to reduce OTPM pressure - Batch where possible instead of issuing many small requests
- Monitor headers proactively and throttle before you're at zero remaining, not after
This is also where routing and key management tools help. SubToAPI sits in front of your Claude access and gives you usage metadata per application key, so you can see which key or workload is driving token consumption before it turns into a wall of 429s — instead of debugging blind after the fact. If you're already managing multiple teams or apps against one Claude account, separating them into distinct sub_live_... keys through the quickstart makes it much easier to isolate which part of your system needs throttling.
A minimal retry pattern
You don't need a full backoff library for most apps — a bounded retry loop that respects retry-after and caps total attempts is enough:
async function callWithRetry(payload, maxAttempts = 4) {
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
try {
return await callClaude(payload);
} catch (err) {
if (err instanceof RateLimitError && attempt < maxAttempts) {
await new Promise(r => setTimeout(r, err.retryAfter * 1000));
continue;
}
throw err;
}
}
}
Combine this with the queue-based limiter above and most 429s disappear from your logs entirely, because you stop sending requests fast enough to trigger them.
FAQ
Does a 429 error cost me tokens or money? No. Claude's API does not bill for rejected requests. A 429 response means the request was never processed, so you only pay for calls that actually succeed and return output.
Will upgrading my plan fix 429 errors? Sometimes. Higher tiers get higher RPM/TPM limits, but a lot of 429s come from bursty traffic patterns rather than genuinely exceeding sustained throughput. Smoothing requests with a queue often fixes it without an upgrade.
Can I avoid 429s entirely with a proxy or gateway? You can reduce them significantly by routing requests through a layer that tracks usage and enforces your own internal rate limits before hitting Anthropic's API. A service like SubToAPI adds that visibility layer along with API key management, though the underlying Claude rate limits still apply.