dsh-cost: Viewing Account Balance and Session Costs in the DSH Web Interface

Preface

When running long sessions in DeepSeek Harness (dsh), the official stats line reports activity and usage, but it does not combine “whether it is currently peak or off-peak, how much balance remains in the account, and roughly how much this session has cost” into a single display. If developers want to align with the official billing rules (half-price off-peak, the 2026 price adjustment, and the pro→flash routing), they often have to consult the documentation themselves or reconcile afterwards.

Below is the community plugin dsh-cost (npm package name dsh-cost-pill, repo Arun1016/dsh-cost). It adds a cost pill to the far right of the official stats line, below the session composer, combining the billing period, account balance (optional), and the current session cost; clicking it expands per-bucket and per-model details. The cost side requires no credentials; the balance side requires a DeepSeek API key, and the plugin does not write the key to disk.

Community plugin; no affiliation with or endorsement by DeepSeek.

What is this

dsh-cost is published by the maintainer Arun1016 and categorized as a client (Web GUI injection). It registers to conversation.composer.dock with order: 2, positioned after the two official pills activity (0) and usage (1).

The core capabilities are summarized as follows:

  • Far-right pill on the stats line: shows Peak during peak hours and Off-peak during off-peak hours, distinguished by a red/green dot; also shows balance and session cost (only the balance segment is missing when there is no key).
  • Popover details: billing period, balance, total session cost, plus per-bucket costs for cache-hit input, cache-miss input (including cache write), and output; when the host can fold by model, a per-model breakdown is also provided.
  • The price table is bundled with the plugin, covering the 2026-09-10 price cut and the pro→flash routing; during the session, usage is folded per request, so two rate sets are never mixed across price adjustments, routing changes, or peak/off-peak boundaries.
  • Bilingual (Chinese/English): 14 dictionary entries under the cost-stats namespace, switching with the application locale.

Environment and Dependencies

  • DeepSeek Harness >= 0.2.1-rc.2 (see engines.dsh in package.json).
  • To view the balance: a DeepSeek API key is required. It is resolved through dsh’s credentials seam; the environment variable DEEPSEEK_API_KEY is used as a fallback only when the credentials service itself is unavailable — if credentials exist but there is no key, the environment variable will not be read. When using only a DeepSeek account login without a key, the pill still shows peak/off-peak and session cost, and the balance segment does not appear.

Installation and Activation

The plugin can be searched in the plugin marketplace as dsh-cost; the terminal install command is as follows (see the README):

dsh plugin --profile <profile> add dsh-cost-pill

Install from the GitHub source:

dsh plugin --profile <profile> add github:Arun1016/dsh-cost

Note: the bare npm name dsh-cost belongs to an unrelated project; this plugin is published under the @arun_1016/ scope and is not to be confused with the former. In current materials the package version is 1.0.2 and the license is MIT.

Please review the repository source code and license yourself before installing; the plugin runs under the permissions of the current dsh process, and as with all DSH plugins, the trust boundary depends on your review of the maintainer and the code.

Configuration

The only configuration option is holidays, used to replace the built-in 2026 China statutory holiday table (国办发明电〔2025〕7 号, Beijing local YYYY-MM-DD). After crossing a year, simply update the Config instead of changing the code.

- id: cost-stats
  name: dsh-cost
  config:
    holidays: ['2026-01-01']   # statutory holidays bill off-peak all day

Peak/off-peak clock: weekdays 09:00–12:00 and 14:00–18:00 are peak hours, and the rest are off-peak; weekends and statutory holidays are off-peak all day. The clock uses the local time of the machine running dsh; the official windows are defined in Beijing time, so readings match the official ones exactly only when the host is on Beijing time.

Typical Usage and Interface Behavior

  1. After installing and enabling the plugin, open the dsh Web GUI; the cost pill appears at the far right of the stats line below the session composer.
  2. Without an API key you can still see peak/off-peak and session cost; after configuring a key the pill will include the balance.
  3. Click the pill to open the popover and view per-token-bucket costs and per-model costs within the session (when the host supports folding).
  4. The browser only requests the host route /api/dsh-balance (once per session step, plus 60 s polling) and does not connect directly to third parties; the balance query is performed host-side against https://api.deepseek.com/user/balance (15 s timeout), and the key is used only in-process and never persisted.

Billing Model (Data Summary)

Prices are in CNY / million tokens; the following table gives peak-hour unit prices, with off-peak at half.

Item Rule
Flash (from 2026-09-10 12:00 Beijing time) Uncached input / cache-hit input / output: 2 / 0.04 / 8
Flash (before the price cut) 3.0 / 0.1 / 9.0
Pro (deepseek-v4-pro, before 2026-09-14 12:00 Beijing time) 9.0 / 0.3 / 27.0
pro→flash routing Billed as Flash from 2026-09-14 12:00 Beijing time
inputTokens Uncached input; cache write is billed at the uncached rate
reasoning Part of the output subset; not billed separately

Applicable Scenarios and Considerations

Suitable for: developers who debug agents for long periods in the dsh Web, need to see “how much this session cost” against the official peak/off-peak and price-adjustment rules, and optionally monitor the account balance.

Privacy and Networking (README Privacy): no telemetry, no third-party endpoints; the browser does not connect directly to the Internet to check the balance. Balance failures (no key, invalid key, network error, timeout) silently return a 200 without balance_infos, and are cached for 30 s; after a recharge, it may take up to about 30 s to refresh. The process-level balance cache is invalidated per key.

Known limitations (excerpt):

  • Sessions that have already been detached are aggregated and priced by the host at the current Flash rate, with no estimation marker; the browser-side fallback estimate is marked (估) / (est).
  • If the host route is missing or errors, the entire pill is silently hidden, with no placeholder or error indication; after a failure, per-step polling stops and only 60 s polling remains.
  • Costs are precise to 4 decimal places below ¥0.01; display always carries the ¥ prefix.
  • The built-in holiday table covers only 2026; unrecognized model ids are priced by the Flash table; the popover has no height cap and is not mutually exclusive with the official pill popover.
  • Costs are accumulated per request; rounding may differ slightly from the invoice.

Conclusion

dsh-cost consolidates peak/off-peak, balance, and session cost into a single pill on the stats line, and performs per-bucket and per-model display according to official rules; peak/off-peak and session cost can be viewed without a key, and a key adds the balance without writing credentials to disk.

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

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

Xiaoye