In the plugin ecosystem of DeepSeek Harness (DSH), monitoring the cost of API calls is an important part of fine-grained management. In particular, when facing different model pricing, differences between cache hits and misses, and rate changes between peak/off-peak periods, manual accounting often struggles to be real-time and accurate. az790871109/dsh-cost-tracker aims to address this need. As a Profile plugin for DSH, it provides real-time cost statistics and backend balance management.
Features¶
This plugin achieves real-time billing by listening to the llm/stream event and has the following capabilities:
- Real-time billing and accurate accumulation: It listens to model call streams and immediately accumulates token counts.
- Precise pricing model: It supports per-model unit pricing, distinguishes cached from non-cached tokens, and supports switching between peak and off-peak tiers.
- RMB-only display: Default exchange rate is 7.2; the panel allows manual adjustment of the exchange rate.
- Backend balance management: Provides a recharge entry point and displays balance, current-period consumption, and remaining quota in real time.
- Project and conversation summaries: The top of the panel shows the total cost for the project containing the current conversation, with per-conversation details listed below.
- Interactive floating panel: The panel is draggable and collapsible, and its colors follow the DSH theme.
- Model-queryable: Registers the
deepseek_costtool so the model can be asked directly to view costs. - Cross-process persistence: Statistics state is written to a local file and continues to accumulate after restarts.
- Zero-intrusion automatic startup: As a profile plugin, it is loaded when DSH starts and requires no extra activation.
Installation and Activation¶
The installation process includes copying files and modifying the configuration. The steps are as follows:
- Create the directory and copy the plugin files:
mkdir -p "$DSH_HOME/profiles/web/node_modules"
cp -R . "$DSH_HOME/profiles/web/node_modules/dsh-cost-tracker"
- Modify the configuration file to load the plugin. Append the following content to the end of
$DSH_HOME/profiles/web/cordis.patch.yml:
- insert:
- id: cost-tracker
name: dsh-cost-tracker
- Restart the DSH Web service:
pkill -f "dsh/lib/bin.js web"
dsh web
After restarting, open the page; the cost floating panel will appear in the bottom-right corner.
Usage¶
After installation, you can operate directly via the panel or conversation:
- View costs: Ask the model directly in the conversation “How much money have I spent?”, or check the main reading on the panel.
- Recharge management: Enter an amount in the panel input box and click “Recharge”.
- Switch tier: Click the panel button to switch the billing tier (auto/off-peak/peak).
- Modify exchange rate: Adjust the value in the “Exchange rate” input box at the bottom of the panel.
- Reset statistics: Click the “Reset” button on the panel to reset all data.
- Panel interaction: Hold the title bar to drag the panel; click the title bar to collapse or expand it.
Notes¶
Before using it, note the following limitations and dependencies:
- Data nature: This is a local estimate, not an official bill, and may differ from the official billing records.
- Statistical scope: It only counts calls after the plugin is loaded; historical messages are not included.
- Price synchronization: The price table is hard-coded in
BASE_PRICESinlib/index.js; after official price adjustments, the source code must be updated manually. - State file: Delete
$DSH_HOME/storages/cost-tracker-state.to reset. - Effective method: After modifying
cordis.patch.ymlor the source code, you must restartdsh webfor changes to take effect. - React dependency: The client side must use
factory: function (require) + require("react")to obtain React; a global React cannot be used, otherwise rendering will error. - Dependency environment: The host side depends on
toolsandwebServer; the client side depends onslots(from@deepseek-ai/dsh-client-runtime).
Ecosystem Information¶
- Maintainer: az790871109
- License: MIT
- Repository: https://github.com/az790871109/dsh-cost-tracker