Introduction

When developing with DeepSeek Harness (DSH), tracking the token consumption of each request, calculating actual costs, and monitoring provider quotas are essential for cost control. Existing statistics methods are often not intuitive enough. The dsh-token-usage plugin embeds visualization charts and data panels directly in the Web UI, aggregating originally scattered usage information, and solves the problem of developers being unable to monitor resource consumption in real time.

Plugin Overview

This is a client-side DSH plugin maintained by developer LaoYueHanNi. Its core purpose is to display model token usage and costs in real time in the Web UI, providing trend charts, historical backfill, per-model pricing details, and provider quota display.

Core Features

  1. Real-Time Logging: Automatically records the number of tokens, cost, model used, and associated session for each request, including context compression calls.
  2. Web Statistics Page: Provides summary cards, a daily total token line chart, and detailed tables by model/session in Settings, with filtering by date range and model.
  3. Session Usage Tab: Adds a “Usage” view to the conversation panel, displaying six core metrics such as success rate, cost, and cache hit rate.
  4. Pricing and Quotas: Provides a detailed entry point to view per-model pricing and displays the remaining quota of the current provider directly on the input bar button.
  5. Historical Backfill: Automatically syncs historical request records from before installation on first startup.

Installation and Enablement

Since the repository no longer provides prebuilt output, install it via npm.

dsh plugin --profile web add @laoyuehanni/dsh-token-usage

After installation, go to Settings via the gear icon in the Web UI sidebar, and you will see the Token Usage page.

Usage Example

After opening the Token Usage page, you can filter data by date range and model using the filters. Click the rate button on a model name to view the full pricing table; click the button to the left of the input bar to view the remaining quota of the current provider.

Notes

  • Upgrading from older versions requires caution: If upgrading from an older version (<= 0.3.7, package name dsh-token-usage), updating directly will cause the plugin to fail to load. You need to remove the old package name first, then add it again.
  • Pricing file invalidation: Manually edited pricing.json files will be silently ignored after upgrading, and the rate table is synchronized from the cloud on every startup.
  • Configurable data directory: The data directory defaults to ~/.dsh/token-usage/, and can be changed to an absolute path in the Web settings card. After saving, historical data will be automatically migrated.
  • Installation source change: Direct installation from GitHub is no longer supported; the npm package name must be used.

Summary

The dsh-token-usage plugin provides DSH users with an intuitive entry point for cost and quota management, making it suitable for development scenarios that require fine-grained monitoring of resource consumption.