> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ruapi.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# DeepSeek API 报错 402「Insufficient Balance」：什么意思、怎么解决

> DeepSeek API 报错「402 Insufficient Balance」（在代码、Cline、Cursor 等工具里出现）说明 DeepSeek 账户余额用完了。怎么查余额、怎么充值，充不进去时怎么办：通过 RuAPI 接入同样的 DeepSeek 模型，用 USDT 付款。

**简单说：** 这个报错是 DeepSeek 自己返回的，意思是这个密钥所属账户的余额用完了。重发请求没用，要给 DeepSeek 账户充值。充不进去的话（卡被拒、PayPal 用不了），可以通过 RuAPI 接入同样的 DeepSeek 模型：换密钥和地址就行，用 USDT 或外国银行的卡付款。

## 报错长什么样

返回码 **402**，内容里有 `Insufficient Balance`。比如 Python（OpenAI SDK）里：

```text theme={null}
openai.APIStatusError: Error code: 402 - {'error': {'message': 'Insufficient Balance', 'type': 'unknown_error', 'param': None, 'code': 'invalid_request_error'}}
```

Cline、Roo Code、Claude Code 等工具里一般显示得短一些：

```text theme={null}
API Error: 402 Insufficient Balance
```

`type` 和 `code` 这两个字段不同版本会不一样，认准返回码 **402** 和 `Insufficient Balance` 这几个字就行。

## 为什么会这样

* **余额用完了。** DeepSeek 的[错误码说明](https://api-docs.deepseek.com/quick_start/error_codes)写得很清楚：402 就是账户里没钱了，要查余额、去充值。
* **赠送余额过期了。** DeepSeek 有带有效期的赠送余额。赠送的过期了、自己充的钱又没有，也会报这个错。
* **花钱的不只是你的代码。** 用这个密钥的所有工具（编程助手、机器人、脚本）都从同一个余额里扣。编程助手上下文长，花得比想象中快。

## 怎么查余额

在 [platform.deepseek.com](https://platform.deepseek.com) 后台看，或者调 [GET /user/balance](https://api-docs.deepseek.com/api/get-user-balance)：

```bash theme={null}
curl https://api.deepseek.com/user/balance \
  -H "Authorization: Bearer $DEEPSEEK_API_KEY"
```

返回 `"is_available": false` 说明余额不够发请求，`total_balance` 是还剩多少。

## 可以怎么办

| 情况 | 怎么办 |
| - | - |
| 能给 DeepSeek 付款 | 去[充值页](https://platform.deepseek.com/top_up)充值。按 [DeepSeek 常见问题](https://api-docs.deepseek.com/faq)的说法，可以用 PayPal、银行卡、支付宝、微信支付 |
| 你的银行卡被拒、所在地区用不了 PayPal | 通过 RuAPI 接入同样的 DeepSeek 模型，步骤见下。不需要 DeepSeek 账号 |
| 类似的报错是 RuAPI 返回的 | RuAPI 余额不足返回的是 **403**，不是 402，见[错误码](https://docs.ruapi.ai/zh/errors.md) |

付款方式的详细说明见 [DeepSeek API 付款](https://docs.ruapi.ai/zh/pay-deepseek-api-russia.md)。

## 通过 RuAPI 接入 DeepSeek

**1. 注册**

在 [www.ruapi.ai](https://www.ruapi.ai/?lng=zh-CN\&utm_source=docs\&utm_campaign=zh-deepseek-402-insufficient-balance) 注册，邮箱、Google 或 Yandex 都行。

**2. 充值**

控制台 →「**钱包管理**」：USDT 或 USDC（TRC20 / BEP20 / Polygon；USDT 还可以走 TON），5 USDT 起。还没有 USDT 的话，[用 SBP 拿卢布买](https://docs.ruapi.ai/zh/buy-usdt.md)。外国银行的卡（Visa / Mastercard）也收。

**3. 密钥**

控制台 →「**令牌管理**」→「**添加令牌**」，拿到一串 `sk-...`。

**4. 换密钥和地址**

在代码或工具设置里，把地址换成 `https://www.ruapi.ai/v1`，密钥换成 RuAPI 的密钥，模型填 `deepseek-flash` 或 `deepseek-v4-pro`。

```python OpenAI SDK theme={null}
from openai import OpenAI

client = OpenAI(
    api_key="sk-你的RuAPI密钥",
    base_url="https://www.ruapi.ai/v1",
)

resp = client.chat.completions.create(
    model="deepseek-flash",  # 或 deepseek-v4-pro
    messages=[{"role": "user", "content": "你好！"}],
)
print(resp.choices[0].message.content)
```

```bash curl theme={null}
curl https://www.ruapi.ai/v1/chat/completions \
  -H "Authorization: Bearer sk-你的RuAPI密钥" \
  -H "Content-Type: application/json" \
  -d '{"model": "deepseek-flash", "messages": [{"role": "user", "content": "你好！"}]}'
```

`deepseek-flash` 和 `deepseek-v4-pro` 有什么区别、选哪个，见 [DeepSeek API](https://docs.ruapi.ai/zh/deepseek-api.md)。Cline、Roo Code、Cursor 等工具怎么配置，见接入工具部分，比如 [Cline](https://docs.ruapi.ai/zh/integrations/cline.md)。

## 常见问题

> [accordion] 换一个新的 DeepSeek 密钥有用吗？
>
> 没用。余额是整个账户共用的，新密钥也从同一个余额里扣。要么充值，要么换一家。

> [accordion] 要不要重发请求？
>
> 不要。余额没充上之前，每次重发都还是 402。如果你的工具会自动重试，把 402 的重试关掉。

> [accordion] 是同样的 DeepSeek 模型吗？
>
> 是。通过 RuAPI 用的就是 DeepSeek 的模型（`deepseek-flash` 和 `deepseek-v4-pro`），协议同样是 OpenAI 兼容的。

> [accordion] 需要 VPN 吗？
>
> 不需要。RuAPI 的网站和 API 都能直接打开。

## 接下来

> [card] [DeepSeek API](https://docs.ruapi.ai/zh/deepseek-api.md)
>
> 模型、能力和接入方法。

> [card] [如何用卢布购买 USDT](https://docs.ruapi.ai/zh/buy-usdt.md)
>
> SBP、Sberbank、T-Bank，一步步来。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.