← Back to Skills Marketplace
liflife

deepseek-balance

by lxf · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
61
Downloads
1
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install deepseek-balance
Description
查询并返回 DeepSeek API 账户余额、赠送余额、充值余额及账户可用状态,需配置 DEEPSEEK_API_KEY 或 ANTHROPIC_AUTH_TOKEN。
README (SKILL.md)

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
Usage Guidance
Review this skill before installing. It should be changed to use only DEEPSEEK_API_KEY for DeepSeek balance checks. If you install it as-is, ensure ANTHROPIC_AUTH_TOKEN is not present in the environment where the agent may run the command.
Capability Analysis
Type: OpenClaw Skill Name: deepseek-balance Version: 1.0.0 The skill is designed to query the DeepSeek API account balance using a Bash script and Python for JSON parsing. It targets the official DeepSeek API endpoint (api.deepseek.com) and handles authentication via environment variables (DEEPSEEK_API_KEY or ANTHROPIC_AUTH_TOKEN) without any evidence of data exfiltration, obfuscation, or malicious intent in SKILL.md.
Capability Tags
requires-sensitive-credentials
Capability Assessment
Purpose & Capability
A DeepSeek balance lookup is coherent with the stated purpose, but automatically falling back to ANTHROPIC_AUTH_TOKEN is not clearly justified for a DeepSeek API call.
Instruction Scope
The script and one-line command automatically choose ANTHROPIC_AUTH_TOKEN when DEEPSEEK_API_KEY is absent, without a per-use confirmation that this unrelated credential should be sent.
Install Mechanism
This is an instruction-only skill with no install script or bundled code files; the supplied commands are visible in SKILL.md.
Credentials
The registry metadata declares no env vars or primary credential even though SKILL.md requires sensitive credentials and references ANTHROPIC_AUTH_TOKEN.
Persistence & Privilege
No background persistence or privileged installation is shown; the ~/.bashrc text is only an example for user-managed environment setup.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install deepseek-balance
  3. After installation, invoke the skill by name or use /deepseek-balance
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
deepseek-balance 1.0.0 - Initial release. - Provides a Bash script to check DeepSeek API account balance. - Supports environment variables DEEPSEEK_API_KEY (primary) and ANTHROPIC_AUTH_TOKEN (fallback). - Shows detailed output for normal, missing key, authentication failure, rate limit, and server error scenarios. - Includes both readable script and a quick one-line command for fast terminal use.
Metadata
Slug deepseek-balance
Version 1.0.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

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.

💬 Comments