dsh-cost-meter: Display session cost of official channel in the DSH bottom readout line

Introduction

The DeepSeek Harness (DSH) footer stats line aggregates token usage, cache hit rates, etc., but does not directly show “how much it cost.” DeepSeek’s official pricing is divided into peak and off-peak time slots, and the unit prices for the three token types (cache hit, uncached input, and output) differ. If you try to rough-calculate it yourself with a calculator, the result often doesn’t match the bill.

Below is an introduction to the community plugin dsh-cost-meter (repository mmd134312/dsh-cost-manager). It adds a “CNY X spent” cell at the end of the native reading line, accumulating costs in real-time based on official peak/off-peak price lists. It only tracks DeepSeek official provider routes; it does not display or guess costs when using third-party proxies. The maintainer is mmd134312, the license is MIT, the current package version is 1.2.1, and it is categorized as a DSH Extension (extension, display name “Cost Meter”).

What is this

dsh-cost-meter is a “session-level electricity meter” installed for DSH: it maintains an independent ledger for each session, appearing on the same line as the native stats at the bottom with aligned styling. Hovering over it merely adds a grey background; clicking it expands a panel above showing the breakdown (three token types, peak/off-peak status, pricing version, model, etc.). Billing data is stored in ${DSH_HOME}/dsh-cost/ledger.json (v2 schema).

Core Features

Only recognizes official provider routes

Whether billing applies depends on the provider route name, not the model name. It recognizes defaults such as deepseek-official, deepseek-account, deepseek, deepseek-api-key, as well as custom routes starting with deepseek-. Third-party proxies (e.g., DeepSeek model names inside certain aggregator sites) are not billed and do not alter the reading line. Additional routes can be written into providers in cost-config.json.

Peak/Off-peak and Three Token Types

  • Peak/Off-peak: Based on Beijing time Asia/Shanghai; weekdays 9:00–12:00 and 14:00–18:00 are peak hours (price ×2 compared to relatively idle slots), and the rest are off-peak (approximately half of peak); weekends and configurable holidays are treated as off-peak.
  • Three Token Types: Cached input, uncached input, and output are priced separately. The hit rate and billing share the same source (hits / (hits + misses)).
  • Price List: Includes a source version (e.g., 2026-09-10 in the README example), segmented by effectiveFrom. Historical calls are not retroactively charged at new prices; unknown models are marked as “Unpriced” rather than fabricating an amount.

Accounting Method

  1. One ledger per session: Sub-agents have independent session IDs, and the amount shown at the bottom is for the current session.
  2. Incremental accumulation: During normal operation, each time usage is seen in llm/stream, only one entry is added (if there are multiple usage entries in the same call, only the last one is recorded once).
  3. Retroactive filling: When a session is billed for the first time, it can decompress frames from ${DSH_HOME}/sessions/<slugified-cwd>/<sessionId>/*.jsonl.zstd to fill in history based on message timestamps and usage. The breakdown will label “Contains N retroactive fills.”
  4. Price list fingerprint change: Historical tokens are precisely recalculated only once when the pricing fingerprint changes, and it only adopts the higher price, never the cheaper one, to prevent the displayed amount from shrinking.

Interface

The plugin registers at conversation.composer.dock, placed after the native session-stats (order: 10). Styling aligns with @deepseek-ai/dsh-client-ui-chat StatsPills and the official stats panel CSS to avoid visual disconnect from the native reading line.

Installation and Activation

The plugin is a profile bundle appearing in “Settings → Plugins,” where it can be enabled, disabled, or uninstalled. It requires DSH ≥ 0.2.0-rc.2 (the README states it has been verified on DSH 0.2.0-rc.2 Windows desktop) and Node ≥ 22.19.0. After installation, DSH must be restarted (it is not a pure runtime hot-load of the whole package).

dsh plugin --profile <your profile> add dsh-cost-meter
dsh plugin --profile <your profile> add <git-url-or-path>   # Or from repo/local directory

Uninstallation:

dsh plugin --profile <your profile> remove dsh-cost-meter

For development, install via link from a local directory (changes to client.js support HMR; changes to the host dsh-cost-meter.mjs require a DSH restart):

dsh plugin --profile desktop add link:/path/to/dsh-cost-meter

engines.dsh is merely a declaration. Installing on an incompatible DSH version may result in no installation-time warning but rather runtime errors; please verify versions before installing.

Typical Usage

  1. Install via the commands above and restart DSH.
  2. Converse normally under the official DeepSeek channel; a cell similar to the following will appear at the end of the bottom reading line:
1 turn · 3 steps · 12 tok/s   48.2K tok · Cache hit 93%   CNY 0.42 spent   26%
  1. Click the “CNY … spent” cell to view details (this session’s cost, cache hits, uncached input, cache reads, output, unit prices, billable call count and retroactive count, current peak/off-peak status and switch countdown, price list version, model, etc.).
  2. If you need to add statutory holidays or custom official gateways, you may optionally create ${DSH_HOME}/dsh-cost/cost-config.json:
{
  "holidays": ["2027-01-01", "2027-02-06"],
  "providers": ["my-official-gateway"],
  "currency": "CNY",
  "showPeakBadge": true
}

The README also mentions a read-only HTTP endpoint GET /dsh-cost/api (documentation is in the repository, refer to it as needed).

Use Cases and Notes

Suitable for: Users who develop and debug primarily on DSH official accounts or official API Key routes and need real-time comparison of DeepSeek peak/off-peak prices and cache structure within a session.

Not suitable for or requires attention:

  • When primarily using third-party proxies, the plugin intentionally does not display costs; the reading line remains consistent with when it is not installed.
  • The plugin runs with the permissions of the current DSH process and will read session logs and write to the ledger; review the source code and MIT license before installation to ensure compliance with your environment policies.
  • Holidays in 2026 are pre-arranged within the plugin based on patterns, not the original State Council text; misidentifying a day as a peak will only affect the pricing tier for a few calls that day, which can be corrected in holidays.
  • The community catalog SkillHub plugin page and GitHub are community distribution channels with no official affiliation with DeepSeek / High-Flyer; the DSH ecosystem emphasizes “everything is a plugin,” and facts in this article are subject to the repository README and package declarations.

Conclusion

dsh-cost-meter supplements a dimension missing from the DSH native reading line: session RMB expenditure based on official channels, peak/off-peak rates, and the three token types, while supporting retroactive tracking and price list version segmentation. For further implementation details, tests (the README claims 108 offline assertions), or changelogs, please read the repository documentation directly.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye