During the development and use of DeepSeek Harness (DSH) Web, it is necessary to monitor API account balances and actual consumption. The official DeepSeek API only provides balance inquiry, but “today’s spend” usually needs to be manually tallied or wait for billing. dsh-deepseek-cost-live fills this gap by fetching the balance through the official API and parsing local session logs to estimate today’s spending.
This is a community open-source plugin (MIT License), maintained by xtd1145. It does not modify DSH source code and is developed based on official runtime capabilities.
Core Features¶
1. Live Balance (Official API)
The plugin calls GET https://api.deepseek.com/user/balance to fetch the balance. The API Key is only resolved within the host process and never enters the browser, logs, or request parameters. If a refresh fails, the last successful data is retained and marked as stale.
2. Today’s Spend (Local Estimate)
The plugin monitors local DSH session logs and converts the usage of each model request (cache hits, misses, output, reasoning) into RMB based on per-model price tables (CNY/million tokens). Because DeepSeek does not provide an official “consumed today” query API, the spend is a locally estimated metric, not an invoice.
3. Real-time Display in Three Places
Real-time display can be enabled in three places simultaneously:
* Composer dock bar below the input box: Shows balance, today’s spend, and a manual refresh button.
* Persistent floating badge in the bottom-right corner: Can be collapsed; state is remembered by localStorage.
* Full panel on the settings page: Balance details, today/last 7 days Token and spend, per-model spend, price table/time zone/polling configuration, and historical re-scan.
4. Other Capabilities
* Supports both Chinese and English.
* Counting applies only to the official DeepSeek route (default deepseek-official provider).
* Supports scanning and re-scanning historical sessions.
Installation and Activation¶
Use the official installation command:
dsh plugin --profile web add <本仓库路径或 dsh-deepseek-cost-live.tgz>
After installation, restart the service to take effect:
powershell -NoProfile -ExecutionPolicy Bypass -File $env:USERPROFILE.dshrestart-dsh-web.ps1
After restarting, open the Web interface in a browser (recommend incognito mode or a hard refresh once). You will see the floating badge and the small bar below the input box. Access “Usage and Balance” in the settings page to view the full panel.
Verify successful installation:
Invoke-WebRequest -Uri 'http://127.0.0.1:3080/dsh-deepseek-cost-live/stats' -UseBasicParsing | Select-Object -ExpandProperty Content
Configuration and Data¶
API Key Sources
The plugin resolves the API Key with the following priority:
1. Plugin configuration file $DSH_HOME/dsh-deepseek-cost-live/config.json.
2. Environment variable (default DEEPSEEK_API_KEY; apiKeyEnv can be changed in configuration).
3. DSH credentials file $DSH_HOME/.credentials.yaml.
4. Official ctx.credentials service.
Data Directory
The plugin creates the following files under $DSH_HOME:
* dsh-deepseek-cost-live/ledger.json: Usage records (idempotent deduplication by sessionId:seq, retained for keepDays days).
* dsh-deepseek-cost-live/config.json: Configuration file.
* dsh-deepseek-cost-live/balance.json: Latest successful balance snapshot.
HTTP Routes
Local loopback access only:
* GET /dsh-deepseek-cost-live/stats — Summary data.
* POST /dsh-deepseek-cost-live/refresh — Refresh balance immediately.
* POST /dsh-deepseek-cost-live/scan — Re-scan all session history immediately.
Notes¶
- Unofficial product: Unrelated to official DeepSeek; this is a community open-source plugin.
- Spend basis: Spend is locally estimated, not an official bill; verify against the official website price list.
- Environment requirements: Node.js >= 22.19.0 is required.
- Route restrictions: HTTP routes support local loopback access only.