When developing with DeepSeek Harness (DSH) or using large models, session token consumption and cost are common metrics to monitor. DSH itself does not provide an explicit usage view, and manual tracking can be cumbersome. The dsh-usage-cost plugin solves this need by providing real-time data in the status bar and detail panel.

Plugin Positioning

This is a localized usage monitoring tool. Maintained by lhh666-6, with an MIT open-source license. It does not upload any data; all calculations are performed locally, and data is persisted through projection mode.

Core Features

The plugin provides a persistent status bar capsule and a detail panel. Data sources include streaming estimation and authoritative calibration after the request ends.

  • Persistent Capsule Display: Registered on the right side of the session title bar, displaying the model name, input/output tokens, and current session cost in real time. During streaming output, numbers update in real time, and estimated values are marked with ~.
  • Detail Panel: Click the capsule to expand it. It shows input/output tokens, cache hit/miss tokens, total tokens, current cost, elapsed time, tokens/s, data status (estimating/calibrated/incomplete), and today’s/monthly cumulative cost.
  • Local Real-Time Estimation and Authoritative Calibration: During streaming, gpt-tokenizer is used for estimation, throttled per every 50 chunks or every 100 ms; after the request ends, calibration uses DeepSeek’s returned usage (prompt_tokens/completion_tokens/prompt_cache_hit_tokens/prompt_cache_miss_tokens).
  • Data Persistence: Current session data is written to disk through session projection; today’s/monthly/per-model accumulated data is written to $DSH_HOME/usage-cost/aggregates.json and is not lost after restart.
  • Custom Price Table: Supports custom price table configuration; default prices are in CNY per million tokens.

Installation and Enablement

Use the official dsh plugin command to install:

dsh plugin --profile desktop add dsh-usage-cost
dsh plugin --profile web add dsh-usage-cost

After installation, restart DSH (or switch profile once), and the usage capsule will appear on the right side of the status bar when you start a conversation.

Configure the Price Table

Default prices (CNY / million tokens) are as follows:

Model Cache Hit Cache Miss Output
deepseek-chat ¥0.5 ¥2 ¥8
deepseek-reasoner ¥1 ¥4 ¥16

To modify or add models, edit $DSH_HOME/settings.yaml:

usage-cost:
  models:
    - id: deepseek-chat
      cacheHit: 0.5
      cacheMiss: 2
      output: 8
    - id: deepseek-reasoner
      cacheHit: 1
      cacheMiss: 4
      output: 16
  chunkInterval: 50
  timeIntervalMs: 100

Technical Implementation

The plugin uses a dual-side architecture and is part of the same plugin system as dsh-plugin-desktop:

  • Host Side: Registers the usageCost session projection, listens to session/event to accumulate data, and handles local persistence.
  • Client Side: Registers the status bar capsule component and reads real-time values through useProjection('usageCost').

Notes

  • Data Privacy: Only local calculation and persistence; no content is uploaded.
  • Data Integrity: Streaming interruption or errors retain the estimate and mark it as “incomplete”, without overwriting previously accurate data.
  • Session Isolation: When switching sessions, data is isolated per session by projections and will not be mixed.
  • Multi-Currency: No currency exchange conversion is performed for now; the default is CNY.
  • Model Interaction: No model-visible instructions, tools, or request fields are injected; it only observes.