OpenAI insufficient_quota Error: Causes and How to Fix It

Quick Fix

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:

insufficient_quota 429 (NOT retryable)
{
"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:

Two errors, one HTTP status. Always branch on error.code.
rate_limit_exceededinsufficient_quota
HTTP status 429429
Meaning Too many requests/tokens this minuteOut of credits or over budget cap
Retryable? Yes — backoff and retryNo — retrying never succeeds
Fix Backoff, throttle, tier upAdd credits / raise spend cap

Common causes

The usual suspects

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_quota until 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.

  1. Open the Usage & Billing dashboard. Look at your current credit balance first — if it’s at or near $0, that’s your answer.
  2. Add or update a payment method, then buy credits (or enable auto-recharge so the balance refills automatically below a threshold).
  3. Check Settings → Limits for a monthly budget cap lower than your spend. Raise it if you’ve outgrown it.
  4. Verify which project the key belongs to and that the project has budget. Move the key or fund the project.
  5. 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:

Python — fail fast on quota, back off only on rate limits
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)
JavaScript / Node — branch on the code before retrying
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.
Watch out

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.

One key, many providers

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

  1. Check your credit balance in the billing dashboard — top up or enable auto-recharge.
  2. Raise or remove a too-low monthly budget cap under Settings → Limits.
  3. Patch your error handling to fail fast on insufficient_quota instead of retrying.
  4. 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?
OpenAI reuses HTTP 429 for both 'too many requests' and 'out of quota'. The distinguishing field is error.code: rate_limit_exceeded is retryable, insufficient_quota is a billing problem that retrying will never fix.
I just added a payment method but still get the error. Why?
Two common reasons: the credit balance is still $0 (adding a card doesn't add credits — you must buy them or enable auto-recharge), or the balance update hasn't propagated yet. Wait a few minutes and confirm the balance shows funds.
Does insufficient_quota mean my API key is invalid?
No. An invalid or revoked key returns a 401 authentication error, not a 429. insufficient_quota means the key is valid but the account/project it belongs to is out of credits or over its budget cap.
Can I retry an insufficient_quota error?
No. It will keep failing until you add credits or raise the budget cap. Detect the code in your error handler and stop retrying — retries just waste calls and can trigger real rate limits.
How do I stop running out of quota unexpectedly?
Enable auto-recharge, set billing alerts below your cap, give each environment its own project budget, and monitor the balance programmatically. Estimate monthly spend in advance with a token cost calculator so your budget cap reflects real usage.