Introduction¶
When developing agents with DeepSeek Harness (DSH), tracking cross-session Token consumption, request frequency, and associated costs is the foundation for cost control and performance optimization. The existing official DSH interface usually focuses on real-time conversation and lacks a long-term usage summary view.
Plugin Overview¶
dsh-token-usage-stats is a DSH Web plugin for tracking cross-session Token usage, request count, and optional costs. It provides an independent dashboard page and an entry point at the bottom of the sidebar, making it easy for developers to view detailed usage data.
- Maintainer: jkStars
- License: MIT
- Positioning: Online tool / statistical analysis
Core Features¶
This plugin provides the following core capabilities:
- Cross-session statistics: Records and aggregates Token usage and request counts across all sessions.
- Independent dashboard: Provides a standalone Web page to display statistical results.
- Data source API: Exposes a JSON data source API (
/api/token-usage-stats) for external consumption. - View switching: Supports switching between an hourly view (today) and daily views (last 3 days, last 7 days, last 30 days, all).
- Smart pricing: Supports custom model pricing and includes a built-in two-tier “peak/off-peak” pricing logic based on Beijing time (weekends are treated as off-peak).
- Automatic refresh: Dashboard data refreshes automatically every 10 seconds.
- Sidebar integration: Provides an entry point at the bottom of the sidebar; clicking it opens the dashboard in a modal dialog.
Installation and Enablement¶
Use the official installation command to add the plugin to the Web Profile.
dsh plugin --profile web add dsh-token-usage-stats@0.3.14
After installation, the plugin is automatically injected into the cordis.patch.yml configuration and attempts to auto-load browser-side resources through the dsh.client manifest. After installation, restart the host or refresh the GUI to apply the changes.
Configuration¶
The plugin supports configuring the currency type and model pricing via cordis.patch.yml. Cost amounts are displayed on the dashboard only when pricing is configured.
The default configuration includes the CNY currency and official peak/off-peak pricing for deepseek-flash and deepseek-v4-pro.
Override the sample configuration in your Profile configuration file:
- patch:
- id: token-usage-stats
config:
currency: USD
pricing:
deepseek-flash:
peak:
uncachedInputPerMillion: 2.0
cacheReadPerMillion: 0.04
cacheWritePerMillion: 0
outputPerMillion: 8.0
offpeak:
uncachedInputPerMillion: 1.0
cacheReadPerMillion: 0.02
cacheWritePerMillion: 0
outputPerMillion: 4.0
Pricing Logic:
* Peak hours: Beijing time 09:00–12:00 and 14:00–18:00.
* Off-peak hours: All times outside peak hours; weekends are treated as off-peak for the entire day.
* For models supporting four pricing tiers, the system uses the price of the corresponding tier based on the time of use; for models that use only peak/offpeak tiers, the corresponding tier is used for calculation at any time.
Typical Usage¶
After installing and configuring the plugin, you can access the dashboard in the following ways:
- Sidebar entry: Click the “Usage Statistics” button at the bottom of the sidebar; the dashboard will pop up as a modal dialog.
- Direct access: Visit
http://<host>:<port>/token-usage-statsin a browser.
Once in the dashboard, the default view is “Today” by hour. You can switch the time range using the dropdown menu at the top (Today, last 3 days, last 7 days, last 30 days, all). For the longer “all” range, the chart automatically collapses into natural weeks or natural months to maintain clarity.
Notes¶
When using this plugin, please note the following:
- Statistics scope: Currently, only fees for the official DeepSeek API are counted. It is based on replay calculations from local Harness session logs and does not include API fees from other providers or channels.
- Cost display: Cost amounts are displayed on the dashboard only when model pricing is configured.
- Data source: Data comes from local historical session logs, not from real-time API fee queries.
- Permissions and security: This plugin runs as a plugin; ensure that the installation source is trustworthy and review the source code and license before use.
Conclusion¶
dsh-token-usage-stats is a lightweight statistics tool. Through its dashboard and sidebar entry, it helps developers intuitively track Token consumption trends. With the custom pricing feature, it can accurately calculate costs across different time periods, making it suitable for DSH users who need fine-grained cost control.
For more information and source code, refer to:
* GitHub repository
* npm package page
* Skill Hub catalog