bjzkhy/dsh-token-ledger-pro ↗★ 0
dsh-token-ledger-pro
DSH 计费统计插件:自动识别模型、实时展示会话/今日/本月消费、余额查询、预算告警,内置 16 家厂商价格目录(DeepSeek/豆包/腾讯混元/阿里千问/OpenAI/Anthropic/Kimi/智谱 等),中英双语
安装
$
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:bjzkhy/dsh-token-ledger-pro说明文档
阅读完整 README ↗配置说明
首次安装后打开 ~/.dsh/profiles/web/cordis.patch.yml,在 dsh-token-ledger-pro 的 balance 块中填入对应厂商的密钥即可查询余额,所有配置与DSH版本完全兼容。
配置余额查询
在 profile 的 cordis.patch.yml(或 settings)里给 dsh-token-ledger-pro 加 config.balance。按当前选中模型的厂商自动选择对应余额配置;未配置时显示「--」。
官方 API(推荐)
- id: dsh-token-ledger-pro
config:
monthlyBudget: 100
unknownModel: estimate
balance:
deepseek:
type: deepseek # 官方余额 API(api.deepseek.com/user/balance)
apiKey: "sk-你的DeepSeek密钥"
currency: "CNY"
openai:
type: openai # OpenAI 订阅余额
apiKey: "sk-你的OpenAI密钥"
currency: "USD"
anthropic:
type: anthropic
apiKey: "sk-ant-xxx" # 需在组织设置里补 organization_id
endpoint: "https://api.anthropic.com/v1/organizations//usage"
currency: "USD"
moonshot:
type: moonshot # Kimi 余额
apiKey: "sk-xxx"
currency: "CNY"
zhipu:
type: zhipu # 智谱余额
apiKey: "xxx.xxx"
currency: "CNY"
# 腾讯混元:按腾讯云账户计费,用费用中心 DescribeAccountBalance(TC3 签名)
hunyuan:
type: tencent # 腾讯云签名接口 billing.tencentcloudapi.com
secretId: "AKID你的腾讯云SecretId"
secretKey: "你的腾讯云SecretKey"
region: "ap-guangzhou" # 可留空,余额接口不依赖地域
currency: "CNY"
# 阿里千问(百炼):按阿里云账户计费,用 BSS QueryAccountBalance(RPC 签名)
qwen:
type: aliyun # 阿里云签名接口 business.aliyuncs.com
accessKeyId: "LTAI你的阿里云AccessKeyId"
accessKeySecret: "你的阿里云AccessKeySecret"
region: "cn-hangzhou" # 可留空
currency: "CNY"
balanceCacheTtl: 60 # 缓存秒数,默认 60(1 分钟)
⚠️ 密钥以明文存在本地配置文件中,注意不要泄露;若不想配置官方密钥,可用下方自定义端点。
自定义 HTTP 端点(任意厂商 / 中转)
- id: dsh-token-ledger-pro
config:
balance:
myproxy: # 与模型 provider 名一致
type: custom
endpoint: "https://你的中转站/api/balance"
headers:
Authorization: "Bearer sk-xxx"
valuePath: "data.balance" # JSONPath,从响应 JSON 提取数值
currency: "CNY"
- 内置厂商也可用
endpoint覆盖默认地址 valuePath支持点号路径:data.balance、balance、data.amount…
不支持的 provider 类型
火山方舟/豆包(Volcano Ark)需要 AK/SK 签名,暂未内置;可用 type: custom 指向你自己的签名网关。