Preface¶
When running long sessions and multi-turn tool calls in DeepSeek Harness (DSH), token consumption adds up quickly. However, the interface does not default to displaying “approximate cost for this turn” or “cumulative cost for the entire session” right in front of your eyes. Manually cross-referencing official price lists, distinguishing between peak and off-peak hours, and estimating by splitting buckets for cache hits/misses/output is both tedious and error-prone.
dsh-cost-meter is a community-maintained DSH plugin. It places a persistent capsule directly below the input box, using DeepSeek’s official peak/off-peak pricing and the actual usage data from session logs to perform estimates. It displays “Current Response” and “Session Consumption” separately and can be expanded to show per-turn details. The following section introduces its capabilities, installation methods, and usage notes.
What is this¶
- Name: dsh-cost-meter (npm package name
@local/dsh-cost-meter, version 1.0.0) - Maintainer: Lopncod
- Category: Model Inference (classified under the community directory SkillHub)
- Repository: github.com/Lopncod/dsh-cost-meter
- Positioning: A cost meter plugin for DSH Web / Desktop clients; amounts are estimated based on official DeepSeek peak/off-peak rates and are not an official bill.
The DSH ecosystem advocates “Everything is a Plugin”; community directories like SkillHub are independent sites and have no official affiliation with DeepSeek / High-Flyer. Before installation, please review the source code and the MIT license yourself. The plugin runs under the permissions of the current DSH process.
What the interface displays¶
The capsule generally looks like this on a single line:
Session Consumption ¥1.23 · Current Response ¥0.087 Off-Peak Rate · Switches to Peak in 2h15m
The meanings are as follows:
- Current Response: The estimated cost of the most recently completed turn; refreshed with a flash notification when the turn ends.
- Session Consumption: The cumulative estimate for the current session, including the ongoing turn.
- Peak/Off-Peak Indicator: Indicates whether the current calculation uses off-peak or peak rates, and shows a hint regarding the time remaining until the next rate switch (when
peakMode: "auto").
Clicking the capsule expands the per-turn details: cost per turn, four token buckets (cache hit read / cache miss read / cache write / output), effective unit price per turn, peak/off-peak markers, and steps within the turn. If there are multiple sessions in the ledger, it also lists all locally recorded sessions and their total.
Pricing Methodology¶
The plugin estimates costs based on DeepSeek’s official price list (RMB / million tokens) and peak/off-peak pricing rules. The built-in tables (Flash / Pro) are as follows:
| Billing Bucket | Description | Flash Off-Peak / Peak | Pro Off-Peak / Peak |
|---|---|---|---|
| Cache Hit Read | Input reusing prefix cache | 0.02 / 0.04 | 0.15 / 0.30 |
| Cache Miss Read | Input not hitting cache | 1 / 2 | 4.5 / 9 |
| Cache Write | Input written to cache (charged at miss rate) | 1 / 2 | 4.5 / 9 |
| Output | Completion (including reasoning tokens) | 4 / 8 | 13.5 / 27 |
- Peak Hours: Monday to Friday 09:00–12:00, 14:00–18:00 Beijing Time; other times (including weekends and all-day Chinese public holidays) are charged at off-peak rates.
- The displayed amounts are estimates; actual deductions are subject to the balance on the DeepSeek side.
Token Data Source¶
The four buckets are derived from the actual usage contained in assistant/message events within the session logs; tokens are not estimated:
inputTokenscorresponds to the uncached bucket and is mutually exclusive withcacheReadTokensandcacheWriteTokens. The sum of these three constitutes the total prompt volume (consistent with thetokenUsageprojection in DSH@deepseek-ai/dsh-token-meter).reasoningTokensbelongs to theoutputTokenssubset and is not billed separately again.- Recalculations for the same
(turn, step)replace previous values rather than accumulating;llm/retry-startedreopens the replacement slot to prevent retries from counting a single turn twice.
Installation and Activation¶
Install the bundle using DSH’s Plugin Manager. Choose one of the following:
Local directory or cloned repository path:
plugin_manager action: install_bundle target: <absolute path to this directory or this repository>
Directly pointing to GitHub:
plugin_manager action: install_bundle target: github:Lopncod/dsh-cost-meter
Restarting DSH is required after installation. The README explains: The host half imports ESM modules at startup; modifying files or re-enabling the bundle while running will not trigger a reload.
Optional Configuration¶
Configuration file path: $DSH_HOME/.dsh-cost.json (Windows default C:\Users\<user>\.dsh\.dsh-cost.json). Changes take effect automatically upon saving; no restart is needed.
{
"peakMode": "auto",
"defaultModel": "deepseek-flash",
"rates": {
"my-proxy-flash": { "hit": 0.01, "miss": 0.5, "out": 2 }
}
}
| Field | Description |
|---|---|
peakMode |
"auto" (default, determines peak/off-peak based on Beijing Time) / "always" (all peak rates) / "never" (all off-peak rates) |
defaultModel |
Model name used to select the price list when request/header is missing |
rates |
Custom unit prices; key is a model id substring (longest match priority); value {hit, miss, out} is RMB/million tokens; a single number indicates the same price for peak/off-peak; key _default changes the fallback price |
Ledger file: $DSH_HOME/.dsh-cost-ledger.json (records per session and per turn). Deleting it only affects historical display; subsequent events will accumulate again.
Read-only HTTP Interface¶
The host half provides read-only routes via ctx.webServer (DSH browser authentication fences are applied only to /api; these routes are unaffected):
| Route | Purpose |
|---|---|
GET /dsh-cost/state?sessionId=<id> |
Current session + summary of all sessions + peak/off-peak status; if sessionId is not in the ledger, it falls back to the most recent recorded session and includes fallback: true |
GET /dsh-cost/rates |
Effective built-in / custom price list |
GET /dsh-cost/debug |
Complete URLs of the last 12 /state requests, useful for troubleshooting whether the page is polling and which id it is using |
Same-origin scripts can also directly request the paths above.
Use Cases and Known Limitations¶
Suitable for: Developers who write agents daily in DSH, tune long sessions, need to see a RMB estimate for “this turn / the whole session” at a glance, and are willing to interpret the numbers according to official peak/off-peak and four-bucket rules.
Limitations (from README):
- Only counts turns after the plugin is enabled; old sessions run before enabling have no history.
- Sub-agent sessions are accounted separately by their respective
sessionIdand are not included in the parent session’s row; however, the grand total includes them. - Sessions created via fork / resume only accumulate new events occurring within the current process; the copied historical prefix is not billed again.
On the development side, you can run npm test to execute 18 tests (covering peak/off-peak boundaries, price list longest match, replacement semantics, ledger JSON round-trip, etc.).
Conclusion¶
dsh-cost-meter consolidates “Current Response / Session” costs and peak/off-peak status into a single capsule below the Composer. Pricing is based on official price lists and actual session usage, with support for custom rates and local ledgers. Community directory page: skillhub.cn/plugins/Lopncod/dsh-cost-meter; Source code and full documentation: github.com/Lopncod/dsh-cost-meter.