/install deepseek-balance
name: deepseek-balance\r description: 查询 DeepSeek API 账户余额。当用户询问 DeepSeek 余额、配额、剩余额度时使用此技能。\r \r
DeepSeek 余额查询技能\r
\r
环境变量配置\r
脚本需要 API Key。优先检查 DEEPSEEK_API_KEY,若未设置则自动回退检查 ANTHROPIC_AUTH_TOKEN。\r
\r
执行脚本\r
直接运行以下 Bash 脚本查询余额:\r \r
#!/bin/bash\r
\r
# 1. 获取 API Key (优先使用 DEEPSEEK_API_KEY,兼容 ANTHROPIC_AUTH_TOKEN)\r
API_KEY="${DEEPSEEK_API_KEY:-$ANTHROPIC_AUTH_TOKEN}"\r
\r
if [ -z "$API_KEY" ]; then\r
echo "❌ 错误: 环境变量 DEEPSEEK_API_KEY 或 ANTHROPIC_AUTH_TOKEN 未设置"\r
echo ""\r
echo "请运行以下命令设置(以 DEEPSEEK_API_KEY 为例):"\r
echo "export DEEPSEEK_API_KEY='your-deepseek-api-key'"\r
echo ""\r
echo "Linux/macOS 永久设置:"\r
echo "echo 'export DEEPSEEK_API_KEY=\"your-deepseek-api-key\"' >> ~/.bashrc"\r
echo "source ~/.bashrc"\r
echo ""\r
echo "Windows (PowerShell): \$env:DEEPSEEK_API_KEY='your-deepseek-api-key'"\r
exit 1\r
fi\r
\r
echo "🔍 正在查询 DeepSeek API 余额..."\r
\r
# 2. 发送请求并捕获 HTTP 状态码与响应体\r
RESPONSE=$(curl -s -L -w "\
%{http_code}" -X GET 'https://api.deepseek.com/user/balance' \\r
-H 'Accept: application/json' \\r
-H "Authorization: Bearer $API_KEY")\r
\r
# 分离 HTTP 状态码和 Body\r
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)\r
BODY=$(echo "$RESPONSE" | sed '$d')\r
\r
# 3. 处理响应\r
if [ "$HTTP_CODE" -eq 200 ] 2>/dev/null; then\r
# 使用 Python 解析 JSON,比 grep/cut 更稳健,支持格式化输出\r
echo "$BODY" | python3 -c "\r
import sys, json\r
\r
try:\r
data = json.load(sys.stdin)\r
if data.get('is_available'):\r
balance = data.get('balance_infos', [{}])[0]\r
currency = balance.get('currency', 'CNY')\r
total = balance.get('total_balance', '0.00')\r
granted = balance.get('granted_balance', '0.00')\r
topped = balance.get('topped_up_balance', '0.00')\r
\r
print('')\r
print('✅ DeepSeek API 余额信息')\r
print(f'💰 货币: {currency}')\r
print(f'💰 总余额: {total} {currency}')\r
print(f'🎁 赠送余额: {granted} {currency}')\r
print(f'💳 充值余额: {topped} {currency}')\r
print(f'📊 账户状态: 可用')\r
else:\r
print('⚠️ DeepSeek API 账户无可用余额')\r
except Exception as e:\r
print(f'❌ JSON 解析失败: {e}', file=sys.stderr)\r
sys.exit(1)\r
"\r
elif [ "$HTTP_CODE" -eq 401 ]; then\r
echo "❌ 认证失败: API Key 无效或已过期"\r
echo "请检查 API Key 是否正确"\r
elif [ "$HTTP_CODE" -eq 429 ]; then\r
echo "❌ 请求过于频繁,请稍后重试"\r
elif [ "$HTTP_CODE" -eq 500 ] || [ "$HTTP_CODE" -eq 503 ]; then\r
echo "❌ DeepSeek 服务异常,请稍后重试"\r
else\r
echo "❌ 查询失败 (HTTP $HTTP_CODE)"\r
echo "$BODY"\r
fi\r
```\r
\r
## 快速执行(一行命令)\r
适用于终端快速检查,无需创建脚本文件,自动兼容环境变量:\r
\r
```bash\r
[ -z "${DEEPSEEK_API_KEY:-$ANTHROPIC_AUTH_TOKEN}" ] && echo "⚠️ 请先设置 DEEPSEEK_API_KEY 或 ANTHROPIC_AUTH_TOKEN" || curl -s -X GET 'https://api.deepseek.com/user/balance' -H "Authorization: Bearer ${DEEPSEEK_API_KEY:-$ANTHROPIC_AUTH_TOKEN}" | python3 -c "import sys,json; d=json.load(sys.stdin); b=d.get('balance_infos',[{}])[0] if d.get('is_available') else None; print(f\"✅ 总余额: {b['total_balance']} {b['currency']}\
🎁 赠送: {b['granted_balance']}\
💳 充值: {b['topped_up_balance']}\") if b else print('⚠️ 无可用余额')"\r
```\r
\r
## 输出示例\r
\r
**成功时:**\r
```\r
🔍 正在查询 DeepSeek API 余额...\r
\r
✅ DeepSeek API 余额信息\r
💰 货币: CNY\r
💰 总余额: 110.00 CNY\r
🎁 赠送余额: 10.00 CNY\r
💳 充值余额: 100.00 CNY\r
📊 账户状态: 可用\r
```\r
\r
**未设置 API Key 时:**\r
```\r
❌ 错误: 环境变量 DEEPSEEK_API_KEY 或 ANTHROPIC_AUTH_TOKEN 未设置\r
请运行以下命令设置(以 DEEPSEEK_API_KEY 为例):\r
export DEEPSEEK_API_KEY='your-deepseek-api-key'\r
...\r
```\r
\r
**认证失败时:**\r
```\r
❌ 认证失败: API Key 无效或已过期\r
请检查 API Key 是否正确\r
```\r
- Make sure OpenClaw is installed (local or Docker)
- Run the install command in chat:
/install deepseek-balance - After installation, invoke the skill by name or use
/deepseek-balance - Provide required inputs per the skill's parameter spec and get structured output
What is deepseek-balance?
查询并返回 DeepSeek API 账户余额、赠送余额、充值余额及账户可用状态,需配置 DEEPSEEK_API_KEY 或 ANTHROPIC_AUTH_TOKEN。 It is an AI Agent Skill for Claude Code / OpenClaw, with 61 downloads so far.
How do I install deepseek-balance?
Run "/install deepseek-balance" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.
Is deepseek-balance free?
Yes, deepseek-balance is completely free, licensed under MIT-0. You can download, install and use it at no cost.
Which platforms does deepseek-balance support?
deepseek-balance is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).
Who created deepseek-balance?
It is built and maintained by lxf (@liflife); the current version is v1.0.0.