Shows DeepSeek API balance and per-turn conversation cost directly in the session UI.
Install
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:Vast-Unhurried/dsh-toolkit#path:/packages/dsh-api-balance
Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).
README
This plugin publishes its README in Chinese only.
DeepSeek Harness 原生风格的 API 余额 与 每轮费用 显示插件(人民币),并在会话头部提供模型计费管理。
- 余额徽章:会话头部操作行。显示当前模型所属供应商的余额,格式
余额(供应商)¥xx.xx;DeepSeek 官方路由显示余额(高峰)/余额(闲时)(按北京时间,与官网峰谷窗口对齐:周一至周五 9:00–12:00、14:00–18:00 为高峰,周末全天闲时)- 余额来源三种:DeepSeek 官方接口(
GET https://api.deepseek.com/user/balance)、第三方余额接口(URL + 凭据名)、本地记账(初始总金额 − 已扣费用) - 单击刷新(官方接口绕过 60 秒缓存;本地记账实时重算);双击打开「模型计费管理」
- 余额来源三种:DeepSeek 官方接口(
- 模型计费管理:双击徽章打开。可添加 / 编辑 / 删除供应商(一个供应商挂多个模型,共用同一余额池),为第三方模型设置独立的输入 / 输出 / 缓存读 / 缓存写费率(元/百万 tokens)
- 本轮费用:每条 assistant 回复完成(带 token 用量)后,在其操作图标旁显示
本轮 ¥x.xxxx;按官方峰谷价或自定义费率精确计价(缓存命中分开计价);悬停显示缓存命中率 X% 消耗 X K/M tok - 今日消耗:悬停徽章显示当日(北京时间)当前供应商的全部消耗(K tok / M tok)——DeepSeek 官方路由与其派生通道(如 vision-toolkit)合并为同一供应商统计,与官网用量页数字一致;第三方供应商各自独立、切换时联动
- 切换联动:切换会话或切换供应商模型时,徽章立即切换为该供应商的余额;同供应商内切换模型保持不变
计价
- DeepSeek 官方(deepseek-v4-flash):峰谷价(2026-08-17 生效;周末全天闲时自 2026-08-23 起):
| 时段 | 输入(缓存未命中) | 输入(缓存命中) | 输出(含 reasoning) |
|---|---|---|---|
| 高峰(周一至周五 9:00–12:00、14:00–18:00 北京时间) | 3.0 | 0.10 | 9.0 |
| 闲时(周末及工作日其余时段) | 1.5 | 0.05 | 4.5 |
单位:元 / 百万 tokens。
- 第三方供应商:按「模型计费管理」中配置的费率计价(未配置的模型不参与本地记账)。
配置(Config)
全部可调参数经 profile 的 cordis.yml 配置(宿主 Schemastery 校验,客户端经 getConfig 拉取,未配置时用内置默认):
| 字段 | 默认 | 说明 |
|---|---|---|
balanceCacheMs |
60000 | 官方余额接口的服务器缓存时长(ms) |
pricing.peak.input / cacheRead / cacheWrite / output |
3.0 / 0.10 / 0 / 9.0 | 高峰价(元/百万 tokens) |
pricing.offPeak.input / cacheRead / cacheWrite / output |
1.5 / 0.05 / 0 / 4.5 | 闲时价(元/百万 tokens) |
peakWindows |
周一至周五 9–12、14–18 | 高峰窗口:[{ days: [1..5], start, end }](0=周日) |
activeModelPollMs |
2000 | 徽章轮询当前模型的间隔(ms) |
panelPollMs |
3000 | 管理面板轮询间隔(ms) |
clickDebounceMs |
240 | 徽章单击/双击防抖窗口(ms) |
# 示例:profile 的 cordis.patch.yml 覆盖层
- id: api-balance
name: dsh-api-balance
config:
balanceCacheMs: 120000
peakWindows:
- { days: [1, 2, 3, 4, 5], start: 9, end: 12 }
- { days: [1, 2, 3, 4, 5], start: 14, end: 18 }
数据与 API
- 路由:
POST /plugins/api-balance/api,方法getBalance/getActiveModel/getSessionModel/getLocalBalance/getTodayUsage/syncProviders/resetLocalBalance/ping - 供应商配置与费率保存在浏览器 localStorage,并同步到宿主
$DSH_HOME/plugins/dsh-api-balance/state.json(本地记账账本 + 按供应商的每日 token 统计) - API Key 复用 Harness 凭据服务(
~/.dsh/.credentials.yaml的DEEPSEEK_API_KEY),Key 永不进入浏览器 - 宿主订阅全局会话事件流为第三方本地记账扣费;官方模型的用量也计入「今日消耗」统计
安装 / 卸载
dsh plugin --profile web add file:./packages/dsh-api-balance
# 卸载
dsh plugin --profile web remove dsh-api-balance
重启 dsh 服务后浏览器硬刷新。卸载后本地记账数据保留在 $DSH_HOME/plugins/dsh-api-balance/state.json,如需彻底清除手动删除。
安全
- 仅 POST + 同源校验(Host 回环 + Origin 精确匹配),拒绝跨站 / DNS rebinding
- 凭据只在宿主侧解析;请求体 64 KiB 上限;响应 no-store
- 客户端纯 React 渲染,无 innerHTML / eval;不改动 Harness 核心
Links
More in this category
bowenliang123/dsh-context★ 5628
DSH context insight panel: Context dashboard + /context command + Context browser — one-stop context lifecycle management with categorized composition, content details, evolution trends, compaction/injection events, and stats.
Han-1413141/dsh-cost-meter★ 774
Per-session and daily API cost, budget with usage %, official balance, history dashboard, and one-click official price sync with peak/off-peak pricing.
wssfk12138/dsh-damage-pulse★ 291
Tracks DeepSeek token usage, per-call and session costs, and account balance with cache-aware charge animations in the DSH Web UI.
zh667/TokenLedger★ 207
Sidebar usage panel that attributes tokens to the relay site that served each request, read from your existing provider config: today/month/all-time totals, per-site and per-model breakdowns, a year activity heatmap, and New API / Sub2API / DeepSeek balances.
Ychris12138/dsh-usage-stats★ 193
Multi-provider usage dashboard with provider/model token breakdowns, calendar drill-downs, account balances, and OpenCode Go / Z.ai subscription quota tracking.
PolinniZhong/dsh-personal-center★ 114
Personal center for DeepSeek Harness: cross-session usage statistics with per-provider and per-model breakdown (auto-discovers configured models), per-model cost estimation, global custom instructions, a data-driven desktop pet with bitmap & vector skins, and a conversation status overview, all local and offline.
Community comments
Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.