Introduction¶
DeepSeek Harness (DSH) adopts a plugin-based architecture. When using the web interface, developers often need an intuitive view of API consumption, account balance, and the specific token breakdown. Existing approaches may require switching to the official console or inspecting local logs, which is not very intuitive. The dsh-plugin-usage plugin reads local session logs to fully reconstruct usage data, estimates costs based on DeepSeek’s official peak/off-peak rates, and provides a dashboard directly in the DSH interface.
Plugin Positioning¶
This is a client-side plugin maintained by 1998moye and licensed under the MIT license. It is integrated into the DSH input box toolbar, does not use a floating window, and will not cover conversation content.
Installation and Activation¶
Before installing, ensure your environment meets the following requirements:
* Node.js 20+
* DSH 0.1.5 or later
Run the following commands to install:
git clone https://github.com/1998moye/dsh-plugin-usage.git
dsh plugin --profile web add /path/to/dsh-plugin-usage
After installation, restart the dsh web process and force-refresh the browser (Ctrl+F5 / Cmd+Shift+R) to load the plugin.
Core Features¶
The plugin provides the following core capabilities:
- Full History Reconstruction: On startup, scans
$DSH_HOME/sessions/**/session.jsonl.zstdand reconstructs the full usage history, including periods before the plugin was installed. - Account Balance Query: Queries the balance directly from DeepSeek’s official API, distinguishing between the top-up balance and the bonus balance.
- Peak/Off-Peak Time-Based Pricing: Calculates peak/off-peak periods based on Beijing Time and applies different unit prices for different models and billing items (input/output/cache).
- Request and Token Statistics: Counts API requests and splits token details into “cache miss”, “cache hit”, and “output”.
- Trend Charts: Provides consumption trend charts for the last 7 days or the last 30 days.
- Grouped Details: Supports viewing detailed breakdowns grouped by model or API key (provider).
Usage¶
The plugin button is integrated on the right side of the input box toolbar, on the same line as controls such as “Full Access” and “Model Selection”. When an active session exists, the button displays today’s cost.
Click the button to open the dashboard. The dashboard includes the following operations:
- Time Range Switching: Today / This Week / This Month / All (This week starts on Monday, and this month starts on day 1; both are based on Beijing Time).
- Metric View: Cost, API request count, and token consumption.
- Tab Switching:
- Token Tab: View the proportions of cache misses, cache hits, and outputs.
- Balance Tab: View the top-up balance and bonus balance.
Data Sources and Billing Logic¶
All plugin data is sourced from local logs. Logs are persisted to $DSH_HOME/storages/用量看板.json and record only numeric token and cost values, without storing conversation content.
Balance queries are initiated by the host process. The API key is taken from DSH credentials and is not sent to the browser.
Costs are estimated based on official pricing and include peak/off-peak logic. Cache hit prices are usually much lower than cache miss prices.
Notes¶
- Log Dependency: The range that can be reported depends on local logs; periods for which logs have been cleaned up cannot be reconstructed. If the time range shown by the official panel is larger than the coverage of local logs, discrepancies between them are normal.
- Billing Differences: Costs are estimated based on token usage and official unit prices. Actual billed deductions may differ slightly due to official price adjustments or the deduction order of bonus balances.
- Data Caching: Balance query results are cached for 30 seconds.
- Dimension Notes: The “API key” dimension in the details is actually
provider. DSH session logs contain only theproviderfield and cannot distinguish between different keys under the same provider. - Button Display: The plugin button is displayed only when a session is active. The welcome page does not have an input box toolbar, so the button is not shown.
Summary¶
By reconstructing local logs and estimating costs from official pricing, this plugin provides DSH web users with transparent usage and cost monitoring. It is suitable for agent developers who need precise control over API consumption costs. The project source code is available on GitHub.