dsh-billing-balance
by echo804
静态插件:在编辑器统计行(输入框下缓存命中的那行)加 API 余额与每会话成本估算
A static plugin for DeepSeek Harness that adds an API balance and per-session cost estimate readout to the composer stats line (the row under the input box showing cache-hit…
安装
dsh plugin --profile web add github:echo804/dsh-billing-balanceGitHub 源码安装:首次需按提示配置 allowBuilds 构建授权后重试
安装与环境配置指引、插件开发教程见 DSH 中文社区文档 ↗
安装即在你的机器上以你的权限运行第三方代码——它可读写文件、使用凭据、访问网络,DSH 的工具审批不会为插件代码加沙箱。「检测到 manifest」仅代表发现 dsh.bundle / dsh.plugin 清单,不构成兼容性或安全审查;安装前请审阅源码,不熟悉的插件先在不含密钥的环境试用。
README
目录
A static plugin for DeepSeek Harness that adds an API balance and per-session cost estimate readout to the composer stats line (the row under the input box showing cache-hit rate, tokens, etc.).
DeepSeek Harness 静态插件:在输入框下方的统计栏(显示缓存命中率、token 等那一行)追加 API 余额 与 本会话消耗金额估算。
Features / 功能
- 余额 (Balance): queries
GET {baseURL}/user/balancewith yourDEEPSEEK_API_KEYand shows余额 ¥xxx(currency follows the account). - 本会话消耗 (Session cost): sums the
tokenUsageprojection (uncached / cache-read / cache-write / output) × DeepSeek's official V4-Flash peak/off-peak CNY pricing, shown as本会话 ~¥x.xx. This is an estimate, not billing authority. - 峰谷时刻 (Peak badge): during DeepSeek peak windows (Beijing time 09:00–12:00 and 14:00–18:00, effective 2026-08-17), the readout appends an orange, bold 「峰谷时刻」 badge and prices at the peak rates; off-peak it shows no badge and prices at the off-peak rates. This makes it easy to tell which pricing tier applies right now.
- Click to refresh the balance.
- Custom baseURL support for gateway/proxy deployments.
How it works / 工作原理
| Half | Mechanism |
|---|---|
Host (index.js) |
Registers a webServer exact route /api/billing-balance; resolves DEEPSEEK_API_KEY via the credentials seam at request time; calls the balance endpoint with the global fetch (real Node environment). The key is never written to files or logs. |
Client (client.js) |
A window.__ModuleLoader__.load bundle registering an entry in the conversation.composer.dock slot (order 1, beside the shipped stats line); reads the tokenUsage projection and fetches the host route same-origin. |
Installation / 安装
Requires a DeepSeek Harness web profile (the browser GUI). The plugin is static: it must be resolvable as an npm package from your profile and appear as a loader entry. Restart the dsh web process after installing — profile configuration is read at startup.
1. Put the package where the profile can resolve it
The plugin package is the plugin/ directory of this repo. Copy it into your profile's hoisted node_modules:
# Windows (PowerShell)
$dest = "$env:USERPROFILE\.dsh\profiles\node_modules\dsh-billing-balance"
Copy-Item -Recurse -Force .\plugin $dest
# macOS / Linux
DEST="$HOME/.dsh/profiles/node_modules/dsh-billing-balance"
cp -R plugin "$DEST"
Or link it if your profile uses pnpm workspaces (pnpm --dir "$HOME/.dsh/profiles" add ./path/to/plugin).
2. Add the loader entry to your profile patch
Edit ~/.dsh/profiles/<profile>/cordis.patch.yml (for the default web profile: ~/.dsh/profiles/web/cordis.patch.yml) and append:
- insert:
- id: billing-balance
name: 'dsh-billing-balance'
Optional custom baseURL (e.g. a gateway):
- insert:
- id: billing-balance
name: 'dsh-billing-balance'
config:
baseURL: 'https://your-gateway.example.com'
Optional price overrides (CNY per 1M tokens; defaults to the official V4-Flash rates):
- insert:
- id: billing-balance
name: 'dsh-billing-balance'
config:
prices:
offPeak: { cacheRead: 0.05, cacheWrite: 1.5, input: 1.5, output: 4.5 }
peak: { cacheRead: 0.10, cacheWrite: 3.0, input: 3.0, output: 9.0 }
3. Restart the web process
Stop and restart dsh web (however you normally launch it). After restart:
- The plugin appears in Settings → Plugins as a loader entry
billing-balance. - The composer stats line shows
余额 ¥xxx | 本会话 ~¥x.xx; click it to refresh the balance. During peak hours (Beijing 09–12, 14–18) it additionally shows an orange 峰谷时刻 badge and prices at peak rates.
Requirements / 依赖
- DeepSeek Harness web profile with
credentialsandwebServerservices (present in the shipped base/web bundles). DEEPSEEK_API_KEYconfigured via the credentials seam (~/.dsh/.credentials.yamlor env — however your deployment stores it).- The host must be able to reach the balance endpoint (official
https://api.deepseek.comby default).
Privacy / 隐私
- The plugin does not store your API key, balance, or any personal data in files.
- The key is read from the credentials seam at request time, used only for the authenticated balance call, and never logged.
- The balance value is returned over the loopback web server to the same-origin browser page (127.0.0.1) to be displayed.
- Cost figures are estimates computed from token counts and public pricing; they are not billing authority.
License / 许可证
Disclaimer / 免责声明
This project is not affiliated with or endorsed by DeepSeek. Pricing constants are public reference values and may drift; always treat the displayed cost as an estimate.
原始 README: https://github.com/echo804/dsh-billing-balance/blob/main/README.md ↗
同类插件
查看全部 →
dsh-usage-plugin
DeepSeek Harness 用量与消耗插件(dsh-usage)—— 每次调用的 token 用量/缓存命中统计、峰谷计费、余额查询、CSV/JSON/PNG 导出,可经桌面端一键安装或命令行 dsh plugin add 安装。

dsh-whale-report
🐋 鲸鱼记事本 — 你的 Agent 年度报告:从会话事件日志生成日报/周报/月报/年报,任意区间、只读不改写

dsh-balance-meter
输入框 dock 显示 DeepSeek 账户余额与会话花费,自动拉取官方定价,支持高峰/低谷计价。

dsh-usage-stats
DeepSeek Harness 使用统计插件|Token 总量与构成、7/30 天趋势、年度活跃热力图、模型占比、工作区/任务筛选、CSV/JSON 导出

dsh-balance
DeepSeek 余额实时显示插件: 在 dsh Web UI 输入框 下方、命中率/输入输出 token 统计条所在的同一行 , 实时显示:

dsh-balance-monitor
DeepSeek 账户余额、剩余比例条与今日花费,显示在 dsh 侧边栏底部 · DeepSeek balance, remaining-ratio bar and today's spend in the dsh si