Why is the API returning 429, and what should I do?
A 429 means you have spent a rolling cap, not that you are banned. Our 429 comes with a Retry-After header saying how many seconds until the cap frees up — respect it, and the request succeeds. If you are seeing 402 instead, that is a different thing: no allowance and no balance.
Three failures people mix up
| Status | What it means | What to do |
|---|---|---|
| 429 | You have hit a rolling cap — the 5-hour or the weekly one. Comes with Retry-After. | Back off for the stated time, then retry. Nothing is lost. |
| 402 | No plan allowance and no balance — or the model is not on your plan. | Top up, upgrade, or switch to a model your plan includes. |
| 503 | The upstream network could not serve the request. | Retry. On a paid plan this is rarer, because those requests fail over to a second provider. |
Where our 429 comes from
Plans hold an allowance for the billing period, plus two rolling caps on how fast it can be spent: a 5-hour window and a weekly one. They exist so one runaway agent loop cannot burn a month of allowance in an afternoon. Both are a percentage of the plan’s allowance, so a larger plan gets a proportionally larger burst — and both are visible as percentages in the console, with the reset time next to them.
If you keep a prepaid balance as well as a plan, you do not get throttled at all — spending past the window bills per token from the balance instead of returning 429.
The retry pattern
import time, openai
def call_with_retry(client, **kw):
for attempt in range(5):
try:
return client.chat.completions.create(**kw)
except openai.RateLimitError as e:
# Prefer the server's number over your own guess.
wait = int(getattr(e, "response", None) and
e.response.headers.get("retry-after") or 2 ** attempt)
time.sleep(wait)
raise RuntimeError("still rate limited after 5 attempts")If you are hitting it constantly
- Look at what is spending the allowance. In the console, the burn rate per model tells you this directly — the same tokens on a ×2.9 model cost nearly three times the window.
- Cut the context you resend. Most agent loops resend the entire history every turn; trimming it is usually the single biggest saving available.
- Move bulk work to the cheapest model and reserve the expensive one for the steps that need it.
- If the workload is genuinely that size, a larger plan raises both caps — they scale with the allowance.
FAQ
▸Does a 429 mean I was charged?
No. The request was refused before it reached a model, so nothing was billed and nothing was consumed.
▸How long is the wait?
Read the Retry-After header — it is the authoritative number. The 5-hour window frees up continuously as older usage ages out of it, so waits are usually short.
▸Is there a requests-per-minute limit?
The caps we enforce are on spend over a rolling window, not on request count per minute. So a burst of small requests is fine; a burst of very large ones is what reaches a cap.