In this guide
What does the error mean?
OpenRouter’s errors page describes a 402 as Your account or API key has insufficient credits. Add more credits and retry the request. The error type is payment_required.
The response body says which limit you hit. Look at error.metadata.limit_source.
| limit_source | What happened | Retry? |
|---|---|---|
openrouter_credits | Your balance can’t cover the request, or one request costs more than your whole in-flight budget | Not until you add credits or shrink the request |
openrouter_in_flight_budget | Running and recently finished requests filled the in-flight budget | Yes, after the Retry-After header |
openrouter_key_limit | The API key’s own credit limit is used up | Not until the key’s limit resets or goes up |
Codes as listed on OpenRouter’s Limits page, checked November 5, 2026.
The in-flight case carries the message This request would exceed your available credits given your current in-flight requests. It’s the only 402 worth retrying unchanged.
Your AI bill, with ernd
What could your AI bill earn?
Enter an amount from $0 to $100,000,000.
back a year at 4%
For US companies. No annual fee. Illustration based on AI vendor spend only. Rewards are points redeemable as cash back.
How do you fix it?
- Log
error.metadata.limit_sourceandremedy_hint. Branch your code on the source and leave the hint for people reading logs. - For
openrouter_credits, add credits at openrouter.ai/settings/credits until the balance is above zero. - If the balance is fine, lower
max_tokensor trim the prompt. The up-front estimate counts input tokens plus every tokenmax_tokensallows, or a fixed cap whenmax_tokensisn’t set. - For
openrouter_in_flight_budget, wait forRetry-Afterand send it again. More credits also raise this budget, up to a ceiling. - For a key limit, raise the key’s credit limit in the dashboard or wait for its daily, weekly or monthly reset at midnight UTC. Some key and budget limits come back as a 403 with
Key limit exceededinstead, so check both codes.
How do you keep it from coming back?
Turn on auto top-up on the credits page so the balance refills below a threshold. Then set the low balance alert. It’s on every plan, goes out by email and defaults to $100.
Put a credit limit on every key, especially ones an agent uses. OpenRouter recommends it, since a key with no limit can spend the whole balance, auto top-ups included.
You can also check GET /api/v1/key from your own monitoring to see limit_remaining before requests fail. ernd is a card for AI spend that earns 4% back, a good fit for whatever pays for the top-ups.
The ernd card
Once your billing is back on track.
The card earns rewards on AI spend. It does not bypass provider quotas, fix account restrictions or change provider prices.
Request your cardThe ernd card is a credit card for US companies, with partners across the AI stack built in.
Common questions.
Why do I get a 402 on OpenRouter with money in my account?
OpenRouter estimates each paid request's cost up front, counting the full max_tokens. If that estimate doesn't fit your balance or your in-flight budget, it rejects the request before it reaches a provider. Lower max_tokens or wait for running requests to settle.
Can a negative OpenRouter balance block free models?
Yes. OpenRouter's limits page says a negative balance can cause errors even on free models, and adding credits to get back above zero fixes it.
Do OpenRouter SDKs retry a 402 on their own?
No. None of the OpenAI, Anthropic, Vercel AI or OpenRouter SDKs retries a 402 automatically. For the in-flight case, catch it, read Retry-After and retry yourself.
Sources & methodology
Checked . Providers change prices and terms; the linked official page is the final word. This guide is published by ernd.
ernd is run by Provenance Research Inc.
