DSH Hub
dsh-tokenledger cover

zh667/TokenLedger

dsh-tokenledger

UIWeb UI199 GitHub stars· updated 2026-09-15

Relay-site attributed token usage for DeepSeek Harness — zero config, no credentials

Install

npx @deepseek-ai/dsh plugin --profile web add "github:zh667/TokenLedger"

Restart `dsh web` after install. Bundle APIs can change during the developer preview.

README badge

dsh-tokenledger DSH Hub badge
[![DSH Hub](https://dshhub.dev/badge/tokenledger.svg)](https://dshhub.dev/plugins/tokenledger)

Paste this into your README. The star count updates with every catalog sync.

From the README

Excerpt from zh667/TokenLedger, cleaned of badges and images.

TokenLedger

把 DeepSeek Harness 的 Token 用量算清楚,并归属到实际服务这次请求的中转站——不用配置,不用凭据。

Token-usage accounting for DeepSeek Harness, attributed to the relay site that served each request. The existing Web GUI (dsh web) and renderer-neutral consumers share the same host-owned aggregation. Zero configuration.

展示图使用演示数据与本机模拟中转站;面板上的每个数字都由真实代码路径算出,只是数据是造的。插件不会把 API Key 或上游原始响应发送到浏览器。

一眼看懂 / At a glance

能力说明
🎯中转站归属按 provider 的 baseURL 归一化 origin 分组——同一站的多把 key 合成一行,站名就是域名,不是你自己起的路由别名
📁按项目归属用量按会话启动时所在的目录分组——工作区注册过的用它的标题,没注册过的用目录名,子目录里起的会话照样算进去
🔍零配置发现从宿主的 provider 配置里读出中转站,不用你再填一遍。只读 baseURL,绝不碰旁边的凭据
💳余额DeepSeek 官方、New API、Sub2API,每个账户一把普通 key 即可;不限额度的 key 报"已用"而不是假余额
⏳订阅配额卖套餐不卖余额的家数越来越多——5 小时 / 每周 / 每月各自滚动、各自重置,每个窗口一条进度条和一个重置时刻
📊用量分析今日/本月/累计三窗口、按站点/模型下钻、缓存命中率、一年活跃度热力图(悬停看当天模型构成)
🧮费用估算生效日期分段的费率表、分桶计价、峰谷时段;未定价的模型显示破折号而不是 0
🗂导出与诊断CSV / JSON 导出,索引健康度,归因不上的行数单独列出
🔒只读回环两个端点仅接受回环 GET,且在 peer socket 地址上设防;从不读取提示词、工具参数或响应内容

快速安装 / Quick start

需要 DeepSeek Harness web profile(@deepseek-ai/dsh >= 0.1.0-rc.6)。

dsh plugin --profile web add "github:zh667/TokenLedger"

重启已经在跑的 dsh web,浏览器硬刷新。侧边栏底部会出现「用量账本」入口。

升级或卸载:

dsh plugin --profile web update dsh-tokenledger
dsh plugin --profile web remove dsh-tokenledger

重装同一个 spec 会重新解析,所以 add 一遍就能拿到最新的 main(实测过,不是推测)。

要钉某个版本,必须用完整的 40 位 commit SHA。 包管理器把 ref 拿去和 git ls-remote 广播的引用列表比对,而那份列表里只有完整 SHA 和分支/标签名——短 SHA 匹配不到任何东西,会直接报 Could not resolve:

spec
github:zh667/TokenLedger✅
github:zh667/TokenLedger#main✅
github:zh667/TokenLedger#947247a❌ 短 SHA 解析不了
github:zh667/TokenLedger#947247a86f0835f0e746695538569b1a76356dd1✅

如果 package.json 里已经被写进了一个解析不了的 spec,add 也会失败——它会先解析整份清单。改掉那一行再 install 即可。

装完之后 /tokenledger diagnostics 会打印当前的路由归属和索引里的路由——排查「我的中转站为什么不显示」看这里,不用猜。

装完即可用:没有要填的配置,也不需要任何凭据就能看到全部用量与中转站分布。余额是唯一用到 key 的地方,而那把 key 宿主已经替你存着了。

命令 / Commands

面板能回答的问题,命令行都能回答——两边读的是同一批查询,不存在第二套聚合。

/tokenledger                      # 全部时间
/tokenledger 7                    # 最近 7 天
/tokenledger 30 api.example.com   # 某个中转站,最近 30 天

/tokenledger site                 # 列出发现到的中转站
/tokenledger site add <路由名> <地址>
/tokenledger site rm <路由名>

/tokenledger export csv 30        # 导出
/tokenledger diagnostics          # 索引健康度
/tokenledger reindex              # 丢弃索引,从头重建

支持的账户类型 / Providers

Provider模式凭据上游接口
DeepSeek 官方余额provider 的 apiKeyEnv/user/balance
New API 系(含 One API、VoAPI 等分支)余额/额度provider 的 apiKeyEnv/api/usage/token/ + /api/status
Sub2API余额 / 额度 / 订阅provider 的 apiKeyEnv/v1/usage
Moonshot / Kimi余额provider 的 apiKeyEnv/v1/users/me/balance
智谱 GLM / Z.ai余额provider 的 apiKeyEnv/api/biz/account/query-customer-account-report,读不到时回退 /api/paas/v4/balance
OpenRouter余额Management Key/api/v1/credits
OpenCode Go订阅provider 的 apiKeyEnv,或本机 auth.json/zen/go/v1/usage
Kimi For Coding订阅provider 的 apiKeyEnv/coding/v1/usages
MiniMax Coding Plan订阅provider 的 apiKeyEnv/v1/token_plan/remains
智谱 GLM / Z.ai Coding Plan订阅 + 余额provider 的 apiKeyEnv/api/monitor/usage/quota/limit

…

Related plugins