Seeing You exceeded your current quota? This is billing, not rate limiting — retrying will never fix it. Do this instead:
- Add a payment method and prepay credits at Settings → Billing. A brand-new key with no billing returns this immediately.
- Check your credit balance and monthly budget cap — you may have credits but have hit a spend limit you set under Settings → Limits.
- Confirm the right org/project key. Each project has its own budget; a key from an out-of-credit project 429s even if another project has funds.
insufficient_quota arrives as an HTTP 429, which makes everyone treat it like a rate limit and reach for exponential backoff. That’s the wrong fix. A rate-limit 429 clears in seconds; an insufficient_quota 429 means you are out of money or over a budget cap, and no amount of retrying will ever make it succeed. Branch on the error code, stop retrying, and fix the billing condition.
What this error means
The error body looks like this — note the type and code are both insufficient_quota:
{
"error": {
"message": "You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.",
"type": "insufficient_quota",
"param": null,
"code": "insufficient_quota"
}
} Compare that to a true rate-limit 429, whose code is rate_limit_exceeded. Same HTTP status, completely different fix:
| rate_limit_exceeded | insufficient_quota | |
|---|---|---|
| HTTP status | 429 | 429 |
| Meaning | Too many requests/tokens this minute | Out of credits or over budget cap |
| Retryable? | Yes — backoff and retry | No — retrying never succeeds |
| Fix | Backoff, throttle, tier up | Add credits / raise spend cap |
Common causes
Nearly every insufficient_quota error is one of these billing states.
- No billing set up. A fresh account or new API key with no payment method has effectively zero usable quota. This is the most common cause for first-time integrations.
- Prepaid credit balance hit $0. OpenAI’s API is prepaid — when the balance runs out, every call returns
insufficient_quotauntil you top up. - Monthly budget / hard limit reached. You (or your org admin) set a monthly budget under Settings → Limits. Once spend crosses it, the API hard-stops with this error even if a card is on file.
- Expired free trial credits. Trial grants expire after a few months; once they lapse you must add paid credits.
- Failed payment / declined card. Auto-recharge failed, so the balance never refilled.
- Wrong project or org. Keys are scoped to a project, and budgets are per project. A key from a depleted project errors while another project still has funds.
How to fix it
The fix is always an account action, never a code retry.
- Open the Usage & Billing dashboard. Look at your current credit balance first — if it’s at or near $0, that’s your answer.
- Add or update a payment method, then buy credits (or enable auto-recharge so the balance refills automatically below a threshold).
- Check Settings → Limits for a monthly budget cap lower than your spend. Raise it if you’ve outgrown it.
- Verify which project the key belongs to and that the project has budget. Move the key or fund the project.
- Wait a few minutes after topping up — balance updates aren’t always instant.
Handle it correctly in code — detect, don’t retry
The most important code change is to stop your retry loop from hammering a billing error. Detect insufficient_quota, alert, and fail fast:
import openai
from openai import OpenAI
client = OpenAI(max_retries=0) # we control retries explicitly below
def safe_chat(messages, model="gpt-4o-mini"):
try:
return client.chat.completions.create(model=model, messages=messages)
except openai.RateLimitError as e:
code = getattr(e, "code", "") or (e.body or {}).get("code", "")
if code == "insufficient_quota":
# Billing problem — DO NOT retry. Surface it loudly.
raise RuntimeError(
"OpenAI quota exhausted: add credits or raise your budget cap."
) from e
# Real rate limit — caller can retry with backoff.
raise
print(safe_chat([{"role": "user", "content": "Hello"}]).choices[0].message.content) import OpenAI from "openai";
const client = new OpenAI({ maxRetries: 0 });
async function safeChat(messages, model = "gpt-4o-mini") {
try {
return await client.chat.completions.create({ model, messages });
} catch (err) {
if (err?.code === "insufficient_quota") {
// Never retry a billing error.
throw new Error("OpenAI quota exhausted: add credits or raise your budget cap.");
}
throw err; // rate_limit_exceeded etc. — let the caller back off
}
}
console.log((await safeChat([{ role: "user", content: "Hello" }])).choices[0].message.content); How to prevent it
- Enable auto-recharge with a sensible threshold so a busy day never drains you to zero mid-traffic.
- Set billing alerts below your budget cap, not at it — you want warning before the hard stop.
- Separate projects per environment with their own budgets, so a runaway dev script can’t exhaust production’s quota.
- Monitor the balance programmatically and page yourself when it drops under, say, one day of runway.
- Estimate spend up front. Size your monthly budget against real token costs before launch — model your numbers with the token cost calculator so the cap matches reality.
Don’t put insufficient_quota in your retry path. A retry storm on a billing error wastes API calls, inflates latency, and can trip real rate limits on top — turning “we’re out of credits” into a full outage.
Related errors and providers
- A 429 with
rate_limit_exceededis the retryable sibling — see the OpenAI 429 rate limit fix. - Other providers have their own equivalents: Anthropic 429 rate limit (Anthropic surfaces a low balance as a 400
credit balance is too low), and Gemini’s RESOURCE_EXHAUSTED. - If quota limits on one provider keep biting, spreading load helps — compare OpenAI vs Anthropic pricing.
Running multiple providers for cost and availability headroom is easier behind a router. OpenRouter gives you OpenAI-compatible endpoints across providers with a single prepaid balance, so a depleted account on one provider can fail over to another. (Affiliate link.)
What to do next
- Check your credit balance in the billing dashboard — top up or enable auto-recharge.
- Raise or remove a too-low monthly budget cap under Settings → Limits.
- Patch your error handling to fail fast on
insufficient_quotainstead of retrying. - Add balance monitoring and alerts so the next depletion warns you before it stops traffic.
Frequently asked questions
Why is insufficient_quota a 429 if it's not a rate limit?
error.code: rate_limit_exceeded is retryable, insufficient_quota is a billing problem that retrying will never fix.