In the DeepSeek Harness (DSH) chat interface, it is usually not possible to directly view the cost of an individual conversation turn, the cumulative session cost, or the account balance. xiaml666/dsh-plugin-cost solves this problem. It provides accurate pricing based on the official price list, supports automatic refresh of prices and exchange rates, synchronization of peak/off-peak periods, and multi-currency display.

Installation and Activation

Installing this plugin requires no runtime dependencies and supports installation from GitHub, npm, or a local path. After installation, the dsh web process must be restarted; the client bundle manifest is assembled only once at startup.

# 从 GitHub 安装
dsh plugin --profile web add github:xiaml666/dsh-plugin-cost

# 本地开发安装
dsh plugin --profile web add link:/absolute/path/to/dsh-plugin-cost

Note: pnpm blocks prepare build scripts for git-hosted packages by default. If the initial installation fails, add the key from the error message to the allowBuilds configuration in pnpm-workspace.yaml and retry. This package itself does not need to be built.

After installation, run the restart script:

node scripts/restart-web.mjs

Core Features

The plugin provides three aspects of cost display in the DSH interface:

  1. Cost per conversation turn
    Displayed on the closing action line of the assistant’s response, after token usage and elapsed time. It is collapsed by default; click to expand and view the model routing, call count, and token breakdown details.

  2. Cumulative session cost
    Displayed below the input box, refreshed every 3 seconds by default. Clicking it displays the number of turns, model calls, tokens used, the current model and its unit price, and other information. A settings entry point is provided in the bottom-right corner of the panel.

  3. Account balance
    Reads data from the /user/balance API and refreshes once every 9 seconds (approximately 3 session refresh intervals). The currency displayed for the balance remains consistent with the cumulative session cost, and it is automatically converted when the currency changes.

Peak and Off-Peak Periods

Amounts are calculated according to the official price list, and peak/off-peak periods are synchronized automatically.

  • Period determination: Peak/off-peak is a model property, not a global switch. The plugin determines whether an off-peak price exists based on the current model’s rate row. Models with an off-peak price display the time period and real-time unit price; models without an off-peak price display “same price all day”.
  • Time zone handling: The plugin parses the period descriptions on the official page and displays them according to the user’s time zone. The period descriptions on the official site (Chinese and English) are logically equivalent (for example, Beijing time and UTC+8).
  • Idle periods: The official site only describes them as “the rest are idle periods”. The plugin derives them by taking the complement of the peak intervals, displaying times outside peak periods from Monday to Friday, as well as all day on Saturday and Sunday.
  • Automatic updates: If the official site changes the periods, the plugin will automatically reflect the change on the next refresh, without needing to update the plugin.

Currencies and Exchange Rates

The plugin supports multi-currency display, following the account currency by default.

  • Primary currency: You can select “Follow account” in the panel (default, i.e., the currency reported by the balance API) or specify a three-letter code.
  • Secondary currency: You can configure secondaryCurrency; for example, display RMB as the primary currency and USD in parentheses.
  • Exchange rate conversion: Exchange rates come from a public per-USD exchange rate table and are refreshed according to fxRefreshHours. Balance readings are converted and displayed in the current currency, ensuring that the balance and cumulative session cost use the same currency.

Configuration and Settings

The configuration file is located at $DSH_HOME/plugin-cost.json (on Windows, typically C:\Users\<you>\.dsh\plugin-cost.json). It is generated automatically on first startup.

The panel provides the following settings sections:

  • Current model: Read-only; displays the model name, peak/off-peak status, and unit price details (including non-cached input, cached input, and output).
  • Currency: Primary currency selection, secondary currency, and custom code.
  • Peak/off-peak: Follow the official site or customize time periods (time zone, days of the week, intervals, off-peak multiplier).
  • Display: Controls the display of account balance, token details, and peak period description.
  • Automatic updates: Catalog address, refresh interval, and status of each channel.

Note: The panel does not provide a rate editor. Rate-related configuration (such as routes and models) must be edited directly in the configuration file or updated through the price catalog; these fields are not sent when saving from the panel.

Price Catalog and Routing

The plugin supports wildcard route configuration, allowing flexible override of pricing rules for third-party channels.

  • Wildcard support:

    • deepseek-official/deepseek-flash: exact match
    • deepseek-official/*: all models under this provider
    • */deepseek-flash: models with the same name across all providers
  • Multiplier packages: Supports adjusting the multiplier for known routes via the multiplier field.

  • Price catalog: catalog/prices.json is an out-of-band update channel. The plugin includes a built-in catalog; you can point catalogUrl to a JSON file with the same structure over the network, allowing prices to be updated without releasing a new version. The catalog supports the retiredAt and billAs fields for automatically switching pricing after a model is retired.

Notes

  • The plugin runs with the permissions of the current dsh web process; you should check the source code and license before installation.
  • Balance readings stay consistent with the current currency and do not become inconsistent.
  • In the price catalog, providers such as openai and google contain only metadata without price data in the default catalog; they need to be supplemented manually or through the configuration file.