Claude API 429 Rate Limit Error: How to Fix It
Claude 429 rate_limit_error explained: how it differs from 529 and 402, per-key request limits, reading retry-after, backoff code, and Claude Code behavior.
GoiAPI · · 12 min read
Ask AI and more

A Claude 429 rate limit error (rate_limit_error) means you sent more requests or tokens in a short window than your limit allows, so the API turned the request away. It is not a balance problem and not a model outage. The fix: read the retry-after header, wait that many seconds, then retry with exponential backoff, and send fewer requests at the same time. If the response also carries x-should-retry: false, stop. That 429 comes from a spending cap, and retrying will not help until the cap resets or you raise it.
This guide covers what a 429 means on Anthropic's API and on GoiAPI, how it differs from 529 and 402, the per-key limits on GoiAPI, retry code for curl, Python and Node.js, and what Claude Code does when it hits a 429.
Disclosure: GoiAPI sells API access to the models mentioned in this article.
What a Claude 429 error looks like
On the Anthropic format (/v1/messages), a 429 body has this shape:
{
"type": "error",
"error": {
"type": "rate_limit_error",
"message": "…"
}
}The message says which limit you hit. In Claude Code, the same failure shows up after automatic retries as:
API Error: Request rejected (429) · this may be a temporary capacity issue. If it persists, check https://status.claude.com.When ANTHROPIC_BASE_URL points at a gateway, the last sentence names that gateway's host instead of Anthropic's status page (Claude Code error reference, checked on December 5, 2026).
429 vs 529 vs 402: which error do you have?
Three codes get mixed up in logs. They have different causes and different fixes:
429 rate_limit_error | 529 overloaded_error | 402 low balance (GoiAPI) | |
|---|---|---|---|
| Whose problem | Your key, account or organization went over a limit | The model is at capacity for everyone | Your balance can't cover the request |
| Does waiting help? | Yes, wait for retry-after (except spend-cap 429s) | Yes, usually minutes; or switch model | No |
| What to do | Back off, retry, cut parallel requests | Wait, check status, switch model | Top up, or lower max_tokens |
| Retried automatically | By Claude Code and the SDKs, unless marked not to retry | By Claude Code and the SDKs | No |
Two details matter when you call Claude through GoiAPI. GoiAPI never returns 529: an overloaded model comes back as a 429 with type rate_limit_error, and a model that is temporarily not responding returns 503 with type overloaded_error (GoiAPI error codes, checked on December 5, 2026). So on GoiAPI, read the message to tell a rate limit from an overload. For the overload case in depth, see Claude 529 overloaded error: causes and fixes.
If you came here from an OpenAI error that says "You exceeded your current quota", that 429 is a billing block, not a rate limit; see the OpenAI insufficient_quota fix.
Why Anthropic's API returns 429
According to Anthropic's rate limits page (checked on December 5, 2026):
- Limits are per organization and per model class, measured in requests per minute (RPM), input tokens per minute (ITPM) and output tokens per minute (OTPM). Going over any one of them returns a 429 that names the limit.
- Short bursts count. Limits can be enforced over shorter intervals: 60 RPM might be enforced as 1 request per second. The API uses a token bucket, so capacity refills continuously rather than resetting at the top of each minute.
- Ramp limits. A sharp increase in usage can cause a 429 even while you are under your rate limits. On the Messages API these carry
error.details.error_code: "ramp_limit_exceeded". The advice is to hold traffic where requests succeed and grow it gradually. - The monthly spend cap of your tier also returns 429
rate_limit_error, witherror_code: "enforced_spend_limit_reached"and noretry-afterheader. Retrying fails until access resumes. - Cached reads don't count toward ITPM, so prompt caching stretches your limit.
Anthropic also sends anthropic-ratelimit-* headers (requests, input tokens and output tokens: limit, remaining, reset) so you can slow down before you hit the wall.
429 limits on GoiAPI
When you call Claude through GoiAPI, the gateway's own limits apply before any request reaches the model. Each one has its own message, quoted from the error codes page on December 5, 2026 (the account message is the text the API returns):
| Cause | Message (values in braces are filled in) | Retry? |
|---|---|---|
| Requests per minute on the key | This API key has reached its limit of {limit} requests per minute. Please try again in {seconds} s. | Yes, after Retry-After |
| Requests per minute on the account | Your account has reached its limit of {limit} requests per minute. Please try again in {seconds} s. | Yes, after Retry-After |
| Too many requests running at once | Your account already has {max} requests running at the same time. Please wait for one to finish, then try again. | Yes, when one finishes |
| Daily or monthly spending limit you set | Request rejected because it would exceed the daily spending limit of this API key (${limit}). The key works again from {reopenAt}, or you can raise the limit on the API Keys page. | No: sent with x-should-retry: false |
| The model is overloaded | The model is overloaded. Please try again in a few minutes. | Yes, after Retry-After |
Requests per minute: per key, and per account
Every API key has a requests-per-minute limit (Limits and balance, checked on December 5, 2026). Going over it returns 429 with a Retry-After header giving the seconds to wait. The account has a per-minute limit too, so creating more keys on one account does not multiply your throughput. There is no unlimited plan: if your workload needs a higher limit, contact support with your expected request rate.
Non-streaming responses tell you where you stand (streaming responses do not carry these headers):
| Header | Meaning |
|---|---|
x-ratelimit-limit-requests | Maximum requests per minute for the key |
x-ratelimit-remaining-requests | Requests left in the current minute |
x-ratelimit-reset-requests | Time until the counter resets (e.g. 12s) |
A simple way to see your own limit is the model list, which is not charged (same page) but still counts as one request in the minute:
curl -s -D - -o /dev/null https://api.goiapi.com/v1/models \
-H "Authorization: Bearer $GOIAPI_API_KEY" | grep -i ratelimitWhen we tested on December 3, 2026, our key reported x-ratelimit-limit-requests: 60. Other keys can have different limits, so read the header instead of hard-coding a number.
Concurrency, spending limits and overload
- Concurrency. The account can run only a limited number of requests at the same time, and the message states that number. This is the 429 that Claude Code users meet when many subagents run in parallel.
- Spending limits. On the API Keys page you can set a daily and a monthly spending limit per key. When a request would go over, you get a 429 with
x-should-retry: false. ItsRetry-Aftercounts down to the moment the key works again, which can be hours away, so never sleep on it blindly. - Overload. An overloaded model returns 429 with a 30-second
Retry-After(checked on December 5, 2026). Check the model's row on the status page, or switch model.
A 429 is returned before the model runs, so it produces no content and is not charged. On GoiAPI, a failed request that returns no content is not charged, except a request you cancel yourself.
How to read retry-after
retry-after is a response header holding the number of seconds to wait before you try again. Rules that hold for both Anthropic and GoiAPI:
- If it is there, honor it. Retrying earlier will most likely fail again and burns one more request from your minute.
- Check
x-should-retryfirst. If it isfalse, don't retry at all. Anthropic's SDKs follow this header when it is present (Claude API errors, checked on December 5, 2026). - Cap the wait. A
retry-afterof thousands of seconds means a cap or a schedule, not a short throttle. Fail fast and tell the user instead of hanging a request for an hour. - Not every 429 has it. Anthropic's spend-cap 429 has no
retry-after. Fall back to exponential backoff when the header is missing.
Retry with exponential backoff and jitter
Exponential backoff doubles the wait after each failure: 1 s, 2 s, 4 s, 8 s and so on, up to a ceiling. Jitter adds randomness to each wait so that many clients that failed at the same moment don't all retry at the same moment again. The examples below use "full jitter": pick a random wait between 0 and the current backoff ceiling. When retry-after is present, they wait that long plus up to one second of jitter.
All three examples call the Anthropic-format endpoint on GoiAPI at https://api.goiapi.com/v1/messages, as in the quickstart. Put your key in the GOIAPI_API_KEY environment variable.
curl
curl has retries built in. --retry treats HTTP 408, 429, 500, 502, 503, 504, 522 and 524 as transient, doubles the wait from 1 second, and follows Retry-After (curl 8.21.0 manual):
curl https://api.goiapi.com/v1/messages \
--retry 5 --retry-max-time 120 \
-H "x-api-key: $GOIAPI_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{"model": "claude-haiku-5-5", "max_tokens": 512, "messages": [{"role": "user", "content": "Hello"}]}'Keep --retry-max-time. curl does not read x-should-retry, and without a time cap it will sleep for the full Retry-After of a spending-limit 429. In our test against a local server that returned Retry-After: 3600, curl with --retry-max-time 120 gave up at once, while plain --retry 2 was still waiting when we stopped it.
Python
Standard library only, so it runs anywhere Python 3 does:
import json
import os
import random
import time
import urllib.error
import urllib.request
BASE_URL = os.environ.get("GOIAPI_BASE_URL", "https://api.goiapi.com")
HEADERS = {
"x-api-key": os.environ["GOIAPI_API_KEY"],
"anthropic-version": "2023-06-01",
"content-type": "application/json",
}
RETRYABLE = {429, 500, 502, 503, 504, 529}
def call_claude(body, max_attempts=5, base=1.0, cap=30.0, max_wait=120.0):
data = json.dumps(body).encode()
for attempt in range(max_attempts):
req = urllib.request.Request(
f"{BASE_URL}/v1/messages", data=data, headers=HEADERS, method="POST"
)
try:
with urllib.request.urlopen(req, timeout=600) as resp:
return json.load(resp)
except urllib.error.HTTPError as e:
message = json.loads(e.read() or b"{}").get("error", {}).get("message")
retry_after = e.headers.get("retry-after")
if (
e.code not in RETRYABLE
or e.headers.get("x-should-retry") == "false"
or attempt == max_attempts - 1
):
raise RuntimeError(f"HTTP {e.code}: {message}") from e
if retry_after and retry_after.isdigit():
delay = int(retry_after) + random.uniform(0, 1)
else:
delay = random.uniform(0, min(cap, base * 2**attempt))
if delay > max_wait:
raise RuntimeError(f"HTTP {e.code}, wait too long: {message}") from e
print(f"HTTP {e.code}, retry {attempt + 1} in {delay:.1f} s")
time.sleep(delay)
reply = call_claude({
"model": "claude-haiku-5-5",
"max_tokens": 512,
"messages": [{"role": "user", "content": "Hello"}],
})
print(reply["content"][0]["text"])Node.js
Uses the built-in fetch (Node.js 18 or later). Save it as retry.mjs so top-level await works:
const BASE_URL = process.env.GOIAPI_BASE_URL ?? 'https://api.goiapi.com';
const RETRYABLE = new Set([429, 500, 502, 503, 504, 529]);
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
async function callClaude(
body,
{ maxAttempts = 5, baseMs = 1000, capMs = 30000, maxWaitMs = 120000 } = {},
) {
for (let attempt = 0; ; attempt++) {
const res = await fetch(`${BASE_URL}/v1/messages`, {
method: 'POST',
headers: {
'x-api-key': process.env.GOIAPI_API_KEY,
'anthropic-version': '2023-06-01',
'content-type': 'application/json',
},
body: JSON.stringify(body),
});
if (res.ok) return res.json();
const { error } = await res.json().catch(() => ({}));
const retryAfter = Number(res.headers.get('retry-after'));
if (
!RETRYABLE.has(res.status) ||
res.headers.get('x-should-retry') === 'false' ||
attempt === maxAttempts - 1
) {
throw new Error(`HTTP ${res.status}: ${error?.message}`);
}
const delay =
retryAfter > 0
? retryAfter * 1000 + Math.random() * 1000
: Math.random() * Math.min(capMs, baseMs * 2 ** attempt);
if (delay > maxWaitMs) throw new Error(`HTTP ${res.status}, wait too long: ${error?.message}`);
console.log(`HTTP ${res.status}, retry ${attempt + 1} in ${(delay / 1000).toFixed(1)} s`);
await sleep(delay);
}
}
const reply = await callClaude({
model: 'claude-haiku-5-5',
max_tokens: 512,
messages: [{ role: 'user', content: 'Hello' }],
});
console.log(reply.content[0].text);How we tested these, on December 5, 2026 with Python 3.14.7 and Node.js 26.12.1: we pointed GOIAPI_BASE_URL at a local test server that returned 429 with Retry-After: 1 twice and then succeeded; both scripts waited and printed the answer. The same server's 429 without Retry-After was retried with jittered backoff, and a 429 with x-should-retry: false or a 402 stopped at once without retrying. Against api.goiapi.com with an invalid key, both scripts stopped on the 401 with no retry. We did not trigger a real rate limit on a live key.
The scripts don't retry inside a stream. If you stream ("stream": true), an error after the 200 headers arrives as an error event in the stream, with no status code and no Retry-After (streaming docs), so handle it in your stream reader.
If you use the Anthropic SDK
You may not need your own loop. Anthropic's SDKs retry a failed request up to two times by default (max_retries in Python, maxRetries in TypeScript). They retry 429 and 5xx, wait for retry-after when it is present, otherwise back off exponentially from 0.5 to 8 seconds, and obey x-should-retry (Claude API errors, checked on December 5, 2026). Raise max_retries for batch jobs, or set it to 0 and use your own loop if you want a cap on long waits. Pointing the SDK at GoiAPI is shown in the Anthropic SDK guide.
What Claude Code does when it hits a 429
Claude Code handles most 429s for you. From the Claude Code error reference (checked on December 5, 2026):
- It retries first. Temporary 429 throttles are retried up to 10 times with exponential backoff. The spinner shows
Retrying in Ns · attempt x/y, and for a rate limit the label names the reason from the first attempt. When you finally seeRequest rejected (429), those retries have already failed. - It won't retry a spend-limit 429. A 429 marked
x-should-retry: falseis shown without retrying. On GoiAPI that is the per-key spending limit: raise it on the API Keys page or wait for the time in the message. - Retry tuning.
CLAUDE_CODE_MAX_RETRIESchanges the count (default 10, capped at 15). For unattended runs such as CI,CLAUDE_CODE_RETRY_WATCHDOG=1keeps retrying 429 and 529 capacity errors past that count, andCLAUDE_CODE_RETRY_WATCHDOG_MAX_WAIT_MScaps how long each request waits. - Recommended fixes. Run
/statusto confirm which credential is active: a strayANTHROPIC_API_KEYcan send requests through a low-tier key instead of your subscription. Run fewer subagents in parallel, or switch to a smaller model with/modelfor high-volume scripted runs.
With GoiAPI as the endpoint, parallel subagents are the usual trigger, because each one is a separate request running at the same time on your account. Each tool step in a turn is a separate API request, so a long agent loop can reach the per-minute limit faster than you would expect from typing alone. Keeping sessions lean helps here too; see how to reduce Claude Code token usage.
Don't confuse a 429 with your plan's usage limits. Messages such as You've hit your session limit or You've hit your weekly limit are about a Claude subscription's quota, not about requests per minute. Those are covered in Claude Code usage limit reached. For every other Claude Code status code, see Claude Code API error codes. Setup for Claude Code on GoiAPI is in the Claude Code integration guide.
How to avoid 429 errors
- Spread requests out. Queue requests on your side and stay below the limit in
x-ratelimit-limit-requests. - Use a fixed worker pool instead of unbounded
Promise.allor thread pools, so concurrency stays capped. - Slow down early when
x-ratelimit-remaining-requestsgets low. - Ramp up bulk jobs gradually; a sudden jump can trip Anthropic's ramp limits.
- Ask for a higher limit when the workload is real: on GoiAPI through support, on Anthropic with a tier increase in the Console.
FAQ
What does error 429 mean in the Claude API?
It means rate_limit_error: your key, account or organization sent more requests or tokens than its limit allows in a short window. Wait for the retry-after seconds and retry with backoff. On Anthropic's API, a 429 can also mean your tier's monthly spend cap was reached, which retrying does not fix.
How long should I wait after a 429?
As long as the retry-after header says. Without it, back off exponentially with jitter and stop after a few attempts.
Is 429 the same as 529?
No. 429 is your limit; 529 is a model at capacity for everyone. On GoiAPI there is no 529: an overloaded model returns 429 with the message "The model is overloaded", so read the message to tell them apart.
Can I get an unlimited rate limit?
No. Every GoiAPI key and account has a per-minute limit. If your workload needs more, contact support with the request rate you expect.
Get started
- Create a GoiAPI account and create an API key in the dashboard.
- Top up with USDT (TRC20 or BEP20) or Binance Pay. No credit card and no monthly fee. Top-ups are final and non-refundable, so add only what you plan to use.
- Call
https://api.goiapi.com/v1/messageswith a model such as Claude Haiku 5.5, and add the retry logic above before you scale up.


