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

OpenRouter error

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

Error message
402 in_flight_budget_exhausted

Retry? YesLast verified 2 documented fixes2 sources

What it means

Your running and recently completed paid requests already fill your in-flight spending budget, so the request is rejected before reaching a provider even though the balance is positive. metadata.limit_source is openrouter_in_flight_budget. This is transient and the response includes a Retry-After header.

Causes

  • Many concurrent paid requests whose estimated cost fills the in-flight budget
  • Recent request costs still settling

How to fix it

  1. Fix 1.

    Wait for the Retry-After header and retry explicitly; SDKs do not retry 402 on their own.

    Snippet
    const res = await fetch('https://openrouter.ai/api/v1/chat/completions', { ... });
    if (res.status === 429 || res.status === 503 || res.status === 402) {
      const retryAfter = Number(res.headers.get('Retry-After'));
      if (Number.isFinite(retryAfter) && retryAfter > 0) {
        await new Promise((r) => setTimeout(r, retryAfter * 1000));
        // retry the request
      }
    }
  2. Fix 2.

    Adding credits raises the in-flight budget, up to a capped ceiling.

More OpenRouter errors

All 32 OpenRouter errors

HTTP 402 at other providers

FAQ

What does the OpenRouter error "402 in_flight_budget_exhausted" mean?

Your running and recently completed paid requests already fill your in-flight spending budget, so the request is rejected before reaching a provider even though the balance is positive. metadata.limit_source is openrouter_in_flight_budget. This is transient and the response includes a Retry-After header.

How do I fix OpenRouter "402 in_flight_budget_exhausted"?

There are 2 documented fixes. Start with the first: Wait for the Retry-After header and retry explicitly; SDKs do not retry 402 on their own.

Should I retry OpenRouter "402 in_flight_budget_exhausted"?

Yes. The official docs treat this error as retryable.

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.