Introduction¶
DeepSeek Harness (DSH) handles interactions in the web interface locally, but it usually lacks detailed Token consumption tracking and account balance monitoring. The dsh-cost-meter plugin solves this pain point by directly displaying DeepSeek session cost estimates and account balance in the bottom status bar.
Plugin Introduction¶
A Web GUI plugin maintained by AnakinCao. It does not participate in model inference; instead, it reads local session logs and the official pricing interface, providing real-time feedback of cost estimates and balance information to users.
Core Features¶
1. Real-time Model Pricing
The plugin obtains the currently selected model via the session.models RPC and displays its real-time price (unit: CNY/1M tokens). The price order is: cache hit / cache miss / output. The plugin supports automatic switching between peak and off-peak pricing (Beijing time; weekdays 9:00–12:00 and 14:00–18:00 are peak hours, and all day on weekends are off-peak hours). Prices update within about 2.5 seconds after switching models.
2. Cost Aggregation and Deduplication
The plugin scans session files in the ~/.dsh/sessions directory and aggregates today’s cost by session.
* Session Merging: Automatically merges subagent sessions into the root session via parentSession.
* Deduplication Mechanism: DSH subagent session files contain the complete events of the parent session. The plugin performs global deduplication using fingerprints of (time, turn, step, count) to prevent duplicate billing (which previously could cause costs to be overestimated by about 5x).
* Workspace Display: The tooltip displays the workspace directory name of the session.
3. Today’s and Session Costs
Cost data is fetched in real time from the official pricing page (cached for 1 hour) and the price is automatically selected based on the effective date (effective 2026-08-17) and time slot. If fetching fails, the plugin falls back to built-in constants.
4. Balance Monitoring
The plugin queries the official GET https://api.deepseek.com/user/balance endpoint every 60 seconds. When the balance falls below the default threshold (BALANCE_WARN_CNY, default 50 CNY), the entire status bar row turns red.
5. Token Type Statistics
The tooltip displays the Token consumption distribution for historical sessions by content type (such as code, reasoning, and tool output), helping with Token optimization.
Installation and Enablement¶
Install using the official CLI:
dsh plugin --profile web add https://github.com/AnakinCao/dsh-cost-meter.git
# restart dsh web
Configuration¶
The plugin requires an API Key to query the balance. The resolution order is as follows:
1. Plugin configuration config.apiKey
2. Environment variable DEEPSEEK_API_KEY
3. DEEPSEEK_API_KEY in ~/.dsh/.credentials.yaml
If no Key is configured, the status bar only displays “balance fetch failed”, but cost estimation still displays normally.
Typical Usage¶
In the bottom status bar, you will see information similar to the following:
stats row · TPS Flash off-peak 0.05/1.5/4.5 · Today ¥11.52 (5 sessions) · Session ¥0.08 · Balance ¥365.36
Hover the mouse over the status bar to view detailed session cost breakdown and price sources.
Notes¶
- Cost Estimation: The displayed values are estimates (official unit price × usage). Authoritative billing is based on the DeepSeek platform.
- Security: Balance and pricing queries run in the host process; the API Key never leaves the browser.
- Resource Usage: The plugin does not consume Tokens and only reads logs; balance queries are cached for 1 hour.
- Uninstall: Delete the plugin directory
node_modules/dsh-cost-meterand remove the patch insertion entry from the configuration file.