llm-provider-billing: 新增百炼 Token Plan 余量查询(bailian-token-plan.sh + SKILL.md 文档)
This commit is contained in:
@@ -52,6 +52,46 @@ curl -s https://api.deepseek.com/user/balance \
|
||||
- **402 vs 401**:余额归零 → HTTP 402 Insufficient Balance(key 仍有效,充值即恢复);key 错误/缺失 → 401。遇到 402 是去充值,不是换 key
|
||||
- 充值/发票在 platform.deepseek.com 的 Billing 页面
|
||||
|
||||
## 阿里云百炼 Token Plan(已验证 ✅)
|
||||
|
||||
Token Plan 是订阅制(周配额),"余量" = 本周剩余 token 配额比例,语义区别于 DeepSeek 的余额。
|
||||
|
||||
### 一键查询
|
||||
|
||||
```bash
|
||||
bash ~/.hermes/skills/custom/llm-provider-billing/scripts/bailian-token-plan.sh
|
||||
# --summary 附加统一用量摘要(免费额度 freeTier + 近期用量)
|
||||
bash ~/.hermes/skills/custom/llm-provider-billing/scripts/bailian-token-plan.sh --summary
|
||||
```
|
||||
|
||||
### 鉴权要求(关键)
|
||||
|
||||
- **Console 鉴权**:首次运行前需浏览器一次性授权 `bl auth login --console --console-site domestic`(国内站)
|
||||
- **API Key 查不了配额**:`bl auth login --api-key <key>` / 环境变量里的 key(用户的是 `OPENAI_API_KEY`)只能调模型,不能查余量
|
||||
- 授权凭据落盘 `~/.bailian/config.json`,登录一次长期有效;回调走本机 `127.0.0.1` 端口,浏览器必须与 CLI 同机
|
||||
|
||||
### 返回结构(实测 2026-09-10)
|
||||
|
||||
```json
|
||||
{
|
||||
"per1WeekPercentage": 0.032949624,
|
||||
"per1WeekResetTime": 1789624440000
|
||||
}
|
||||
```
|
||||
|
||||
- `per1WeekPercentage`:**本周已用比例**(0.033 ≈ 3.3% 已用;实测随时间递增,确认是"已用"不是"剩余"),剩余 ≈ 1 - 该值
|
||||
- `per1WeekResetTime`:本周配额重置时间(epoch 毫秒,如 2026-09-17 13:54 CST,即 7 天滚动窗口)
|
||||
- 原始 JSON 只有这两个字段,无绝对额度数值;脚本自动换算已用/剩余百分比 + 本地时区重置时间
|
||||
|
||||
### 相关命令
|
||||
|
||||
| 命令 | 用途 | 鉴权 |
|
||||
|---|---|---|
|
||||
| `bl usage token-plan --output json` | Token Plan 周配额用量 | Console |
|
||||
| `bl usage summary --output json` | 统一摘要:freeTier 剩余额度 + 近期用量 | Console |
|
||||
| `bl usage stats` / `bl usage free` | 用量统计 / 免费额度 | Console |
|
||||
| `bl token-plan list-seats` | 订阅座位详情 | AK/SK(`ALIBABA_CLOUD_ACCESS_KEY_ID` 等环境变量) |
|
||||
|
||||
## 其他提供商(待扩展)
|
||||
|
||||
每家端点不同。添加前先用 web_search 验证官方文档并实测一次,把端点 + 返回结构记录到 `references/`。
|
||||
|
||||
Reference in New Issue
Block a user