huanyuLv/dsh-balance-tide
DeepSeek Harness (DSH) Web 插件: 余额 + 峰谷计价潮汐提示。显示 DeepSeek 账户余额与本会话花费, 并在余额前提示当前峰/谷价格档位、距切换倒计时与使用建议。
已收录
6
Usage
Bundle 已验证
功能介绍
输入框下方显示 DeepSeek 账户余额与本会话花费,余额前带峰/谷价格徽章(北京时间)与距切换倒计时,悬停看两档单价明细与使用建议。
适合
- 希望在 DSH Web 内查看 DeepSeek 账户余额和本会话预估花费的 API 用户。
- 希望按北京时间峰谷时段安排高 token 用量任务的用户。
- 需要配置价格表、计价时段、轮询间隔和反向代理允许域名的管理员。
不适合
- 会话花费按当前时段价格估算,不能替代官方账单。
- 多币种用户无法在主显示行看到全部余额;该处只显示第一种币种。
- deepseek-chat 和 deepseek-reasoner 未列于所引用的官方价格页,因此插件使用的是未经验证的兜底价格。
- 非 DeepSeek 计费工作流很少能从绑定 DeepSeek 余额接口和凭据的插件中获益。
README
dsh-balance-tide
| English | 简体中文 |
DeepSeek Harness (DSH) Web plugin: account balance + peak/off-peak pricing tide indicator.
A live readout row under the composer:
[standard] peak pricing starts in 2d 5h | Balance ¥28.78 | ~¥0.42 this session | ?
Once peak/off-peak pricing takes effect (2026-08-17), the badge and countdown follow Beijing time in real time:
[off-peak] peak in 2h 15m | Balance ¥28.78 | ~¥0.42 this session | ? ← off-peak hours
[peak] off-peak in 1h 30m | Balance ¥28.78 | ~¥0.42 this session | ? ← peak hours
Features
-
Pricing badge:
standard(before 2026-08-17) /peak/off-peak, judged live in Beijing time - Countdown: time remaining until the next pricing switch, ticking every second — plan your usage ahead
-
Balance: live balance from the official
/user/balanceendpoint (granted / topped-up split) -
Session cost: estimated at current-period prices (reuses
sessionProjections; same-turn/step samples replace rather than double-count) - Hover details: full price tables for the current and the next period, the peak/off-peak gap (peak = off-peak × 2), peak windows, and usage advice
-
?icon: opens the official pricing page https://api-docs.deepseek.com/zh-cn/quick_start/pricing/ -
Zero config: reuses
DEEPSEEK_API_KEYfrom DSH credentials — no key in the repo, ever - i18n: UI follows the interface language (中文 / English)
Peak/off-peak schedule (Beijing time)
Per the official pricing page (2026-08 edition, last verified 2026-08-15):
- From 2026-08-17 00:00, peak/off-peak pricing applies; before that, current flat prices
- Peak windows: 09:00–12:00 and 14:00–18:00; all other hours are off-peak
- Off-peak = half of peak
| Model (per 1M tokens) | Flat (hit / miss / output) | Off-peak | Peak |
|---|---|---|---|
| deepseek-v4-flash | 0.02 / 1 / 2 | 0.05 / 1.5 / 4.5 | 0.10 / 3.0 / 9.0 |
| deepseek-v4-pro | 0.025 / 3 / 6 | 0.15 / 4.5 / 13.5 | 0.30 / 9.0 / 27.0 |
Install
From npm (recommended)
dsh plugin --profile web add dsh-balance-tide
From the Git URL
dsh plugin --profile web add https://github.com/huanyuLv/dsh-balance-tide
From a local directory
dsh plugin --profile web add file:/path/to/dsh-balance-tide
Restart dsh web to take effect. Requires pnpm (npm i -g pnpm).
Configuration (in $DSH_HOME/profiles/web/cordis.patch.yml)
- id: dsh-balance-tide
config:
refreshIntervalMs: 300000 # how often the host polls the balance API
clientPollIntervalMs: 30000 # how often the browser re-reads the cache
currency: CNY
allowedHosts: [] # register your domain here if you front dsh with a reverse proxy
When the official prices or the schedule change, override them in config — no need to wait for a plugin release:
- id: dsh-balance-tide
config:
tideCutoff: '2026-08-17T00:00:00+08:00' # when peak/off-peak pricing starts
peakWindows: # peak hours (Beijing time, [start, end))
- { start: 9, end: 12 }
- { start: 14, end: 18 }
tidePrices: # per-tier prices (per 1M tokens)
flat:
deepseek-v4-flash: { cacheHit: 0.02, cacheMiss: 1, output: 2 }
peak:
deepseek-v4-flash: { cacheHit: 0.1, cacheMiss: 3, output: 9 }
offpeak:
deepseek-v4-flash: { cacheHit: 0.05, cacheMiss: 1.5, output: 4.5 }
peakWindows: [] means there are no peak hours at all — use it if the tiered pricing
is ever withdrawn.
Security
-
Credentials: prefer
DEEPSEEK_API_KEYfrom DSH credentials. TheapiKeyconfig option is an escape hatch only — it lands in a config file in plaintext, so avoid it.baseUrlmust be https; plaintext http is rejected outright (it would put the key on the wire). -
Balance endpoint:
/query-tideserves your account balance, so readers are checked. The Host must be localhost, an IP literal, or a domain registered inallowedHosts(this blocks DNS rebinding); any request carrying an Origin must be same-origin (this blocks arbitrary web pages from reading your balance). Rejected reads get a 403. -
Error reporting: the server sends only a small set of error codes to the browser;
raw exception text goes to the log, so a custom
baseUrlnever leaks to the frontend.
Known limitations
- Costs are estimates computed at current-period prices; the official invoice is authoritative.
- For multi-currency accounts the readout row shows the first currency only; the rest appear in the tooltip.
-
deepseek-chat/deepseek-reasonerare no longer listed on the official pricing page — the static entries inpricesare a fallback, not a verified quote.
Development
npm install
npm test
Compatibility
- DeepSeek Harness
0.1.0-rc.6+ (web profile) - Node.js 20 / 22 / 24 (covered by CI)
- Cross-platform: pure JavaScript + standard browser CSS, no native modules
- License: MIT
常见问题常见问题
在启用了 DSH 的终端中执行已验证命令 dsh plugin --profile default add github:huanyuLv/dsh-balance-tide。命令会解析公开 package 元数据,并保持插件与本页展示的目录身份一致。
兼容性以页面上展示的 bundle 与 profile 状态为准。如果某个 profile 尚未检测到,请先保持禁用,并在生产启用前阅读仓库文档。
GitHub 链接和 activity 元数据是 release 与维护状态的来源。新版本发布后重新查看本页,确认目录已经观察到最新版本。