← 返回 Skills 市场
61
总下载
1
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install deepseek-balance
功能描述
查询并返回 DeepSeek API 账户余额、赠送余额、充值余额及账户可用状态,需配置 DEEPSEEK_API_KEY 或 ANTHROPIC_AUTH_TOKEN。
使用说明 (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
安全使用建议
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.
功能分析
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.
能力标签
能力评估
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.
如何使用
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install deepseek-balance - 安装完成后,直接呼叫该 Skill 的名称或使用
/deepseek-balance触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
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.
元数据
常见问题
deepseek-balance 是什么?
查询并返回 DeepSeek API 账户余额、赠送余额、充值余额及账户可用状态,需配置 DEEPSEEK_API_KEY 或 ANTHROPIC_AUTH_TOKEN。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 61 次。
如何安装 deepseek-balance?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install deepseek-balance」即可一键安装,无需额外配置。
deepseek-balance 是免费的吗?
是的,deepseek-balance 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
deepseek-balance 支持哪些平台?
deepseek-balance 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 deepseek-balance?
由 lxf(@liflife)开发并维护,当前版本 v1.0.0。
推荐 Skills