
zoumutou/dsh-cost-balance
33Last commit Aug 14, 2026
dsh-cost-balance DSH plugin
Adds a small black bar below the input field that expands into a translucent panel on click. Displays per-session spending, real-time account balance (auto-refresh every 60s), cache hit rate, token counts, and more. Uses the same data source as the shipped stats cell.
How to install the dsh-cost-balance DSH plugin
dsh plugin --profile web add dsh-cost-balanceCopying does not run this command. Review the repository and version before installing the dsh-cost-balance DSH plugin.
dsh-cost-balance DSH plugin data source
dsh-cost-balance DSH plugin snapshot date: Aug 16, 2026
discovered
What the dsh-cost-balance DSH plugin can do
- Collapsible iOS-style bar showing minimal stats in the input area
- Expandable frosted glass panel with detailed metrics: rounds, steps, LLM/tool latency, first token latency, throughput, cache hit, token input/output, cost, balance
- Auto-refresh account balance every 60 seconds via DeepSeek official API
- Supports custom pricing overrides via profile configuration file
- Instant recalculation on token usage changes
Where the dsh-cost-balance DSH plugin fits
- Monitor real-time session cost to manage budget during long conversations
- Check DeepSeek account balance without leaving the chat interface
- Analyze cache hit ratio to optimize prompt reuse and reduce costs
- Track token consumption for debugging or billing purposes
- Customize pricing model for enterprise or custom rate plans
Who the dsh-cost-balance DSH plugin is for
- DSH Web UI users who want cost transparency
- Developers or power users monitoring DeepSeek API spending
dsh-cost-balance DSH plugin limitations
- Balance requires a valid DeepSeek API Key; shows '--' if not configured or fetch fails
- Built-in pricing only covers DeepSeek official models; price changes require manual configuration override
- Only available for the DSH Web UI profile (not CLI or other profiles)
dsh-cost-balance DSH plugin: from the repository README
Quoted from the zoumutou/dsh-cost-balance README, the upstream source of the dsh-cost-balance DSH plugin. Copyright remains with the original authors.
DeepSeek Harness(DSH)Web UI 插件:在输入框下方显示一条 iOS 风格的小黑条,点击展开轻盈的半透明多行面板,查看**会话花费、账户余额、缓存命中、Token 用量**等统计。 默认折叠为一条居中的小黑条(类似 iOS 底部横条),点击展开毛玻璃面板: | 行 | 内容 | |---|---| | 轮次 · 步数 | 3 轮 · 12 步 | | LLM 耗时 / 工具调用 | 45.2s / 12.3s | | 首 token 平均 / 吞吐 | 1.4s / 25.4 tok/s | | 缓存命中 | 87% | | Token | 输入 12.2K · 输出 517 | | 花费 | $0.0123(本会话,按官方定价) | | 余额 | ¥9.00(DeepSeek 账户实时余额,60s 自动刷新) | ## 安装(npm 发布版) ```sh dsh plugin --profile web add dsh-cost-balance ``` > 该命令从 npm registry 拉取已发布的 [dsh-cost-balance](https://www.npmjs.com/package/dsh-cost-balance)(dsh.bundle),自动加入 profile 的 bundle 层。 然后重启(或刷新)DSH Web UI。卸载:`dsh plugin --profile web remove dsh-cost-balance`。 ## 工作原理 - **Client 半**(`lib/client.js`):注册在 `conversation.composer.dock` 槽位(接管 shipped 的 `stats` 单元格,与产品自带统计行同源同数据),展示折叠/展开 UI;通过同源 `GET /api/cost-balance` 读取数据,每 60 秒自动刷新,token 用量变化时即时重算。 - **Host 半**(`lib/index.js`):经 `webServer` 注册 `/api/cost-balance` 路由——花费按会话累计 token(未命中输入 / 缓存命中 / 缓存写入 / 输出)× 模型单价计算;余额经 `credentials` 服务解析 `DEEPSEEK_API_KEY` 后调用 DeepSeek 官方 `GET /user/balance`(60s 缓存、失败 30s 抑制)。 余额取自**用户自己的 API Key 账户**,无需任何配置;未配置或抓取失败时面板显示 `余额 --`。 ## 定价与覆盖 内置 DeepSeek 官方定价(USD / 1M tokens): | 模型 | 缓存命中 | 缓存未命中 | 输出 | |---|--
Read the full READMERepository license: MIT
dsh-cost-balance DSH plugin questions
How do I install dsh-cost-balance?
Run `dsh plugin --profile web add dsh-cost-balance` in your terminal. This pulls the plugin from npm and adds it to your web profile. Then restart or refresh the DSH Web UI to see the cost bar.
Why is the balance showing '--'?
The balance requires a valid DeepSeek API Key to be configured in your DSH environment. If the key is missing or the API call fails, the plugin displays '--'. Check that your `DEEPSEEK_API_KEY` is set correctly and that the DeepSeek balance API is accessible.
Can I change the pricing model for models not listed?
Yes, you can override the pricing by adding a `cost-balance` config section in your profile's `cordis.patch.yml` file. Provide the exact model ID and your custom prices for cacheHit, cacheMiss, and output. The plugin will use your values instead of the built-in ones.
Does this plugin work with other AI models besides DeepSeek?
The plugin is designed specifically for DeepSeek models and uses DeepSeek's official pricing and balance API. It may not work correctly with other providers because the cost calculation and balance endpoint are tied to DeepSeek.
How often does the balance refresh?
The balance is automatically refreshed every 60 seconds. If the API call fails, the plugin suppresses further requests for 30 seconds to avoid spamming. You can also trigger a manual refresh by clicking the bar (if the plugin supports it) or by restarting the UI.