Introduction¶
After using DSH for a while, it is easy to lose track of how much money a single “continue” session has burned. When the context gets long, it is hard to mentally calculate the token usage and cost for a single turn; DSH itself has a token usage panel, but you have to expand it, do manual calculations, and remember whether it is peak or off-peak time yourself. The dsh-turn-cost plugin by maintainer inzia005 is here to do this.
What is this¶
dsh-turn-cost is a client-side DSH plugin maintained by inzia005, version 0.1.0, MIT licensed. It displays a line below each reply containing the cost for this turn, the number of tokens, and peak/off-peak pricing, for example:
¥0.093 · 942k tok · 峰
Hovering over it reveals details, including tokens for this turn, non-cache hit input, cache hit rate, output, peak/off-peak pricing, and the model name, for example:
本轮 942k tok · 输入 4.9k · 缓存命中 931k(99%) · 输出 5.8k · 峰时价 · deepseek-flash
It solves the problem of “invisibility of per-turn cost”: no need to expand the usage panel, nor to calculate manually.
Core Features¶
The following explains the plugin’s accounting method, which is key to understanding the displayed numbers.
- Pricing is in RMB per million tokens, sourced from the DeepSeek official pricing page https://api-docs.deepseek.com/zh-cn/quick_start/pricing.
- Display is split into a summary line and a hover detail view; the items in the details correspond to the pricing table above.
| Item | Off-peak | Peak |
|---|---|---|
| Cache Hit Input | ¥0.02 | ¥0.04 |
| Non-cache Hit Input | ¥1 | ¥2 |
| Output | ¥4 | ¥8 |
- Peak time = Beijing Time “Mon-Fri 09:00–12:00, 14:00–18:00”; other times (including weekends) are considered off-peak.
- Cache writes (
cacheWriteTokens) are charged at the non-cache hit input rate, as there is no separate cache write tier in the official pricing. reasoningTokensare part ofoutputTokensand are not added up separately.- Models with
proin the name are charged at 3 times the Flash rate. - The built-in holiday judgment is simplified to only consider weekends and lacks a built-in public holiday schedule. If a public holiday occurs, it is calculated using the weekday peak/off-peak rules, resulting in a slightly higher cost than actual.
Installation and Enabling¶
The installation commands provided in the README are as follows. The first installs from GitHub, the second from a local directory:
# 从 GitHub
dsh plugin --profile desktop add github:<你的用户名>/dsh-turn-cost
# 或本地目录
dsh plugin --profile desktop add /绝对路径/dsh-turn-cost
After installation, the desktop client needs to be restarted because the host side needs to reload the plugin.
Typical Usage¶
After installation and restart, the plugin requires no extra configuration. During a conversation, a line of cost information automatically appears below each reply; hovering shows the details. There are no writable configuration files after installation, nor are there manual commands to execute.
How it Works¶
The plugin consists of two parts.
- Host side
lib/index.js: Subscribes tosession/event, sums up theassistant/messageusage for each(session, turn)(separately recording cache read, non-cache hit input, cache write, and output), determines peak/off-peak based on the turn end time and converts to RMB, exposing a query interface viaGET /dsh-turn-cost/turn.json?turn=&seq=. Usesseqas the primary key to avoid mixing up accounts when two sessions happen to have the same turn number. - Browser side
lib/client.js: Registers a component into theconversation.chat.turnTailslot, rendering that line of text below each reply. All data comes from the interface above, avoiding redundant calculation of prices in the browser.
Applicable Scenarios and Notes¶
Suitable for developers who want to see per-turn costs directly in the conversation flow rather than repeatedly expanding the usage panel. A few points to note:
- The plugin runs with the permissions of the current dsh process; source code and license (MIT) should be checked before installation.
- Only counts turns that occur after the plugin is loaded; historical conversations are not backfilled.
- Records are kept in memory and cleared when the process restarts.
- Peak/off-peak determination uses the local clock converted to Beijing Time (+8 hours), without verifying if the system time zone is correct.
- Privacy-wise, it only reads the usage numbers from DSH’s own session events; all calculations are done locally, without connecting to the internet, uploading, or writing files; the router only listens on the local web server and is not exposed externally.
Conclusion¶
The value of dsh-turn-cost lies in compressing per-turn costs into a single line that can be read at a glance, saving the steps of expanding the panel and manual calculation. Directory page: https://www.skillhub.cn/plugins/inzia005/dsh-turn-cost, Source code: https://github.com/inzia005/dsh-turn-cost.