--- name: llm-provider-billing description: Use when 用户问 LLM 余额/还有多少钱/够不够跑。查询各 API 提供商账户余额。 category: custom metadata: author: Hermes Agent last_updated: "2026-09-01" --- # LLM Provider Billing / 余额查询 查各家 LLM API 账户还剩多少钱、是否可调用。先看本技能,别猜端点。 ## DeepSeek(已验证 ✅) 官方端点 `GET https://api.deepseek.com/user/balance`,用普通 API key 做 Bearer 认证,无需额外权限。 ### 一键查询 ```bash bash ~/.hermes/skills/custom/llm-provider-billing/scripts/deepseek-balance.sh ``` 或手动: ```bash export DEEPSEEK_API_KEY=$(grep '^DEEPSEEK_API_KEY=' ~/.hermes/.env | cut -d= -f2-) curl -s https://api.deepseek.com/user/balance \ -H "Accept: application/json" \ -H "Authorization: Bearer $DEEPSEEK_API_KEY" ``` ### 返回结构 ```json { "is_available": true, "balance_infos": [ { "currency": "CNY", "total_balance": "16.60", "granted_balance": "0.00", "topped_up_balance": "16.60" } ] } ``` - `total_balance` = `granted_balance`(赠送) + `topped_up_balance`(充值);三个字段都是**十进制字符串**,解析时不要转 float - `is_available` = 余额是否足够调用(≠ 服务可用性,不预测消耗速度) - 多币种时 USD/CNY 分开列,不要自行换算汇率 ### 关键事实 - **Key 位置**:`~/.hermes/.env` 的 `DEEPSEEK_API_KEY`(Hermes 的 config.yaml 里 api_key 均为空,key 集中在 .env) - **402 vs 401**:余额归零 → HTTP 402 Insufficient Balance(key 仍有效,充值即恢复);key 错误/缺失 → 401。遇到 402 是去充值,不是换 key - 充值/发票在 platform.deepseek.com 的 Billing 页面 ## 其他提供商(待扩展) 每家端点不同。添加前先用 web_search 验证官方文档并实测一次,把端点 + 返回结构记录到 `references/`。 ## 坑 - `curl | python3 -m json.tool` 管道到解释器可能触发安全审批;可先 `> /tmp/bal.json` 再解析 - 本技能脚本:`scripts/deepseek-balance.sh`(从 ~/.hermes/.env 自动读 key,无需手动 export) - **YAML frontmatter 里的日期必须加引号**(`last_updated: "2026-09-01"`),裸 `2026-08-30` 会被 YAML 解析成 date 对象,导致 skill_view 报 "Object of type date is not JSON serializable"(本次会话实测踩坑)