Skip to main content
Watch: I Built an AI App Without Leaving Databricks

OpenRouter error

OpenRouter 402 payment_required: what it means and how to fix it

Error message
402 payment_required

Retry? NoLast verified 4 documented fixes2 sources

What it means

The account or API key has insufficient credits. error.metadata.limit_source is openrouter_credits when the balance cannot cover the request, or openrouter_key_limit when the key's credit limit is exhausted. A negative balance can cause 402 even for free models.

Causes

  • Account balance at or below zero
  • Per-key credit limit exhausted
  • Balance cannot cover the request's estimated cost

How to fix it

  1. Fix 1.

    Check error.metadata.limit_source, then add credits to bring the balance above zero.

  2. Fix 2.

    If the key's limit_remaining is exhausted, raise the key's credit limit or wait for it to reset (see limit_reset).

  3. Fix 3.

    Reduce the request size (fewer input tokens or a lower max_tokens), and monitor with GET /api/v1/key.

  4. Fix 4.

    A 402 without a Retry-After header is not a wait-and-retry case.

More OpenRouter errors

All 32 OpenRouter errors

HTTP 402 at other providers

FAQ

What does the OpenRouter error "402 payment_required" mean?

The account or API key has insufficient credits. error.metadata.limit_source is openrouter_credits when the balance cannot cover the request, or openrouter_key_limit when the key's credit limit is exhausted. A negative balance can cause 402 even for free models.

How do I fix OpenRouter "402 payment_required"?

There are 4 documented fixes. Start with the first: Check error.metadata.limit_source, then add credits to bring the balance above zero.

Should I retry OpenRouter "402 payment_required"?

No. The official docs treat this error as not retryable: fix the cause before sending the request again.

Which other AI APIs return HTTP 402?

Per their official error docs: Anthropic API (402 billing_error), Cohere API (402 Payment Required), DeepSeek API (402 - Insufficient Balance), Gemini API (402 payment_required; 402 RESOURCE_EXHAUSTED), Mistral API (402 Payment required).

Sources

Last verified against 2 sources: OpenRouter's official docs and official SDK repositories.

Newsletter

Know when the APIs change

One email per week. New model releases, API changes, what broke, and how developers are working around it.