Introduction¶
DeepSeek Harness (DSH) provides a runtime environment for local LLM development, but developers need to keep track of the cost and usage of model calls in real-time. The dsh-token-usage-panel plugin provides a status bar and a details panel below the DSH conversation area to display per-call token usage and costs, peak-valley pricing information, balance queries, and a calendar heatmap.
Core Features¶
Status Bar¶
The status bar is fixed below the input card to display core data. Regardless of screen width variations, the three items Session, Today, and Balance are always persistent. When space is limited, secondary numbers are compressed, while the peak-valley countdown remains fully displayed at any setting.
Status bar example:
Session ¥0.561 · 15.9M Today ¥0.561 · 15.9M ............ Balance ¥3.44 Valley Price · 21h02m Details ▴
Clicking the “Details” button expands a panel above the input card containing four tabs:
- Per-call Details: Displays details for each model call, including time, model, miss/cache hit/output tokens, peak-valley time slots, and cost. Supports switching by this session, today, last 30 days, or all, along with a total row and paginated loading.
- Calendar Heatmap: Provides rolling grids of 13/26/39/53 weeks, colored by daily cost. Hovering over a cell reveals the date, cost, number of calls, and token count.
- Balance: Displays recharge balance, gift balance, and the last observation time. Supports manual refresh and provides a comparison between “Today’s Actual Balance Deduction” and “Today’s List Price Estimate”.
- Settings: Configure status bar toggles, heatmap default weeks, cache write pricing criteria, balance refresh interval, price lists, peak time slots, and statutory holidays.
Peak-Valley Pricing¶
The plugin supports peak-valley pricing. The default rules are as follows:
* Peak Hours: Weekdays 09:00-12:00 and 14:00-18:00 (Beijing Time).
* Valley Hours: All other times, including all day on weekends and Chinese statutory holidays.
* Price List: Defaults to reading from the locally installed dsh-whale-widget, but can also be manually maintained in settings.
Data Persistence¶
All usage data is persisted to $DSH_HOME/usage-panel/ledger.json. The ledger retains data for 400 days by default, with a limit of 50,000 entries.
HTTP Routes¶
The plugin provides read-only HTTP routes for troubleshooting data sources:
* GET /dsh-usage-panel/snapshot.json?sessionId=: Retrieves all data required for the status bar.
* GET /dsh-usage-panel/calls.json?scope=&sessionId=&limit=&offset=: Retrieves per-call details.
* GET /dsh-usage-panel/heatmap.json?weeks=: Retrieves calendar heatmap data.
* GET/POST /dsh-usage-panel/config.json: Reads or modifies configuration.
* GET/POST /dsh-usage-panel/balance.json: Reads or forces a refresh of the balance.
Installation & Activation¶
Install using the DSH CLI:
dsh plugin --profile desktop add dsh-token-usage-panel
For local development or immediate code changes, use the link installation method:
dsh plugin --profile desktop add link:<absolute path to this directory>
After installation, the plugin can be toggled in Settings → Plugins. When disabled, the status bar disappears immediately, but existing ledger data is retained.
Notes¶
- Estimate ≠ Bill: The list price estimates displayed on the panel are affected by cache hit determination, gift credits, and promotional activities, and do not replace the platform’s official bill.
- Balance Availability: The balance feature is only available in account login mode. When using API Key direct connection, the account service returns empty, and the panel will show it as unavailable.
- Historical Data: The ledger only starts recording after the plugin is installed; historical data will not be backfilled.
- Contract Dependencies: The plugin relies on undocumented DSH contracts (such as
__ModuleLoader__, slot props, etc.). If they break after a DSH upgrade, fixes are required. - Holiday Maintenance: The holiday table is built-in with 2026 data by default. Data for subsequent years must be manually added in settings after they are announced.
- Data Source: Balance observation values only exist when a balance is readable and the panel is open.
License¶
MIT