Skip to content
Billfuse

Billing error or rate limit? AI API errors from OpenAI, Anthropic, Gemini and OpenRouter

Last updated

An AI API can stop your requests for two different reasons: you're sending them too fast, or you're out of money. The status code often doesn't tell you which. OpenAI and Anthropic use 429 for both, Anthropic also uses 400 for a spend limit, and OpenRouter uses 402 and 403. The providers say to wait and retry a rate limit. A billing error keeps failing until someone fixes the billing (adds credits, raises a limit, updates payment details) or the limit resets.

This page lists the billing errors from OpenAI, Anthropic, Gemini and OpenRouter, the field that tells each one apart from a rate limit, and a function that sorts them. What it says about each provider was checked against that provider's docs on November 15, 2026. Where a message or a status isn't in the provider's docs, the page says “as reported” and links the developers' report it comes from, with its date. Where an answer in a table's Retry? column is our advice rather than the provider's, the cell says “our advice”.

The short version

  1. Find your provider below, and match the status and the field it names. The status alone isn't enough.
  2. If it's a billing error, stop retrying, and tell someone who can add credits or change the limit.
  3. If it's a rate limit, wait and retry: at least as long as the Retry-After header says if there is one, with backoff if not, and with a maximum number of attempts.

Before you add credits, check auto-reload. With it on, running out of credits no longer stops a runaway loop, because the provider buys more. OpenAI and Gemini let you give auto-reload a monthly limit. At Anthropic, set a spend limit as well. At OpenRouter, give the key a credit limit: OpenRouter warns that a key with no limit can spend your entire balance, auto top-ups included.

Sources: OpenAI Help Center, Prepaid API billing, Google AI Studio, Billing, Claude Code, Error reference, OpenRouter, Authentication

One status, different meanings

OpenAI

All four of OpenAI's billing errors come back as 429, the status of a rate limit. Read error.code. OpenAI says the error's type can still be insufficient_quota, and that “Retrying billing, spend, or quota errors won't restore API access.”

ErrorWhat stopped youRetry?
429 credit_balance_exhaustedYour organization has no prepaid credits left.No. Add credits.
429 project_spend_limit_exceededThe project reached its enforced spend limit.No. Raise the limit, or wait for the monthly reset.
429 organization_spend_limit_exceededThe organization reached its enforced spend limit.No. Raise the limit, or wait for the monthly reset.
429 organization_usage_limit_exceededThe organization reached the usage limit OpenAI set.No. Ask OpenAI for a higher limit.
429 insufficient_quota as the codeAn older error for any of the four. The code doesn't say which.No. Check credits and limits.
429 slow_downYour request rate went up too quickly.Yes, more slowly.
429, other codesA rate limit. OpenAI's guide lists it without a code.Yes, unless the type is insufficient_quota.
503 server_is_overloadedThe model is overloaded. Not your account.Yes.

The messages

Error 429 credit_balance_exhausted, as reported
You have no credits remaining. Add credits to continue using the API at https://platform.openai.com/settings/organization/billing/.

OpenAI's docs give the code but not this message. From a GitHub issue dated November 12, 2026.

Error 429 insufficient_quota, as reported
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.

The older error. OpenAI's docs no longer show it; an archived copy of the error codes page from July 23, 2026 still did. From a log in a GitHub issue opened on August 21, 2026. Gemini has sent the same first sentence; see Gemini below.

You may also find billing_hard_limit_reached, “Billing hard limit has been reached”, in older code and posts. It isn't in OpenAI's docs now, and the newest forum thread we found that starts with it is from June 19, 2025. Forum posts show it as a 400, and the function further down doesn't check for it.

More in our guides to the insufficient_quota error and OpenAI spend limits.

Sources: OpenAI, Error codes, Rate limits

Anthropic

Anthropic uses three statuses for money: 400 for a spend limit you set, 429 for your usage tier's monthly spend cap, and 402 for a billing problem. The 429 has the same type as a rate limit, rate_limit_error. On the Messages API, its error.details.error_code tells them apart, and it has no retry-after header. Anthropic: “Retrying, including the SDK's automatic retries, fails until access resumes.”

ErrorWhat stopped youRetry?
400 invalid_request_error, “You have reached your specified API usage limits”A spend limit you set on the organization.No. Raise it, or wait: the message says when access comes back.
400, “You have reached your specified workspace API usage limits”A spend limit you set on a workspace.No. Same as above.
400 invalid_request_error, “Your credit balance is too low”, as reportedYour prepaid credits ran out.No, our advice. Buy credits.
402 billing_errorAn issue with your billing or payment information.No, our advice. Check your payment details.
429 rate_limit_error, error code enforced_spend_limit_reachedYour usage tier's monthly spend cap.No. Access comes back at 00:00 UTC on the 1st, or ask for a tier increase.
429 rate_limit_error, otherA rate limit, or a ramp limit after a sharp rise in usage.Yes, after retry-after if it's there.
529 overloaded_errorThe API is overloaded. Not your account.Yes, our advice. Anthropic's SDK retries it.

Two exceptions. A spend limit on the Claude Code workspace can return a 429 with a retry-after header instead of a 400. And the spend cap's error code is documented for the Messages API only; on other endpoints the spend cap can look like an ordinary rate limit, so keep a maximum number of retries.

The messages

Error 429, from Anthropic's docs
You have reached your API usage limits: your organization has crossed its monthly API usage threshold, set based on your organization's API tier. You will regain access on 2026-09-01 at 00:00 UTC.

The spend cap error, from Anthropic's rate limits page. The date is when access comes back. For a limit you set, Anthropic gives only how the message starts (in the table) and says it states when access resumes.

Error message, from Anthropic's docs
Your credit balance is too low to access the Anthropic API. Please go to Plans & Billing to upgrade or purchase credits.

Anthropic's docs show this message on one page, about the API credits that come with Max, Ultra and Team plans, with no status code. Developers report it as a 400 (GitHub issues from November 12 and November 13, 2026), the same status and type as a spend limit you set. Read the message to tell them apart.

More in our guides to the credit balance error and Anthropic spend limits.

Sources: Anthropic, Errors, Rate limits, API credits for Max, Ultra, and Team plans

Gemini

Google documents one error for running out of money: 402, when your prepaid balance is used up. Its 429 covers rate limits, including spend-based ones, and developers report reaching a spend cap as a 429 too. Google's troubleshooting page: “Do not retry on client errors (like 400, 402, or 403)”.

ErrorWhat stopped youRetry?
402 RESOURCE_EXHAUSTEDYour prepaid balance is used up. Every API key on the billing account stops.No. Add credits.
429 RESOURCE_EXHAUSTED, “monthly spending cap”, as reportedA spend cap on the project or the billing account.No. Google doesn't document this error. Check your caps.
429 RESOURCE_EXHAUSTED, otherA rate limit, including the limit on spend per 10 minutes ($10 on Tier 1, $200 on Tiers 2 and 3) where it applies.Yes, with a maximum number of attempts.
429 quota_exceeded (Interactions API)Your daily quota.Not soon. Wait for the reset, or ask for more.
400 FAILED_PRECONDITIONThe free tier isn't available in your country, and billing isn't on.No. Set up a paid plan.
403 PERMISSION_DENIEDA key or project problem, or an unpaid balance on the billing account.No.
503 UNAVAILABLEThe service may be overloaded or down. Not your account.Yes.

The messages

Error 402, as reported
Your prepayment credits are depleted. Please go to AI Studio at https://ai.studio/projects to manage your project and billing. Learn more at https://ai.google.dev/gemini-api/docs/billing#prepay. 

Google's docs describe this error as “Your Prepay credit balance is depleted.” and say not to retry it, but don't show this message. From a GitHub issue dated November 7, 2026. A notice on Google's developer forum dated September 18, 2026 says these requests returned a 429 until then.

For a spend cap, developers on Google's forum have posted a 429 with “Your billing account has exceeded its monthly spending cap” (April 21, 2026) or “Your project has exceeded its monthly spending cap.” (August 24, 2026). Google's docs don't say which error a spend cap returns. In the first report, requests still failed an hour after the cap was raised. In the second, AI Studio showed spend below the cap.

Gemini has also sent OpenAI's “You exceeded your current quota, please check your plan and billing details.” as a 429 (forum post, November 5, 2026). In one report the message goes on to name the quota, free-tier requests per day (GitHub, November 10, 2026).

Error 400 FAILED_PRECONDITION, Google's description
Gemini API free tier is not available in your country. Please enable billing on your project in Google AI Studio.

More in our guides to the prepayment credits error and Gemini spend caps.

Sources: Google AI Studio, API errors, API errors (Interactions API), Troubleshooting, Rate limits

OpenRouter

OpenRouter uses 402 for credits and 403 for budgets, and a key limit can come back as either. It names the limit in error.metadata.limit_source. Read that, not only the status. OpenRouter: a 402 without a Retry-After header “is not a wait-and-retry case”.

ErrorWhat stopped youRetry?
402 openrouter_creditsYour balance can't cover the request, or one request costs more than your whole in-flight budget.No. Add credits or send a smaller request.
402 openrouter_in_flight_budgetYour running and recent requests fill your in-flight budget.Yes, after Retry-After.
402 with no limit_sourceYour account or API key has insufficient credits.Not until you add credits.
402 or 403 openrouter_key_limitThe API key's credit limit is spent.No, until it resets or you raise it.
403 openrouter_workspace_budgetA workspace budget is spent.No, until resets_at (null: never) or an admin raises it.
403 openrouter_guardrail_budgetA guardrail budget is spent.No, until resets_at (null: never) or an admin raises it.
429A rate limit.Yes, after Retry-After if it's there.

The messages

Error 402, as reported
This request requires more credits, or fewer max_tokens. You requested up to 32000 tokens, but can only afford 15989. To increase, visit https://openrouter.ai/settings/credits and upgrade to a paid account

Not in OpenRouter's docs. This one, from a GitHub issue dated October 18, 2026, had limit_source set to openrouter_credits. The same opening sentence has also come with openrouter_key_limit (November 4, 2026), so check limit_source.

Error 403, as reported
Key limit exceeded (daily limit). Manage it using https://openrouter.ai/workspaces/default/keys/... $2.03 of $2.00 used; resets 2026-10-28T00:00:00.000Z.

OpenRouter's docs give only the words “Key limit exceeded”. From a GitHub issue dated October 27, 2026; we cut the key's ID from the link.

Error 403, from OpenRouter's docs
Budget limit exceeded (weekly limit). Contact your org admin. $52.00 of $50.00 used; resets 2026-10-12T00:00:00.000Z.

OpenRouter's example of a guardrail budget error. The metadata also has limit_usd, spend_usd and resets_at.

More in our guides to the “requires more credits” error and OpenRouter spending limits.

Sources: OpenRouter, Errors and Debugging, Limits, Capping Shared Agent Keys

Sort them in code

If you call more than one of these providers, this function covers all four. It takes the HTTP status and the JSON error body, and says yes when credits ran out or a spend limit was reached: errors that look like a rate limit, or that a retry loop might repeat, but that retrying won't fix. Handle everything else as you already do.

Python
# Errors that retrying won't fix: credits ran out or a spend limit was
# reached, so someone has to add credits, change a limit or wait for a reset.
OPENAI_BILLING = {
    "credit_balance_exhausted",
    "project_spend_limit_exceeded",
    "organization_spend_limit_exceeded",
    "organization_usage_limit_exceeded",
}
ANTHROPIC_400 = (
    "You have reached your specified API usage limits",
    "You have reached your specified workspace API usage limits",
    "Your credit balance is too low",
)
OPENROUTER_LIMITS = {
    "openrouter_credits",
    "openrouter_key_limit",
    "openrouter_workspace_budget",
    "openrouter_guardrail_budget",
}


def billing_stop(provider: str, status: int | None, body: object) -> bool:
    """provider: "openai", "anthropic", "gemini" or "openrouter".
    body: the parsed JSON error, with or without the outer "error" object."""
    if not isinstance(body, dict):
        body = {}
    error = body["error"] if isinstance(body.get("error"), dict) else body
    message = str(error.get("message") or "")
    if provider == "openai":
        return status == 429 and (
            error.get("code") in OPENAI_BILLING
            or error.get("type") == "insufficient_quota"
        )
    if provider == "anthropic":
        if status == 429:
            details = error.get("details")
            return isinstance(details, dict) and (
                details.get("error_code") == "enforced_spend_limit_reached"
            )
        return status == 402 or (
            status == 400 and message.startswith(ANTHROPIC_400)
        )
    if provider == "gemini":
        return status == 402 or (
            status == 429 and "spending cap" in message.lower()
        )
    if provider == "openrouter":
        metadata = error.get("metadata")
        source = metadata.get("limit_source") if isinstance(metadata, dict) else None
        if source in OPENROUTER_LIMITS:
            return True
        return status == 402 and source != "openrouter_in_flight_budget"
    return False
TypeScript
// Errors that retrying won't fix: credits ran out or a spend limit was
// reached, so someone has to add credits, change a limit or wait for a reset.
type Provider = "openai" | "anthropic" | "gemini" | "openrouter";
type Fields = Record<string, unknown>;

const OPENAI_BILLING = new Set([
  "credit_balance_exhausted",
  "project_spend_limit_exceeded",
  "organization_spend_limit_exceeded",
  "organization_usage_limit_exceeded",
]);
const ANTHROPIC_400 = [
  "You have reached your specified API usage limits",
  "You have reached your specified workspace API usage limits",
  "Your credit balance is too low",
];
const OPENROUTER_LIMITS = new Set([
  "openrouter_credits",
  "openrouter_key_limit",
  "openrouter_workspace_budget",
  "openrouter_guardrail_budget",
]);

function isFields(value: unknown): value is Fields {
  return typeof value === "object" && value !== null && !Array.isArray(value);
}

// body: the parsed JSON error, with or without the outer "error" object.
function billingStop(
  provider: Provider,
  status: number | undefined,
  body: unknown,
): boolean {
  const outer = isFields(body) ? body : {};
  const error = isFields(outer.error) ? outer.error : outer;
  const message = typeof error.message === "string" ? error.message : "";
  switch (provider) {
    case "openai":
      return (
        status === 429 &&
        (OPENAI_BILLING.has(String(error.code)) ||
          error.type === "insufficient_quota")
      );
    case "anthropic":
      if (status === 429) {
        return (
          isFields(error.details) &&
          error.details.error_code === "enforced_spend_limit_reached"
        );
      }
      return (
        status === 402 ||
        (status === 400 && ANTHROPIC_400.some((s) => message.startsWith(s)))
      );
    case "gemini":
      return (
        status === 402 ||
        (status === 429 && message.toLowerCase().includes("spending cap"))
      );
    case "openrouter": {
      const metadata = isFields(error.metadata) ? error.metadata : {};
      const source = metadata.limit_source;
      if (typeof source === "string" && OPENROUTER_LIMITS.has(source)) {
        return true;
      }
      return status === 402 && source !== "openrouter_in_flight_budget";
    }
  }
}

Where each SDK keeps the status and the body:

Python
# OpenAI SDK (openai.APIStatusError)
billing_stop("openai", error.status_code, error.body)
# The OpenAI SDK pointed at OpenRouter: name OpenRouter, not OpenAI
billing_stop("openrouter", error.status_code, error.body)
# Anthropic SDK (anthropic.APIStatusError)
billing_stop("anthropic", error.status_code, error.body)
# Google Gen AI SDK (google.genai.errors.APIError)
billing_stop("gemini", error.code, error.details)
# requests or httpx: name the provider you called
billing_stop("openrouter", response.status_code, response.json())
TypeScript
// OpenAI SDK (OpenAI.APIError)
billingStop("openai", error.status, error.error);
// The OpenAI SDK pointed at OpenRouter: name OpenRouter, not OpenAI
billingStop("openrouter", error.status, error.error);
// Anthropic SDK (Anthropic.APIError)
billingStop("anthropic", error.status, error.error);
// Google Gen AI SDK (ApiError): the response is JSON text in error.message
billingStop("gemini", error.status, JSON.parse(error.message));
// fetch: name the provider you called
billingStop("openrouter", response.status, await response.json());

We ran both versions against a local test server that sent most of the errors on this page (not Gemini's 403 or quota_exceeded, the Claude Code workspace 429 or billing_hard_limit_reached). It went through the OpenAI SDK (openai 3.50.0 and 7.56.0, for OpenAI and OpenRouter), the Anthropic SDK (anthropic 2.8.0 and @anthropic-ai/sdk 1.8.0), the Google Gen AI SDK (google-genai 3.3.0 and @google/genai 3.3.0), httpx and fetch. Every answer matched the rules above. Each provider's own guide has a check that reads its SDK's error object directly.

Sources: anthropic-sdk-python, Anthropic, Errors, OpenAI, Rate limits, openai-python, Retries, Google AI Studio, Troubleshooting

Where Billfuse fits

Billfuse is the tool we built for people who use several of these providers. It doesn't prevent any of these errors.

More guides

It's free while Billfuse is in early access. You can try it with sample data first, no sign-up needed.