
le-soleil-se-couche/dsh-token-cost
50Last commit Aug 14, 2026
dsh-token-cost DSH plugin
This plugin adds cost display to the conversation page and a configuration panel in Settings. It reads DSH session logs, computes fees using built-in pricing, and supports automatic switching between pricing schemes. Historical data is backfilled on first query.
How to install the dsh-token-cost DSH plugin
dsh plugin --profile web add github:le-soleil-se-couche/dsh-token-costCopying does not run this command. Review the repository and version before installing the dsh-token-cost DSH plugin.
dsh-token-cost DSH plugin data source
dsh-token-cost DSH plugin snapshot date: Aug 16, 2026
discovered
What the dsh-token-cost DSH plugin can do
- Shows session cost directly in the conversation status line with a clickable detail modal.
- Provides aggregated summary with time filters (today, yesterday, last 7/30 days, custom up to 30 days) and statistics cards for cost, tokens, cache hit rate.
- Displays current pricing scheme, next switch time, and peak hours in the summary panel.
- Supports dual pricing schemes (A and B) with automatic switching based on record time, and allows forced scheme, custom model prices, and currency toggle (CNY/USD).
- Reads and compresses session logs using fzstd (pure JS, zero dependencies), only re-parses changed logs.
Where the dsh-token-cost DSH plugin fits
- Monitor per-conversation token costs and cache hits in real time.
- Generate overall cost reports by model, session, or date for budget analysis.
- Compare costs between different pricing schemes and peak/off-peak hours.
- Track historical usage trends with custom date ranges (up to 30 days).
- Verify the impact of model pricing changes by switching between pricing schemes.
Who the dsh-token-cost DSH plugin is for
- DSH Web GUI users who want to track API costs.
- Developers and operators managing DeepSeek API usage budgets.
- Users who need detailed breakdown of token usage and cache performance.
dsh-token-cost DSH plugin limitations
- Cost is estimated based on provider-reported usage, not official billing.
- Only requests made through DSH are counted; requests from other tools or processes using the same API key are not included.
- Conversations spanning midnight are split by local browser timezone.
- Pricing data is captured from DeepSeek's official page (as of 2026-08-14); users must manually update if price changes occur (though new schemes can be added without plugin update).
dsh-token-cost DSH plugin: from the repository README
Quoted from the le-soleil-se-couche/dsh-token-cost README, the upstream source of the dsh-token-cost DSH plugin. Copyright remains with the original authors.
DeepSeek Harness(DSH)Web GUI 的 Token 用量 / 缓存命中 / 费用统计插件:支持单对话视图与整体汇总,内置双计价方案并在 DeepSeek 调价后按记录时间自动切换。 ## 功能 - **单对话视图**:对话页面底部官方状态行(「首 token 平均 … · … tok/s」之后)直接嵌入本会话消耗费用,点击即可打开按请求的明细弹窗(时间 / 模型 / 缓存未命中 / 缓存命中 / 输出 / 费用,最新在上)。 <p align="center"> <img src="docs/screenshots/conversation-bottom.png" alt="对话底部状态行费用展示" width="90%"> </p> <p align="center"> <img src="docs/screenshots/cost-detail.png" alt="费用明细弹窗" width="80%"> </p> - **整体汇总**(设置 > 插件配置 > Web UI 插件 > Token 费用统计):时间筛选(今天 / 昨天 / 最近 7 天 / 最近 30 天 / 本月 / 上月 / 自定义,最多 30 天)+ 费用 / 输入 / 输出 / 缓存命中率统计卡,按模型、会话、日期分组。 - **计价状态**:当前生效方案、下次切换时间、高峰时段一目了然。 ## 数据来源 插件读取 DSH 的持久会话日志(`$DSH_HOME/sessions/<cwd>/<session-id>/session.jsonl.zstd`),把 provider 上报的 usage 事件折叠为按请求的计费记录(同一 turn/step 取最后一次,与官方 token-meter 投影语义一致)。紧凑账本(`$DSH_HOME/storages/dsh-token-cost/ledger.json`)缓存解析结果,只重解析变化的日志;zstd 解压使用 fzstd(纯 JS 零依赖)。 Token 字段遵循 Harness 约定:`inputTokens` = 缓存未命中部分,`cacheReadTokens` = 缓存命中部分(两者不相交,相加即计费输入)。 ## 价格引擎(双方案 + 自动切换) 内置官方价格表(api-docs.deepseek.com/quick_start/pricing,2026-08-14 抓取): - **方案 A**(平价,2026-08-16T16:00Z 前):deepseek-v4-flash / v4-pro 平价(CNY/USD),deepseek-chat / deepseek-reasoner 旧平价。 - **方案 B**(峰谷定价,2026-08-16T16:00Z
Read the full READMEThe repository declares no license. Check with the authors before using it.
dsh-token-cost DSH plugin questions
How do I install dsh-token-cost?
Run the command `dsh plugin --profile web add github:le-soleil-se-couche/dsh-token-cost` in your terminal, then restart the `dsh web` service. After restart, go to the Settings page and expand the "Web UI Plugins" section to see the plugin.
Does the plugin work with historical conversations?
Yes, the plugin reads persistent session logs from DSH's session directory. When you first open the plugin, it will backfill historical data by parsing existing logs. Only new or changed logs will be re-parsed on subsequent uses.
Can I change the displayed currency from USD to CNY?
Yes, you can switch the display currency between CNY and USD. Go to the plugin's configuration panel (Settings > Web UI Plugins > Token Cost Statistics) and set the `currency` option to either 'cny' or 'usd'. The default is 'cny'.
How does the pricing scheme work?
The plugin includes two pricing schemes: Scheme A (flat rate, valid before 2026-08-16T16:00Z) and Scheme B (peak/off-peak pricing, starting from that time). Peak hours are Beijing time 9–12 and 14–18 (UTC 1–4, 6–10); off-peak is half price. Each record is billed using the scheme that was active at the time of the record. You can also force a specific scheme via the `priceMode` option.
Why are my costs different from the official bill?
The plugin estimates costs based on token usage reported by the provider. It is not an official billing tool. The actual charges from DeepSeek may differ due to rounding, promotions, or other factors. Always refer to the official bill for accurate charges.