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
- Check credits and the spend limits on the organization, project and key.
- Alert a human on the first billing 429; don't wait for users to report it.
- Make sure retry code skips billing codes.
- Track spend per feature so a jump shows up before the limit does.
- Use separate keys per app so one runaway job can't block the rest.
Related
- 429 Too Many Requests (rate_limit_exceeded)
- Failure mode: Budget surprises
- Failure mode: Retry and cost multipliers
- ModelRaters list: Best for fast and low cost