- Home
- Plugins
- Usage & Billing
- dsh-model-balances
dsh-model-balances
pangh0928/dsh-model-balances
Shows each configured provider's balance above the sidebar avatar, with the account wallet and the API-key wallet on separate rows and today's spend under each; providers without a balance API show 'unknown' instead of a number. Balances and spend come from the local aggregation routes of the kenz1117/dsh-ui-usage-billing plugin, which must be installed.
Install
dsh plugin --profile web add github:pangh0928/dsh-model-balancesREADME
dsh-model-balances
在 DSH 侧边栏底部(账号头像上方)常驻一张余额卡片,按钱包逐行显示各模型提供商的可用余额。
- DeepSeek 的登录账号钱包与API Key 钱包分行显示,各自独立;
- 每行的余额下方有一行小字,是该钱包今日花费(当天这个账号 / Key 用掉多少,按 DSH 会话日志归因);
- 其它已配置且有余额接口的提供商(Kimi、智谱 GLM、xAI 等)依次列出;
- 已接入但没有余额接口的提供商也会列出,显示「额度未知」——不编造数字,也不把可用的模型藏起来;
- 未登录、未配置、不可读的钱包显示原因,不显示 0;
- 每次显示的都是真实返回值,不做估算。

截图里每个钱包两行:第一行名称与余额,第二行小字是今日花费(图中金额已打码)。
数据来源
行数据来自三处:
- 余额金额:本机
@kenz1117/dsh-ui-usage-billing插件提供的聚合路由GET /api/billing/balance(anonymous + 回环守卫 + 5 分钟缓存)。本插件不持有任何密钥,也不直接请求厂商接口; 该插件未安装或不可用时,卡片显示「暂无余额数据」。 - 可用提供商:
ctx.remote.llm.listProviders(),即当前真正注册成功、可调用的 provider 路由。 用于给没有余额接口的提供商补一行「额度未知」。 - 今日花费:同一个插件的用量聚合路由
GET /api/billing/usage-stats,取byDayModelsSite[今天]按站点汇总。api-key钱包认领<route>与<route>-official,account钱包认领<route>-account, 都没被认领的金额记入 tooltip 的「未归属」。日期用响应里的timezone(跟随 DSH,Asia/Shanghai), 不用浏览器时区,所以跨时区不会错一天。
行为
- 挂载即拉取,之后每 30 秒轮询;点击卡片立即刷新;标签页重新可见时补一次。
- 每个钱包占两行:名称与余额一行、今日花费小一号字右对齐贴在余额下方,侧栏再窄也不会挤掉名字。
- 超过 5 行折叠为「还有 N 项」;行内 tooltip 显示充值 / 赠金拆分,以及今日合计与未归属金额。
- 侧边栏折叠时退化为 36px 的
¥按钮,tooltip 列出全部钱包。 - 未检测到
@kenz1117/dsh-ui-usage-billing(余额路由返回 404)时,卡片直接提示先安装该插件,而不是显示 0。 - 只使用
--dsw-*主题变量,跟随明暗主题;不向宿主容器注入布局样式。
接口约定
请求头需带 x-dsh-billing-client-version / -locale / -timezone-offset,缺失时账号钱包会以
no-metadata 隐藏。响应形如:
{ "balances": [
{ "provider": "deepseek", "displayName": "DeepSeek", "walletKind": "account",
"currency": "CNY", "totalBalance": 12.34, "isAvailable": true },
{ "provider": "deepseek", "displayName": "DeepSeek API", "walletKind": "api-key",
"currency": "CNY", "totalBalance": 4586.43, "isAvailable": true }
] }
安装
推荐在 DSH 桌面端的 Plugins → Plugin Market 搜索「模型余额」安装;需要同时安装
@kenz1117/dsh-ui-usage-billing(提供余额聚合路由),否则卡片会提示先安装该插件。
命令行安装到 web profile:
dsh plugin --profile web add github:pangh0928/dsh-model-balances
本地开发时也可以直接把目录装进当前 profile(会写入 ~/.dsh/profiles/desktop/package.json
与 cordis.patch.yml,需要一次 danger-full-access 审批;plugin_manager remove_bundle 可回滚):
# 在 DSH 会话里对 lead 代理说:
# plugin_manager install_bundle target=<本目录绝对路径>
已知限制
- 只覆盖「有余额查询接口」的提供商。硅基流动、阶跃星辰、月之暗面、腾讯云 TokenHub 等没有公开余额 接口的平台只显示「额度未知」,真实余额需要去各自控制台查看。
- 哪些厂商能查到数字由
@kenz1117/dsh-ui-usage-billing决定,充值到账后会自动从「额度未知」变成金额。 - billing 侧有 5 分钟缓存,点刷新只是触发它重查。
- 今日花费依赖
usage-stats:这条路由不可用时只显示余额;某天账本缺失(旧版用量统计没落盘的会话行) 就统计不到那部分。 - 与 usage-billing 同槽时,它会收成 36px 图标(其自身的邻居降级逻辑),完整面板需点开。
结构
package.json # dsh.bundle.patch + dsh.client(web),可选 peer 依赖 usage-billing
cordis.patch.yml # 注册插件入口 id: model-balances
index.js # 宿主侧空壳(纯客户端插件)
client.js # 卡片组件:拉取、渲染、轮询、折叠、locale
locale/*.json # 中英文案
screenshots/ # README 用的卡片截图
icon.svg
Related plugins
DeepSeek-Balance-Whale-Widget
meteornox/deepseek-balance-whale-widget
dsh-context
bowenliang123/dsh-context
dsh-cost-meter
han-1413141/dsh-cost-meter
dsh-damage-pulse
wssfk12138/dsh-damage-pulse