Skip to content

429 insufficient_quota

Cause: Your OpenAI organization, project or key has run out of credits or hit a spend or usage limit, so every request is refused until that changes.

Copy-paste fix

Detect billing 429s and stop immediately, with an alert, instead of letting retry logic spin.

import logging
import openai

BILLING_CODES = {"credit_balance_exhausted", "organization_spend_limit_exceeded",
                 "project_spend_limit_exceeded", "api_key_spend_limit_exceeded",
                 "organization_usage_limit_exceeded"}

class BillingBlocked(Exception):
    pass

def call(client, **kwargs):
    try:
        return client.chat.completions.create(**kwargs)
    except openai.RateLimitError as e:
        if e.type == "insufficient_quota" or e.code in BILLING_CODES:
            logging.critical("LLM billing block: type=%s code=%s", e.type, e.code)
            raise BillingBlocked(e.code or e.type) from e  # do not retry
        raise  # a real rate limit: let your backoff handle it

Work out what your monthly token use should cost on TokenCenter

What the error means

OpenAI's error-codes guide says billing errors arrive as 429s, with the specific cause in error.code (for example credit_balance_exhausted or project_spend_limit_exceeded), while error.type can still be insufficient_quota.

The same guide says retrying billing, spend or quota errors won't restore access. Anthropic's docs make the same point for a spend-cap 429: it has no retry-after header and keeps failing until access resumes.

Checklist

  1. Check credits and the spend limits on the organization, project and key.
  2. Alert a human on the first billing 429; don't wait for users to report it.
  3. Make sure retry code skips billing codes.
  4. Track spend per feature so a jump shows up before the limit does.
  5. Use separate keys per app so one runaway job can't block the rest.

Related

Sources

All guides · All errors