Introduction¶
The DSH (DeepSeek Harness) plugin system allows features to be extended through plugins. Conventional usage statistics plugins are usually based on local session logs and cannot cover calls made from the web interface, mobile apps, or other clients. The dsh-usage plugin directly calls the official DeepSeek platform APIs and displays the account’s total balance and token usage in the DSH Web GUI.
Core Features¶
- Balance: Automatically reads DSH credentials, calls the
api.deepseek.com/user/balanceendpoint, and displays the total, top-up, and gifted balances. - Token Usage (Account-wide): Calls the official platform
api/v0/usage/by_api_key/{amount,cost}endpoints, displaying cache hits, cache misses, output tokens, and the corresponding costs. - Time Range: Supports switching between 24 hours, 7 days, 30 days, and 90 days, and provides a stacked bar chart alongside a detailed table.
- Model Tool: Registers the
deepseek_usage_querymodel tool, allowing a large language model to query balance and usage directly. - Token Persistence: The token is saved to
~/.dsh/dsh-usage-token, automatically read after DSH is restarted, so no repeated configuration is needed.
Installation and Enablement¶
Run the following command in the terminal to install it:
dsh plugin --profile web add "github:Huasecc/dsh-usage#main"
After installation, restart the Web interface for the configuration to take effect.
Initial Setup: Obtaining the Platform Token¶
The plugin must obtain a DeepSeek platform session token to access the data. On first use, follow these steps:
1. Log in via a browser to https://platform.deepseek.com/usage.
2. Press F12 to open the console and run the following code to retrieve the token:
JSON.parse(localStorage.getItem('userToken')).value
- Paste the output token into the plugin settings page under “Platform Usage Access Token” and save.
How It Works and Notes¶
- Data Source: The data comes from the official DeepSeek platform APIs and includes account-wide data (web, mobile, and other clients), not limited to local sessions.
- Token Type: The required token is the web console session token (
userTokenfromlocalStorage), not an API key. - Environment Dependencies: Because
platform.deepseek.comhas WAF protection, requests must include browser headers (UA/Accept/Origin/Referer) to avoid being intercepted. - Security Note: The plugin only reads your own DSH credentials and platform token; the distribution package contains no keys.
Summary¶
This plugin addresses the need to view full account usage in a DSH environment and is suitable for users who want to monitor consumption across all channels. To view actual account spending, it is recommended to install and use it.