Introduction¶
The core philosophy of DeepSeek Harness (DSH) is “everything is a plugin.” In agent development or long-running services, developers often encounter situations where token consumption is high but the source is hard to identify: Which model is consuming tokens? Which project is the most expensive? Is it caused by cache misses or excessive inference costs? The dsh-token-use plugin integrates real-time token usage statistics and cost estimation into the DSH settings panel, solving the “invisible cost” problem through visualization.
Plugin Overview¶
dsh-token-use is a real-time token usage dashboard designed to provide visual usage monitoring and cost analysis capabilities for DSH.
- Positioning: Admin / Security category plugin.
- Maintainer: huangyuheng.
- License: MIT.
Core Features¶
This plugin provides comprehensive data support through four tabs on the settings page:
-
Overview
- Card display: Shows estimated cost, total volume (input + output + cache), input, output, cache read/write, reasoning, and call counts.
- Trend chart: Rendered with ECharts. Supports stacked area charts (composition of cache/input/output), amount bar charts (right axis), and a prominent daily average reference line. Supports switching between 7 / 30 / 90 days.
- Usage heatmap: Displays usage over the past 12 months, with each cell representing one day. Supports coloring by “Total” or “Amount”; hover to view detailed data for that day.
- Filtering: Supports querying by day/month/year/time range/all, as well as filtering by model.
-
Model Statistics
- Displays detailed usage and cost tables for all models. Supports querying by day, month, year, or custom time range.
-
Project Statistics
- Displays detailed usage and cost tables for all projects, also supports multi-dimensional range queries.
-
Configuration Information
- Version and environment: Compares the version and channel (rc/alpha/stable) of each component (dsh-service, dsh, this plugin), and displays runtime environment parameters (platform, Node version, PID, port, uptime, etc.).
- Health check: Checks API responses, client bundle loading, and Harness self-checks (profile integrity, dependency resolution, etc.).
- System operations: Supports one-click restart and shutdown operations (both require confirmation).
Cost Estimation¶
- Calculation logic: Cost is calculated based on DeepSeek official pricing × local usage × peak/off-peak rate multiplier.
- Billing scope: Only models whose names contain
deepseekare included in cost calculation; other models (e.g., claude, gpt) are not counted. - Data source: The plugin fetches the official pricing page once per day and caches it. If the network request fails, it falls back to a built-in snapshot.
- Note: The displayed cost is an estimate and may be affected by official price changes, cache billing rules, and statistical delays. Please refer to the official billing amount.
Installation and Enabling¶
After installation, the plugin will create a first-level entry called “Token Usage” in the DSH settings sidebar.
# 通过 npm 包安装
dsh plugin --profile web add dsh-token-use
# 或从 GitHub 源码安装
dsh plugin --profile web add github:huangyuheng/dsh-token-use
# 或从本地解压目录安装
dsh plugin --profile web add /解压路径/dsh-token-use
Typical Usage¶
After installation and restarting dsh web, you can view the data on the settings page. The plugin incrementally accumulates data via the session/event event bus, without requiring host-side polling.
API Endpoint Examples:
# 获取概览数据
curl 'http://127.0.0.1:3080/dsh-token-use?day=2026-09-10'
# 查询指定月份
curl 'http://127.0.0.1:3080/dsh-token-use?month=2026-09'
# 查询指定模型
curl 'http://127.0.0.1:3080/dsh-token-use?model=deepseek-v4-flash'
# 获取版本与运行环境
curl http://127.0.0.1:3080/dsh-token-use/config
# 执行健康检查
curl http://127.0.0.1:3080/dsh-token-use/health
# 一键重启服务
curl -X POST http://127.0.0.1:3080/dsh-token-use/restart
# 关机
curl -X POST http://127.0.0.1:3080/dsh-token-use/shutdown
Notes¶
- Runtime environment: Requires
dsh webversion ≥ 0.1.0-rc.6. - Data dependency: The plugin requires network access to fetch the latest pricing. If it fails, it uses the built-in snapshot.
- Statistical scope: The displayed cost is an estimate and only DeepSeek models are included. Auxiliary calls (e.g., web search, conversation title) are not counted.
- Performance design: The host side does not write to disk or add timers. It is fully based on incremental updates through the event bus, avoiding resource waste.