dshx-token-cost: View account balance and token cost estimates by model in DSH Settings

Introduction

When running agents with DeepSeek Harness (DSH), token consumption is scattered across a vast number of session logs, and platform billing statements differ from the metric of “what the cost would be if billed at public API list prices.” To quickly answer questions like “how much money is left in my account” or “which model is eating up the budget these days,” users often have to switch back and forth between the console and local logs.

dshx-token-cost is a client-side DSH plugin published by maintainer callaumyan-design (current version v2.1.0, MIT License). It adds an Usage & Cost page to DSH settings: on one side, it reads the DeepSeek platform interface to display the account balance; on the other, it scans local ~/.dsh/sessions logs to aggregate tokens by day and model, estimating costs based on public price lists from various vendors. The community directory can be found at SkillHub, and the source code is on GitHub.

What is this

In short: dshx-token-cost is a DSH settings page plugin that simultaneously answers two questions—how much money is left in the account (platform balance), and how many tokens were consumed locally per day and per model, and what is the estimated cost based on API list prices (local log statistics).

Access path: Settings → Usage & Cost. The plugin runs with the permissions of the current DSH process; it is recommended to review the repository source code and license before installation or enabling to ensure compliance with your environment policies.

Core Features

Questions the Panel Answers

Question Panel Location
How much is left in the account? Top “Account Balance” card
How much was spent (estimated) during this period? Range Summary → Estimated Cost
Which day was the most expensive? Daily Usage Table (click a row to expand model details for that day)
Which model is eating the budget? By Model Summary Table
Cache hit performance? Range Summary → Cache Hit Rate; Cache Read/Write columns in Daily/By Model tables
How many provider routes does the same model pass through? “N routes” tag after the model name (hover for details)
Tokens and estimated cost per hour? “Usage by Hour” chart (v2.1.0)

Account Balance and Currency

The balance comes from the DeepSeek platform interface. The platform returns multiple wallet records by currency, and the order is unstable. The plugin selects the corresponding wallet to display based on the ¥ / $ you select on the page, without performing cross-currency conversion; other currencies are listed in an “Additionally …” row.

Range Selection and Memory

Options include Current Month / Today / 7 / 14 / 30 / 90 days, or specifying start and end dates via “Custom” (max 365 days). “Current Month” refers to the full calendar month (from the 1st to the end of the month), and the status line echoes the actual date range covered. The range and currency are saved in localStorage under dshx-token-cost/prefs; if unavailable, it falls back to defaults (30 days / RMB).

Cost Estimation Logic

What is displayed is an estimate, not an official bill. The calculation formula is:

Cost = Input × Input Price + Output × Output Price
     + Cache Read × Cache Read Price + Cache Write × Cache Write Price

Prices are based on public API list prices from respective vendors (pricing.js, README records verification as of 2026-10-11). RMB-priced models are calculated based on published RMB prices; USD-priced models are converted from USD prices using an exchange rate. The USD to RMB exchange rate is updated at most once a day, sourced sequentially from open.er-api.com and api.frankfurter.app, and cached in ~/.dsh/dshx-token-cost/rate.json; if that fails, the last known rate is used, or the built-in default of 7.1.

Calibers to note: DeepSeek is uniformly calculated at off-peak prices; weekday peak prices are 2x the off-peak price, so estimates for daytime usage scenarios may be low; some Gemini Flash series use current introductory prices (officially scheduled to adjust on 2027-01-01).

Log Statistics and Performance

Since v2.0.0, the plugin directly decompresses zstd to read session logs and maintains a persistent index (~/.dsh/dshx-token-cost/index.json, retaining 400 days), replacing the method of replaying entire logs via the harness sessionQuery. The README states cold starts take about 2.5 seconds, and steady-state refreshes are in milliseconds. The scan does not read credentials; it only parses the request/header and assistant/message usage fields in logs, attributing provider/model by log order.

The state directory (index and rate cache) can be overridden with the environment variable DSHX_TOKEN_COST_STATE.

HTTP Reporting Endpoint

The Host side provides a reporting interface for the settings page or other integrations to call:

GET /dshx-token-cost/report?days=30[&force=1]
GET /dshx-token-cost/report?from=2026-10-01&to=2026-10-11[&force=1]

from/to take precedence over days, and both ends are inclusive; force=1 forces a refresh of the index and balance cache. The returned structure includes balance and usage (containing daily days, summary by model, v2.1.0’s usage.hours, etc.).

Installation and Enabling

The materials do not provide a unified CLI installation command syntax; installation can be performed via the DSH client’s plugin installation flow from the SkillHub plugin page (dsh.marketplace.profiles in package.json is web and desktop, requiresRestart: true).

After installation, the copy is located at:

~/.dsh/profiles/<profile>/node_modules/dshx-token-cost/

Registration locations for the desktop profile (similar for local file: development):

  • ~/.dsh/profiles/desktop/package.json → dependencies and dsh.profile.bundles
  • ~/.dsh/profiles/desktop/cordis.patch.yml → - id: dshx-token-cost

You must restart the DSH desktop after modifying host routes or bundles. When developing with file: dependencies, pnpm installs a copy rather than a symlink, so changes to source code require reinstallation or copying to take effect.

Typical Usage

Viewing in Settings Page

  1. Start the DSH desktop (or the web profile with the plugin installed).
  2. Open Settings → Usage & Cost.
  3. Select the statistics range and currency; if you need to ignore short-term caches, click “Recount” (equivalent to requesting with force=1).
  4. View tokens and estimated costs in the Daily Usage, By Model Summary, and By Hour charts; on narrow screens, numbers are displayed in a compressed format, with full values in the tooltip.

Offline Verification and Self-testing

The repository provides Node scripts to verify statistics without opening the UI:

node test.mjs 30            # Cost table by day and model for the last 30 days
node test-endpoint.mjs      # Endpoint assertions
node test-client.mjs        # Client rendering assertions (requires react, jsdom)
node test-layout.mjs        # Layout assertions (requires Chrome/Edge)

Dependencies for client and layout tests can be installed via npm install --no-save according to the README, pointing to node_modules via NODE_PATH or DSHX_TEST_NODE_MODULES.

Applicable Scenarios and Notes

Who it is for: Developers who run multiple models and sessions on a single machine with DSH for long periods, needing to see platform balance at a glance in settings and break down local token usage by model into comparable “billed at public API prices” estimates.

Who it is NOT for: Financial reconciliation or official consumption details; when peak/promotional/enterprise contract prices are not fully modeled, there will be discrepancies between estimates and actual deductions.

Permissions and Security: The plugin reads local session logs and requests the platform balance interface, executing with the permissions of the DSH process at installation time. Please read implementations such as index.js, usage.js, rate.js in the Source Repository before enabling.

Ecosystem Note: DSH adopts an “everything is a plugin” extension approach; community directories like SkillHub are maintained by the community and have no official affiliation with DeepSeek / High-Flyer.

Conclusion

dshx-token-cost consolidates “how much money is left on the platform” and “how many tokens were burned per day and per model in local logs, and the estimated cost at list prices” into a single settings page, using a persistent index to compress refresh times for large session volumes into a usable range. For installation instructions and version information, see the SkillHub Directory Page; for implementation details, price lists, and test commands, refer to the GitHub README.

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

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

Xiaoye