Introduction¶
When running long sessions in DSH Web, the interface usually displays a built-in statistic, such as 38.4M tok · Cache hit 99.6%, indicating token consumption and cache hit rates. This line answers “quantity” but does not directly answer “how much did this session cost based on the official price list?”
To reconcile accounts or control costs, one often has to manually multiply bucketed tokens by unit prices and distinguish between peak and off-peak hours. dsh-plugin-token-cost is a community client plugin that combines precise bucketing reported by the server with the price list in the profile. It displays a reference amount next to the composer and can be expanded to verify the token count, unit price, and billing rules for each tier.
The following describes the plugin’s positioning, capabilities, installation, configuration, and the boundaries of the billing methodology you accept by using it.
What is this¶
- Repository: jessicacui99/dsh-plugin-token-cost
- Maintainer: jessicacui99
- Category: Client (Web)
- Version (package.json): 0.1.0
- License: MIT
The plugin displays the token cost incurred by the current session in real-time next to the DSH Web input box (defaulting to display in RMB). Token counts are derived from the server-side tokenUsage projection, not local character estimation; amounts are calculated by multiplying bucketed token counts by the price list configured in your profile (or the built-in default).
Core Features¶
Precise Bucketing, Not Local Estimation¶
The server reports four buckets: cache-hit input, cache-miss input, cache write, and output. The plugin accumulates usage for the current session based on these four buckets, consistent with the “Token counts are exact” statement in the README.
Amount and Details¶
The token count for each bucket is multiplied by the corresponding unit price in the price list to obtain the itemized amount. The interface displays the total in a pill form; clicking it expands the view: showing token count, unit price, and item amount for each tier, and listing both peak and off-peak unit prices simultaneously (the currently active one is marked), facilitating reconciliation with official bills.
Interface Position and Period¶
The display is positioned adjacent to the built-in token statistics bar, with matching font size and height. Peak/off-peak can be automatically determined by UTC by default (Monday to Friday 01:00–04:00 and 06:00–10:00 are peak hours); it can also be fixed to peak or off-peak in the configuration without following the clock.
Built-in Default Price List (Peak Price)¶
The unit of the built-in table is RMB / million tokens, and the values in the table are peak prices; off-peak prices are converted at display time based on “off-peak = half of peak” (consistent with the README’s description of official rules).
| Model | Hit / Miss / Output (¥/1M tok, Peak) |
|---|---|
| deepseek-flash | 0.04 / 2 / 8 |
| deepseek-v4-pro | 0.30 / 9 / 27 |
Models not configured in the price list will display a prompt and will not silently show ¥0.
Installation and Enablement¶
The plugin targets the web profile. The installation command follows the repository README:
dsh plugin --profile web add github:jessicacui99/dsh-plugin-token-cost
If you already have a plugin directory checked out locally, you can also install using an absolute path (as per the English section of the README):
dsh plugin --profile web add /absolute/path/to/dsh-plugin-token-cost
Notes:
- The host side automatically mounts when
patchReload: liveis enabled in the profile; the browser side requires a page refresh to see the client UI. - No separate build step:
lib/client.jsis a handwritten bundle depending only on React andreact/jsx-runtime; the host side does not import third-party packages.
It is recommended to browse the repository source code and MIT license before installing; the plugin runs under the permissions of the current DSH process. Like other client plugins in the directory, the trust boundary depends on the code you install.
Custom Prices and Periods¶
If the prices do not match the billing, you can override the config of the token-cost plugin in ~/.dsh/profiles/<profile>/cordis.patch.yml. Note: a patch replaces the entire config segment, so you must write out all fields you wish to retain; you cannot just write the changed items.
- id: token-cost
config:
currency: CNY # Only affects display symbol (¥ / $ / €)
period: auto # peak | off-peak | auto
models:
- model: deepseek-flash
provider: deepseek-official
inputCacheHit: 0.04 # RMB / 1M tokens, peak unit price
inputCacheMiss: 2
output: 8
- model: deepseek-v4-pro
provider: deepseek-official
inputCacheHit: 0.3
inputCacheMiss: 9
output: 27
Invalid configurations such as negative numbers, missing model, or misspelled period will cause a loading failure rather than running silently with incorrect prices.
Typical Usage¶
- Run the aforementioned
dsh plugin --profile web add ...in the web profile to complete installation. - Refresh the DSH Web page and view the cost pill next to the built-in token statistics alongside the composer.
- Click the pill to view bucket details and the comparison of peak/off-peak unit prices.
- If you need to fix the pricing to peak or off-peak, set
periodtopeakoroff-peak; otherwise, keepautoto follow UTC rules. - If official prices change or the price list differs from the built-in table, complete the
cordis.patch.ymlas described in the previous section and reload the profile.
Applicable Scenarios and Notes¶
Suitable for: Developers debugging agents for long periods on the Web, needing to observe “reference costs” as the session progresses, and wishing to reconcile bills using bucket details.
Boundaries (Explicitly stated in README, please accept these when using):
- The displayed amount is a reference value, not an official bill: For example, cache writes are calculated at the “miss” price; peak/off-peak follows UTC rules or your
periodsetting; the price list needs updating if official prices or rules change. - In long sessions, the entire context is resent for each request, so prompt tokens increase with turns (cache hits dominate). This is the billing model itself, not duplicate counting by the plugin; duplicate records for the same turn/step are replaced rather than accumulated.
- Subagent consumption is not included in the parent session numbers; they are independent sessions.
- If the model is switched mid-session, the accumulated tokens are priced entirely by
modelSelection.lastUsed(the current model);tokenUsageis a total log sum and is not split by model. - Current Session Only: The numbers reset to zero when switching sessions.
The DeepSeek Harness ecosystem emphasizes “Everything is a plugin”; the community directory SkillHub Plugin Page is an independent site with no official affiliation with DeepSeek / High-Flyer.
Conclusion¶
dsh-plugin-token-cost connects the server’s four-tier token usage and a configurable price list to the Web composer. It adds the “how much did I spend” dimension while retaining built-in token statistics, and supports expanding to verify peak/off-peak unit prices. Installation follows the README command dsh plugin --profile web add github:jessicacui99/dsh-plugin-token-cost; prices and periods can be fully overridden in cordis.patch.yml.