dsh-billing-balance
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.
No comments yet. Be the first to write one.