Foreword

DSH’s philosophy is “everything is a plugin”. For DSH users, API cost statistics can be implemented as an independent plugin: displaying the current session cost at the bottom of the session and the total accumulated cost globally on the settings page.

The following introduces fflow2023/dsh-usage-cost. It is a lightweight DeepSeek Harness plugin designed for session-level and global API cost statistics.

What is this

dsh-usage-cost is maintained by fflow2023 under the MIT license. It incorporates the “current session accumulated cost” into the statistics row at the bottom of the session and provides a “Cost Statistics” panel on the settings page.

It is a read-only cost estimation plugin: figures are derived based on replaying persistent session logs, and are recoverable after restarts or cold reads. The plugin does not inject prompts, schemas, tools, or messages into the model, resulting in zero direct token impact and no effect on the KV Cache.

Core Features

After enabling, the visible features include:

  1. Display cost on the same line as token statistics at the bottom of the session, including peak/off-peak prices.

  2. Settings → Cost Statistics: Displays total accumulated cost, peak/off-peak split, split by model (V4 Pro / V4 Flash), and a descending list by session.

The billing scope only covers deepseek-v4-pro and deepseek-v4-flash. Other models are counted in unpricedTokens and are not silently charged at incorrect prices.

In terms of implementation, the plugin is pure JavaScript with zero build steps and zero runtime dependencies; on the Host side, it consists of 1 projection unit with O(1) complexity per event.

Billing Scope

The cost unit is Yuan per Million tokens. The plugin calculates costs based on peak and off-peak prices effective at 2026-08-17 00:00 Beijing Time.

Peak hours are 9:00–12:00 and 14:00–18:00 Beijing Time; the rest are off-peak hours, calculated at half the peak price.

Price-related configurations are centralized in the PRICES object in index.js. When prices change, simply modify index.js and bump the version number.

Installation & Enabling

Install from GitHub:

dsh plugin --profile web add github:fflow2023/dsh-usage-cost

Install using package name:

dsh plugin --profile web add @fflow2023/dsh-usage-cost

In a source code checkout environment, replace the dsh installation commands above with the corresponding pnpm dsh plugin --profile web add ... commands.

When installing from Git for the first time, pnpm will prompt you to copy the generated allowBuilds key into that profile’s pnpm-workspace.yaml and run it again. Installing from GitHub requires authorizing the build once.

The plugin’s peer dependencies are:

{
  "@deepseek-ai/cordis": "^4.0.1-rc.1",
  "react": "^18.2.0"
}

Typical Usage

After installing and enabling, view as follows in the interface:

  1. View the current session cost and peak/off-peak prices on the same line as token statistics at the bottom of the session.

  2. View total accumulated cost, peak/off-peak split, split by model, and a descending list by session in “Settings → Cost Statistics”.

It does not inject prompts, schemas, tools, or messages into the model.

Applicable Scenarios & Notes

Suitable for scenarios where you want to view session-level and global API costs for deepseek-v4-pro and deepseek-v4-flash within the DSH web profile.

Usage Notes:

  • The plugin runs with the permissions of the current dsh process; check the source code, MIT license, and dependencies before installing.
  • It is a read-only projection and does not alter model input or affect the KV Cache.
  • Non-billed models are counted in unpricedTokens; do not misinterpret this as billed cost.
  • Price rules are based on peak/off-peak prices at 2026-08-17 00:00 Beijing Time; if prices are updated, the plugin version must be synchronized.

GitHub: https://github.com/fflow2023/dsh-usage-cost