Skip to content
Underread.
Guides

How to Fix “You exceeded your current quota” (insufficient_quota) on the OpenAI API

It returns 429, so everyone treats it as a rate limit and adds a retry. It isn't a rate limit, and retrying will never fix it.

By Vemuri Abhiram6 min read
Close-up of a terminal showing a failed API response
Close-up of a terminal showing a failed API response
On this page

Your calls worked an hour ago. Now every one of them comes back the same way:

openai.RateLimitError: Error code: 429 - You exceeded your current quota,
please check your plan and billing details

The status is 429. That's the rate-limiting status, so the obvious move is to add a delay and retry, and most retry wrappers will do exactly that for you without being asked. That instinct will cost you an afternoon, because this 429 isn't a rate limit at all. It's a billing state wearing a traffic error's clothes, and no amount of patience will clear it.

#The fix order at a glance

# Fix Time When it's the answer
1 Read error.code, not the status 2 min Always start here
2 Check the balance on the right project 5 min Credit ran out
3 Find the key you're actually sending 10 min Wrong project or org
4 Make retries stop on this error 20 min Your loop is burning money
5 Set a usage alert 10 min So it doesn't recur silently

#1. Read the error code, not the status code

The status tells you almost nothing here. The body tells you everything:

from openai import OpenAI, RateLimitError

client = OpenAI()
try:
    client.responses.create(model="gpt-4.1-mini", input="ping")
except RateLimitError as e:
    body = getattr(e, "body", {}) or {}
    print(body.get("error", {}).get("code"))

You'll get one of 2 strings, and they mean opposite things:

error.code What it means Retry?
rate_limit_exceeded Too many requests or tokens in the window Yes
insufficient_quota The billing account is empty Never

I've watched a team add exponential backoff to an insufficient_quota loop and leave it running overnight. It made 40,000 failed calls, filled a log bucket, triggered 3 separate alerts and fixed precisely nothing, because the condition it was waiting on was never going to change on its own. A rate limit refills on a rolling window. A balance refills when somebody pays.

#2. Check the balance on the project you're actually calling

Open the billing page and look at the credit balance. If it's zero or negative, that's your answer and the rest of this guide is optional.

Two things catch people here, and both are quiet.

Credit grants expire. Free trial credit carries an expiry date, and the dashboard will happily show you a non-zero grant that lapsed last week while the account bills as empty. Look at the expiry column, not just the figure. This catches people months after signup, when the original grant has long stopped being front of mind.

Auto-recharge can fail silently. A declined card doesn't page anybody. It stops topping up, the balance drains on the next busy day, and the first anyone hears about it is a wall of 429s in production. Worth checking the card on file at the same time you check the balance, because fixing one without the other buys you a week.

There's also a distinction that trips up teams moving from a personal account to a company one. Prepaid credit and monthly invoicing behave differently when they run out: prepaid stops dead at zero, while an invoiced account generally keeps serving and bills you later. If your account was recently converted, the behaviour you remember may no longer apply.

#3. Find the key you're actually sending

This is the one that wastes the most time. You topped up an account, the balance is healthy, and the calls still fail — because the key in your environment belongs to a different project.

Print the tail of the key your process actually loaded:

import os
k = os.environ.get("OPENAI_API_KEY", "")
print(len(k), k[-6:] if k else "MISSING")

Never print the whole key. The last 6 characters are enough to match it against the dashboard.

Check 3 things in order:

  1. The project. Project-scoped keys (keys tied to one project rather than the whole org) bill to that project's budget. A project with its own limit set to 0 returns insufficient_quota while the org has plenty.
  2. The organisation. If you belong to more than 1, an OPENAI_ORG_ID left over from an old job sends calls somewhere you don't fund.
  3. Where the value came from. A .env file that your process never loaded, a CI secret that shadows your local one, a container that baked in an old value at build time.

#4. Make your retry loop stop on this error

Most SDK wrappers and agent frameworks retry every 429 by default. On insufficient_quota that turns one failure into thousands, and it buries the real error in noise.

Branch on the code:

import random, time
from openai import OpenAI, RateLimitError

client = OpenAI()

def call(**kw):
    for attempt in range(6):
        try:
            return client.responses.create(**kw)
        except RateLimitError as e:
            code = (getattr(e, "body", {}) or {}).get("error", {}).get("code")
            if code == "insufficient_quota":
                raise RuntimeError("Billing quota exhausted — retrying will not help") from e
            time.sleep((2 ** attempt) + random.random())
    raise RuntimeError("Rate limited after 6 attempts")

The jitter (the small random value added to each wait) matters when several workers fail together. Without it they all sleep the same length and retry on the same tick. There's more on that pattern in the rate limit guide.

#5. Set an alert so the next one isn't a surprise

Usage alerts email you at a threshold you pick. Set one at roughly half your monthly budget and another near the top. It converts a production outage into an inbox message on a Tuesday.

If the bill itself is the problem rather than the alerting, the fixes in cutting an OpenAI bill without changing models usually find 30% without touching quality.

#Match your symptom to the fix

What you're seeing Most likely cause Go to
Worked yesterday, fails on every call today Credit ran out or a card declined 2
Works locally, fails in CI or production Different key, different project 3
Balance looks fine in the dashboard Project budget set to 0, or grant expired 2 and 3
Thousands of failures in minutes Retry loop treating it as a rate limit 4
Some calls fine, some 429 Genuine rate_limit_exceeded, not quota —

#When none of it worked

If the code really is insufficient_quota, the balance really is positive, and the key really belongs to that project, you've exhausted the self-serve path. Open a billing ticket and include the request id from the failing response header, the last 6 characters of the key, and the project id. Support can see which ledger the call hit, which you can't.

One thing worth checking first: a payment can sit in a pending state for a short window after it clears your bank. If you topped up in the last few minutes, give it 10 and try again before writing the ticket.

Frequently asked questions

Why does a billing problem return 429 and not 402?

402 Payment Required exists but is barely used across the industry. OpenAI groups both the traffic ceiling and the billing ceiling under 429 and distinguishes them in the body. It's the reason so many retry loops behave badly here.

Will waiting a day reset insufficient_quota?

No. Rate limits refill on a rolling window, so they clear on their own. A quota failure is a balance, and a balance only changes when you add money or an invoice settles.

I added credit and it still fails. Why?

Usually the key belongs to a different project from the one you funded, or that project has its own budget limit set to 0. Check both before adding more credit.

Does this affect the Batch API too?

Yes. Batch work draws on the same balance. A batch submitted with no credit fails at the point the job runs rather than on submission, which makes it look like a different fault.

Written by

Vemuri Abhiram

Founder & Editor

I write every post here. The tools I review are ones I pay for and run on real client work, not demo accounts, and every number you see came off my own invoice or dashboard.

More from Underread, once a week.

The guides worth reading and the tests worth trusting. One email, every Friday.

No spam. Unsubscribe in one click.