OpenAI 429 rate_limit_exceeded
Why am I getting OpenAI 429 rate_limit_exceeded?
A chat completion returns HTTP 429 with a `rate_limit_exceeded` code and a message naming the exact limit that tripped (requests-per-minute or tokens-per-minute) plus how many seconds to wait — most commonly on a Free-tier key on its very first burst of calls.
Is this your error?
{"error":{"message":"Rate limit reached for requests. Limit 3, Used 3, Requested 1. Please try again in 20s.","type":"requests","param":null,"code":"rate_limit_exceeded"}}Why this happens on OpenAI
Source: https://platform.openai.com/docs, verified 2026-08-08.
OpenAI's 429 body names the specific limit dimension you hit and includes a countdown in the message text itself, on top of the retry-after header — which is more diagnostic detail than a generic 429 gives you, and worth reading before assuming your account is throttled generally.
The fix
def call_with_backoff(messages, max_retries=5):
for attempt in range(max_retries):
try:
return client.chat.completions.create(model=MODEL, messages=messages)
except RateLimitError as e:
retry_after = float(e.response.headers.get("retry-after", 2 ** attempt))
time.sleep(retry_after)
except APIStatusError as e:
print(f"OpenAI returned {e.status_code}: {e.message}")
raise
raise RuntimeError("exceeded max retries")
response = call_with_backoff([{"role": "user", "content": "Say hello in one sentence."}])
print(response.choices[0].message.content)Backoff and retry
OpenAI returns HTTP 429 with a retry-after header.
Back off for the duration in retry-after, then retry with jittered exponential backoff. A 429 on the first call almost always means Free-tier caps, not an outage.
Full tier limits: OpenAI rate limits →
What not to do
Don't retry immediately in a tight loop — a burst of retries against a capacity or rate signal just adds load and delays recovery. Use jittered exponential backoff.
Evidence
Reproduced against OpenAI's own documentation and the fixture at code-examples/python/openai/errors.py on 2026-08-08; not yet observed in production traffic.
FAQ
What does OpenAI's 429 rate_limit_exceeded body actually contain?
A message naming the specific limit dimension that tripped (requests or tokens), the numeric limit, how many you'd used, and how many seconds to wait — read the message text, not just the status code.
How do I stop hitting OpenAI rate limits?
Back off using the retry-after header with jittered exponential backoff, and check whether you're still on a lower usage tier — see the full tier table on the rate-limits page for your account's actual caps.
