Blog

DeepSeek API "402 Insufficient Balance": What It Means and How to Fix It

Short answer

402 Insufficient Balance means the DeepSeek account behind your API key has run out of balance. DeepSeek's error code page lists it as 402 - Insufficient Balance and says to check your balance and add funds on the Top up page.

Retrying won't help. Every request with a key from that account fails until the balance is topped up. Check the balance with GET https://api.deepseek.com/user/balance, top up, and make your code stop retrying on 402.

If you'd rather keep one prepaid balance for DeepSeek, Claude, GPT and Gemini, you can call the same DeepSeek model IDs through TeamoRouter with the OpenAI SDK. It's pay-per-use from $5, and you can top up by card or with USDT.

What the error looks like

This is a real response from the OpenAI Python SDK pointed at DeepSeek, from a public GitHub issue filed in March 2025. The reporter fixed it by topping up their DeepSeek account:

text
Error code: 402 - {'error': {'message': 'Insufficient Balance', 'type': 'unknown_error', 'param': None, 'code': 'invalid_request_error'}}

Through LiteLLM, the same error shows up as DeepseekException - Insufficient Balance (chidionyema/idp#6499). Tools such as Claude Code or Codex connected to DeepSeek's own endpoints draw on the same balance, so they stop working at the same time.

402 vs. other DeepSeek errors

DeepSeek's error code page lists these. Only some of them get better with retries:

Code Meaning Retry?
400 Invalid Format The request body is malformed No, fix the request
401 Authentication Fails Wrong API key No, check the key
402 Insufficient Balance The account has run out of balance No, top up
422 Invalid Parameters A parameter is invalid No, fix the parameter
429 Rate Limit Reached Too fast, or over a concurrency or QPS limit Yes, after pacing requests
500 Server Error Problem on DeepSeek's side Yes, after a brief wait
503 Server Overloaded High traffic Yes, after a brief wait

How to fix it on DeepSeek's side

  1. Check the balance. DeepSeek's balance API tells you whether the account can make calls:
bash
curl https://api.deepseek.com/user/balance \
  -H "Authorization: Bearer $DEEPSEEK_API_KEY"

is_available is false when the balance can't cover API calls. total_balance is split into granted_balance (granted balance that hasn't expired) and topped_up_balance.

  1. Top up. Add funds on the Top up page. If you have more than one DeepSeek account, check that the key belongs to the account you topped up.
  2. Know which balance goes first. DeepSeek's pricing page says fees are taken from the granted balance first when both exist. If you were living on a grant, it can run out or expire before you notice.
  3. Expect faster spending at peak times. DeepSeek's off-peak rates are half the peak rates. Peak hours are 01:00–04:00 and 06:00–10:00 UTC, Monday to Friday, excluding Chinese public holidays, so the same workload drains the balance faster then.
  4. Stop retrying on 402. The OpenAI Python SDK only retries connection errors, 408, 409, 429 and 5xx responses by default (openai-python README), so a 402 surfaces right away. Agent frameworks often add their own retry loops; in the OpenManus issue above, the same 402 was logged five times within about 12 seconds. Handle it explicitly:
python
import openai
from openai import OpenAI

client = OpenAI(api_key="sk-...", base_url="https://api.deepseek.com")

try:
    resp = client.chat.completions.create(
        model="deepseek-flash",
        messages=[{"role": "user", "content": "Hello"}],
    )
except openai.APIStatusError as e:
    if e.status_code == 402:
        # Not transient: alert someone and stop sending requests until topped up.
        raise RuntimeError("DeepSeek balance is empty") from e
    raise
  1. Watch the balance. Poll /user/balance from a scheduled job and alert before total_balance reaches zero, so a production service doesn't stop on an empty balance.

Call DeepSeek through TeamoRouter instead

TeamoRouter is an API gateway with one key for DeepSeek, Claude, GPT and Gemini. It's OpenAI-compatible, so code that already calls DeepSeek with the OpenAI SDK only needs a different base URL and key. The DeepSeek model IDs are the same: deepseek-flash and deepseek-v4-pro. You pay per use from one prepaid balance, with no subscription.

  1. Create an API key in the TeamoRouter console. It starts with sk-teamo-.
  2. Top up from $5. The top-up dialog takes cards. You can also click Pay with crypto and pay with USDT, USDC or ETH from Binance, OKX or any exchange app — the checkout shows which networks your amount supports (BEP20 works from $5). You don't need a wallet extension. Step by step: Pay with USDT.
  3. Change the base URL and key:
python
from openai import OpenAI

client = OpenAI(
    api_key="sk-teamo-...",
    base_url="https://api.teamorouter.com/v1",
)

resp = client.chat.completions.create(
    model="deepseek-v4-pro",
    messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)

GET /v1/models lists every model ID you can use with the key. Tool-by-tool setup (OpenCode, Cline, Cherry Studio, Codex) is in the DeepSeek V4 Pro integration guide.

One thing doesn't change: a prepaid balance can run out on TeamoRouter too. It returns 402 insufficient_balance when your balance can't cover a request, and long-context requests reserve their maximum possible cost first (API integration guide). The difference is that one balance covers all four model families.

FAQ

Is 402 Insufficient Balance a rate limit? No. Rate limiting is 429. A 402 means the balance is empty, and waiting doesn't fix it.

I topped up and still get 402. Why? Call /user/balance with the same key your app uses. If is_available is still false, the key probably belongs to a different account from the one you topped up.

Do granted balances expire? DeepSeek's balance API reports granted_balance as the granted balance that hasn't expired, so expired grants no longer count toward total_balance.

Will my OpenAI SDK code work with TeamoRouter? Yes. Change base_url to https://api.teamorouter.com/v1 and the key to your TeamoRouter key. The DeepSeek model IDs stay the same.

Next steps

Ready to connect?Log in · top up · create an API key — three steps to start.