Preface¶
When running conversations in DeepSeek Harness (DSH), the UI shows token breakdowns: uncached input, cache reads, cache writes, and output. These numbers tell you “how much was used,” but they don’t directly map to “how much it cost”—especially since DeepSeek’s official price list distinguishes peak and off-peak time slots, where the same bucket of tokens carries different unit prices at different times.
If you’re already using the community widget dsh-whale-widget for balance monitoring, you’d want the estimates in the usage popup to be consistent with the widget’s figures. Below is the client-side plugin dsh-usage-cost released by maintainer O789Real: it appends CNY amounts to the right of each token row in DSH’s built-in “Usage” popup and adds a total row at the end; the pricing and peak/off-peak rules are sourced from the same origin as dsh-whale-widget (DeepSeek’s official CNY price list + peak/off-peak pricing).
What is this¶
dsh-usage-cost is a standard DSH bundle plugin (npm package name dsh-usage-cost, current version 0.2.0, MIT license). The maintainer developed and verified it on DSH 0.2.0-rc.2 (desktop / Web); package.json declares compatibility with dsh version >=0.2.0-0 <0.3.0-0.
The plugin consists of a host half (lib/index.js: registering static routes, injecting the loading script into the page) and a browser half (assets/usage-cost.js: pricing, peak/off-peak, annotations, reporting). It does not read conversations, does not track billing, and does not interfere with model requests; it only appends nodes to the existing official DOM, takes effect globally and automatically for all conversations, without per-conversation toggles or extra buttons.
Core Features¶
The two popups covered¶
- The per-turn usage popup opened from the “Usage xx” pill below each answer.
- The popup opened from the Token usage session-level pill below the input box.
UI effect¶
Displays the corresponding amount to the right of each token number row, and appends “本轮费用” (this turn’s cost) or a session-level total at the end of the dl. Example (from the project README):
本轮用量 888,131 tok
─────────────────────────────────────────────────────────────
提供方 / 模型 deepseek-account/deepseek-flash
缓存命中 99.97%
未缓存输入 296 tok ¥0.000592
缓存读取 886,912 tok ¥0.0355
缓存写入 0 tok ¥0.00
输出 923 tok ¥0.007384
本轮费用 ¥0.0435(高峰价)
Pricing basis¶
- Unit price: yuan / million tokens, each token category is a
[off-peak price, peak price]pair. - Supported model prices (README table):
deepseek-flash(including old names such asdeepseek-v4-flash): cache hit 0.02 / 0.04, miss 1 / 2, output 4 / 8.deepseek-v4-pro: cache hit 0.15 / 0.30, miss 4.5 / 9.0, output 13.5 / 27.0.- Peak/off-peak: Beijing time, Monday to Friday (excluding statutory holidays) 9:00–12:00 and 14:00–18:00 are peak hours; all other times (including weekends, weekends reclassified as working days, and statutory holidays all day) use the off-peak price; peak price = off-peak price × 2.
- Per-turn usage popup: peak/off-peak is determined by the actual time the turn occurred (tracing back from the open pill to
[data-turn-tail], reading the clock at the end of that turn’s action row), not by the time you opened the popup. The total row is labeled(高峰价)/(谷价). - The session-level Token usage total spans multiple turns and cannot be attributed to a single time period; it is estimated using the current time period’s unit price, with the note
(按当前时段价). - Amounts are local estimates, not official bills; they are consistent with the “per-turn consumption” basis of the whale widget; actual consumption is still subject to official bills and the widget’s balance monitoring.
Runtime characteristics¶
- Uses MutationObserver with a 1.5s polling fallback, automatically re-applying annotations after official re-renders.
- Uses only Node built-in modules, with no runtime npm dependencies; the browser half is a classic script (not an ES module).
Installation and Activation¶
The plugin runs with the permissions of the current DSH process. Before installing, it is recommended to review the GitHub repository source code and MIT license to confirm it meets your environment policy.
Recommended: one-line install via DSH CLI¶
Replace --profile with your profile name (generally desktop for the desktop app, commonly web for pure Web deployments):
dsh plugin --profile desktop add dsh-usage-cost
You can also install it in DSH under Settings → Plugins. For local development, you can point to the source directory:
dsh plugin --profile desktop add link:/绝对路径/dsh-usage-cost
Windows: PowerShell script¶
powershell -ExecutionPolicy Bypass -File .\install.ps1
To uninstall:
powershell -ExecutionPolicy Bypass -File .\uninstall.ps1
Installs to E:\deepseekharness\.dsh\profiles\desktop by default; use -ProfileDir "<path>" to switch profiles.
How to activate after installation¶
| UI | Action |
|---|---|
| Desktop app window | Fully quit and reopen DeepSeek Harness (the injection table is collected at host startup; there is no hot refresh). |
Browser access http://127.0.0.1:<port>/ |
Just refresh the page (F5). |
If only assets/usage-cost.js was modified, refreshing the page is sufficient; modifying lib/index.js requires restarting DSH.
Typical usage and price overrides¶
After installation and restart (or refresh), just use DSH conversations normally: click a usage pill to open the popup, and amounts will automatically appear to the right of the tokens. The built-in price list works without any configuration.
If DeepSeek officially adjusts prices, you can override individual fields in <DSH_HOME>/usage-cost-pricing.json, without restart or refresh—the latest values will be read each time a popup is opened. Example:
{
"currency": "¥",
"models": {
"deepseek-flash": { "hit": [0.02, 0.04], "miss": [1, 2], "out": [4, 8] },
"my-gateway-model": { "hit": [0.1, 0.2], "miss": [2, 4], "out": [8, 16] }
},
"peakHours": [[9, 12], [14, 18]],
"holidays": { "2027-01-01": 1 }
}
The built-in price list is located between the @pricing-core markers at the top of assets/usage-cost.js; when official prices change, both the browser half and the optional override file need to be kept in sync with dsh-whale-widget. After the State Council publishes the following year’s holiday schedule each November, holiday dates must be added (both HOLIDAY_VALLEY in the plugin and the widget side need to be updated).
Self-check and troubleshooting¶
When amounts do not appear in the UI, you can check in the order suggested by the README:
- Whether
http://127.0.0.1:19387/dsh-usage-cost/healthreturns 200 (host half and routes). - Whether
clientJsServedin the response is greater than 0 (whether the page received the client script). - The
censusfield inhttp://127.0.0.1:19387/dsh-usage-cost/report(whether popups and pills are recognized by the script).
Other diagnostic entry points: /dsh-usage-cost/pricing.json (currently active price list), <DSH_HOME>/usage-cost-host.log, <DSH_HOME>/usage-cost-report.jsonl. You can run npm test in the repository for offline probes (syntax, price list, fake DOM annotation behavior).
Use cases and notes¶
Who it’s for: Developers and users who frequently check token breakdowns in DSH, want to see CNY estimates right in place, and are already using or plan to use dsh-whale-widget for reconciliation.
Boundaries (README “Known boundaries”):
- Session-level totals are only estimates for the current time period, as already noted in the UI.
- Mainly recognizes official Chinese and English locale row labels; other languages may fall back to text heuristics, and there may be cases where annotations fail.
- If the official side significantly changes the usage popup DOM or removes the turn clock, peak/off-peak tracing or annotations may be affected.
- Plugin directories (such as the SkillHub plugin page) are community listings and have no official affiliation with DeepSeek / High-Flyer; the DSH ecosystem follows “everything is a plugin”—please review the code yourself before installing third-party bundles.
Conclusion¶
dsh-usage-cost extends DSH’s built-in usage popup from “pure token counts” to “tokens + per-turn peak/off-peak CNY estimates”, and shares the same official price list and peak/off-peak rules as dsh-whale-widget. If you need to directly reconcile the input/output costs of each turn in the conversation interface, you can install it with the commands above, and after restarting or refreshing you will see amounts in both types of usage popups.
- Community directory: https://www.skillhub.cn/plugins/O789Real/dsh-usage-cost
- Source code and full documentation: https://github.com/O789Real/dsh-usage-cost