DeepSeek API 402 "Insufficient Balance": whose balance, how to tell, and what to do
DeepSeek's API is prepaid. You add money, requests draw it down, and when it reaches zero every request answers Insufficient Balance with HTTP 402 until money is added. That is simple when the account is yours. It is confusing when the key belongs to a product you use: OpenCode Zen and Go, agent frameworks with a built-in DeepSeek provider, and any tool that bundles "free" DeepSeek access are calling DeepSeek with their key, and when their account runs dry, you get an error about a balance you have never seen. Most of the GitHub reports for this string are the second case.
Last verified September 21, 2026 against DeepSeek docs: error codes, DeepSeek docs: models and pricing, anomalyco/opencode #35142: "insufficient balance in free model" (July 3, 2026), anomalyco/opencode #28129: 11 of 12 Go models fail with Insufficient Balance (May 2026), anomalyco/opencode #27598: 402 on an active Go subscription · 4 min read
| Provider | DeepSeek API (api.deepseek.com), directly or through a product that uses its own DeepSeek key |
| HTTP status | 402 Payment Required |
| Message | Insufficient Balance |
| Cause | The prepaid balance on the DeepSeek account that owns the key is zero. DeepSeek has no free tier and no post-paid billing |
| How common | About 286,000 files on GitHub call api.deepseek.com, and 9,300 contain code that handles this exact string (GitHub code search, September 21, 2026) |
| Can you wait it out? | No. Nothing resets. The error ends when someone adds funds to that account |
- Your key, your code: the account is empty. Add funds on the DeepSeek platform; the error clears within a minute. Retrying before that does nothing.
- Inside OpenCode Zen or Go, or another app: the empty account is theirs. Check their status or GitHub issues; everyone sees it at once. Either wait for them, or add a provider whose balance is yours.
- In a fallback chain: treat 402 as final for that provider and move to the next one. It is not a transient error.
What the error looks like
HTTP/1.1 402 Payment Required
{"error": {"message": "Insufficient Balance", ...}}
# the same error as tools surface it:
AI_APICallError: Insufficient Balance (OpenCode, Vercel AI SDK apps)
openai.APIStatusError: Error code: 402 - {'error': {'message': 'Insufficient Balance', ...}} (Python SDK)The message is the only stable part of the body; the other fields differ between DeepSeek's OpenAI-format and Anthropic-format endpoints. The status is 402, which the OpenAI SDKs do not map to a named exception: Python raises a plain APIStatusError with status_code == 402, and the SDK does not retry it. Frameworks that classify errors by name often file it under "unknown" or "malformed request", which is how it ends up logged as something it is not.
Whose balance is empty
| Where you saw it | Whose balance is empty | Can you fix it yourself? |
|---|---|---|
Your own code calling api.deepseek.com with your key | Yours | Yes: add funds on the DeepSeek platform. The error clears within a minute of the payment |
| OpenCode Zen or Go, including the free models | OpenCode's account at DeepSeek | No. Every user gets the error at the same time; it ends when OpenCode tops up or moves the model |
| Another app or agent with a built-in DeepSeek provider | Whoever holds the key the app uses | Only if the key is yours. Check the app's provider settings |
| An agent framework fallback chain (Hermes, oh-my-opencode and similar) | The provider that was tried first | Configure the chain to treat 402 as final for that provider and move on |
The tell for the reseller case is timing. If the error started for you at the same minute it started for everyone else, and the app's own paid models fail alongside the free ones, it is the reseller's account. On July 3, 2026 OpenCode's free DeepSeek V4 Flash returned Insufficient Balance for every user at once until a maintainer posted "should be working now"; in May 2026, 11 of the 12 OpenCode Go models did the same for sub-agent calls.
Fix 1: if it is your account, add funds
Sign in to the DeepSeek platform, open the balance page and top up. Requests start succeeding as soon as the payment posts. If you are not sure the key is yours, this check settles it:
curl -s https://api.deepseek.com/chat/completions -H "Authorization: Bearer $DEEPSEEK_API_KEY" -H "Content-Type: application/json" \
-d '{"model":"deepseek-flash","messages":[{"role":"user","content":"Say ok"}],"max_tokens":5}' -w "\nHTTP %{http_code}\n"
# 402 Insufficient Balance -> add funds. 401 Authentication Fails -> the key is wrong. Both are final; neither is fixed by retrying.Two habits prevent the next one. Set a balance alert if your provider offers one, and treat 402 in code as a stop signal: no retry loop, no backoff, an alert to a human.
Fix 2: if it is a reseller's account, bring your own provider
You cannot top up someone else's DeepSeek account, and their "free" model will come back when they do. In the meantime, most of these tools accept a provider you control. OpenCode takes any OpenAI-compatible endpoint in opencode.json (our guide, with a config block that puts DeepSeek V4 on US GPUs next to Go); Claude Code, Codex and the others have equivalents on the integrations page. With your own provider, the only balance that can run out is yours, and you will know about it first.
Fix 3: fail over to the same model on another balance
DeepSeek V4 Flash and V4 Pro are open-weight models, so a second endpoint can serve the same model on a different account. Since 402 is final, the fallback should happen on the first one:
import os
from openai import OpenAI, APIStatusError
deepseek = OpenAI(base_url="https://api.deepseek.com", api_key=os.environ["DEEPSEEK_API_KEY"])
backup = OpenAI(base_url="https://api.inferenceapis.com/v1", api_key=os.environ["INFERENCEAPIS_API_KEY"])
def chat(messages, **kw):
try:
return deepseek.chat.completions.create(model="deepseek-flash", messages=messages, **kw)
except APIStatusError as e:
if e.status_code != 402:
raise
# Out of prepaid balance at DeepSeek. Retrying will not help; the same open-weight model elsewhere will.
return backup.chat.completions.create(model="deepseek-flash", messages=messages, **kw)The ids deepseek-flash, deepseek-v4-pro, deepseek-chat and deepseek-reasoner are all accepted here, so the model string does not change. New accounts get $1 of starter credit once the email address is confirmed, which covers a few hundred Flash requests, and there is no subscription; when the balance runs out, our own 402 says so and links the billing page.
What it costs, side by side
| Per 1M tokens | DeepSeek, deepseek-flash (off-peak / peak) | Inference APIs, DeepSeek V4 Flash | Inference APIs, DeepSeek V4.1 Flash |
|---|---|---|---|
| Input, cache miss | $0.15 / $0.30 | $0.19 | $0.40 |
| Input, cache hit | $0.003 / $0.006 | $0.04 | $0.01 |
| Output | $0.60 / $1.20 | $0.38 | $1.60 |
| Model served | DeepSeek-V4.1-Flash | DeepSeek-V4-Flash-0731 | DeepSeek-V4.1-Flash |
| Whose balance | Yours, prepaid at DeepSeek | Yours, prepaid here; $1 starter credit on signup | Same |
| Where it runs | DeepSeek, China | Together AI GPUs, United States | Together AI GPUs, United States |
DeepSeek's figures are from its pricing page on September 21, 2026 and change by time of day; ours are flat. On price, DeepSeek off-peak wins. What you are paying for elsewhere is a balance nobody else can drain, a US location, zero retention (/trust), and no concurrency cap (the 429 entry).
Frequently asked questions
I have an active OpenCode Go subscription. Why does a model say Insufficient Balance?
Your Go subscription is a quota inside OpenCode. The model behind it runs on OpenCode's own DeepSeek account, and when that account is empty the request fails regardless of your quota. The reports on GitHub (#27598, #28129, #35142) all show this shape: active subscription, 402 from the provider, fixed when OpenCode topped up.
Does DeepSeek have a free tier?
No. The API is prepaid. Products that offer "free DeepSeek" are paying DeepSeek themselves, which is why their free models are the first to return this error when their account runs low.
Will retrying with backoff eventually work?
Not until funds are added. 402 is not a capacity or rate error. Retry loops that treat it like a 429 burn time and, in agent frameworks, can kill sub-agents that would have succeeded on another provider.
Is the DeepSeek model on Inference APIs the same one?
Yes: the public DeepSeek V4 Flash (0731), V4.1 Flash and V4 Pro (0813) weights on Together AI GPUs in the United States. Thinking is on by default as at DeepSeek and off with reasoning_effort: "none".
Where Inference APIs fits
The fallback in fix 3 is what we sell: DeepSeek V4 Flash, V4.1 Flash and V4 Pro on GPUs in the United States, billed per token from a balance that is yours alone. The model ids you already send work unchanged, and a new account starts with $1 of credit. When it runs out you get our own 402 insufficient_balance, with a link to add funds, and nobody else's usage can empty it. We are not cheaper than DeepSeek off-peak; the table above shows both.
Something changed or wrong? Tell us and we will re-verify the entry.
