
TwotwoPiggy/dsh-balance
61Last commit Aug 15, 2026
dsh-balance DSH plugin
dsh-balance adds a live balance and session cost estimator to the DSH Web UI input bar. It shows account balance with a green/yellow/red adequacy indicator, estimated cost for the current conversation, and a hover card with detailed breakdowns. The plugin also includes a time-aware pricing engine that automatically switches between peak and off-peak rates after August 17, 2026.
How to install the dsh-balance DSH plugin
dsh plugin --profile web add dsh-balanceCopying does not run this command. Review the repository and version before installing the dsh-balance DSH plugin.
dsh-balance DSH plugin data source
dsh-balance DSH plugin snapshot date: Aug 16, 2026
discovered
What the dsh-balance DSH plugin can do
- Real-time balance display with color-coded adequacy indicator (green/yellow/red) and manual refresh by clicking the indicator dot
- Session cost estimation based on DeepSeek official per-token pricing for V4 Flash and V4 Pro models
- Hover card with dual-column layout showing account balance details and session consumption breakdown by model
- Time-aware pricing engine that automatically applies peak/off-peak rates (5x off-peak discount) after August 17, 2026
- Visual configuration panel accessible from the input bar, allowing adjustment of thresholds, currency, API key, custom pricing, and YAML export
- Server-side caching with stale-while-revalidate and browser-side polling that pauses when page is hidden
- Manual force refresh with 2000ms cooldown to prevent abuse
Where the dsh-balance DSH plugin fits
- Monitor DeepSeek account balance in real time to avoid unexpected service interruption during long conversations
- Estimate per-session cost to track API spending and optimize usage
- Configure custom warning/danger thresholds tailored to individual budget sensitivity
- Switch between CNY and USD currency with matching pricing templates for global users
- Isolate development and production environments using separate profiles and ports
Who the dsh-balance DSH plugin is for
- DeepSeek API users who frequently monitor their account balance
- DSH users who want integrated cost visibility within the Web UI
- Developers and operators managing multiple DeepSeek API keys across different environments
dsh-balance DSH plugin limitations
- Only supports DeepSeek official API endpoints; not compatible with other providers
- Session cost estimation relies on user-configured model prices; unlisted models use default pricing which may be inaccurate
- Manual force refresh has a built-in 2000ms cooldown; rapid clicks are throttled
- Visual configuration panel is only available in DSH Web UI; terminal users must edit YAML directly
dsh-balance DSH plugin: from the repository README
Quoted from the TwotwoPiggy/dsh-balance README, the upstream source of the dsh-balance DSH plugin. Copyright remains with the original authors.
DeepSeek 余额实时显示插件: 在 dsh Web UI 输入框**下方、命中率/输入输出 token 统计条所在的同一行**, 实时显示: - **账户余额与充足度状态指示灯**(如 `🟢 余额 ¥97.69`, 红/黄/绿三色直观反映余额充裕状况,**点击状态圆点可直接手动强刷查询最新余额**) - **本次对话的估算消耗**(如 `本会话约 ¥3.92`, 按模型、按 DeepSeek 官方单价估算) - **`?` 定价参考图标**: 悬停以 `?` 为中心优雅浮现 **DeepSeek V4 系列专属定价微卡片**(支持 `deepseek-v4-flash` 与 `deepseek-v4-pro`),点击直达官方定价页 <https://api-docs.deepseek.com/zh-cn/quick_start/pricing/> 悬停读数可查看**左右双栏毛玻璃卡片**: - **左栏【📊 账户余额】**:实时大字总额、充足度 Badge、充值与赠送金额构成、5分钟自动刷新时间戳点击指示灯强刷指引以及偏好设置快速入口。 - **右栏【⚡ 本会话消耗】**:当前会话预估总花费、按模型细分明细(如 `• deepseek-v4-flash: ¥3.92`)、换行小字体展示输入/输出与缓存命中统计(如第一行 `Token: 输入 124M · 输出 301K` 与第二行 `命中: 123M (99.3%)`)。 - **时间感知引擎**:内置 2026 年 8 月 17 日起 DeepSeek 谷峰计费自动切换机制(09:00~12:00, 14:00~18:00 峰时 / 其他时段 5 折谷时),全自动无缝同步。  ## 架构 ``` ┌─────────────┐ 按 refreshIntervalMs 轮询 ┌──────────────────┐ │ DeepSeek API│◀────────────────────────────│ 服务器插件(host) │ │ /user/balance│ │ · 余额缓存(带陈旧回退)│ │ │ ?force=1 手动强刷路由 │ · /query-balance 路由│ └─────────────┘ │ · queryBalanceCost │ │ 会话花费投影(含V4谷峰)│ └
Read the full READMEThe repository declares no license. Check with the authors before using it.
dsh-balance DSH plugin questions
How do I install dsh-balance?
Run `dsh plugin --profile web add dsh-balance` in your terminal. After successful installation, restart `dsh web` to activate the plugin. You can also use AI assistant prompt templates provided in the README for automatic installation.
How do I configure the warning and danger thresholds?
Edit the `cordis.patch.yml` file in your profile directory (e.g., `$DSH_HOME/profiles/web/cordis.patch.yml`). Set `warningThreshold` and `dangerThreshold` values in your currency. For example, to set warning at 10 CNY and danger at 5 CNY, use the standard template. The changes take effect immediately after saving.
Can I use this plugin with a USD account?
Yes, you can switch the currency to USD by setting `currency: USD` in the config. The README provides a complete template for USD accounts with appropriate thresholds and pricing for DeepSeek V4 models. Adjust the threshold values accordingly (e.g., warning=2.0, danger=0.5 USD).
How do I manually refresh the balance without waiting for the polling interval?
Click the status indicator dot (the colored circle) on the balance display in the DSH Web UI. This triggers a manual force refresh that bypasses the cache and queries DeepSeek API directly. Note that there is a 2000ms cooldown between manual refreshes to prevent abuse.
How do I update dsh-balance to the latest version?
Run `dsh plugin --profile web remove dsh-balance` to remove the old version, then `pnpm store prune` to clear pnpm cache, and finally `dsh plugin --profile web add dsh-balance@latest` to install the latest version. This ensures you get the newest release instead of a cached old version.