Introduction¶
When running conversations in DeepSeek Harness (dsh), the number of tokens indicates usage volume, but it may not directly answer “how much this step cost”, “how much spent today”, or “how much balance remains”. If you want these numbers to be visible directly in the dsh web interface without needing to check other pages separately, you need a plugin that can read session logs, calculate costs locally, and display balance and cost distribution.
Below is an introduction to suanzhang-dsh, a DeepSeek Harness billing plugin: the sidebar displays balance and today’s spending, the Billing tab lists costs by step, official prices are synchronized automatically, and it supports cross-session and cross-day aggregation.
What is this¶
suanzhang-dsh is a DeepSeek Harness billing plugin. The repository address is:
https://github.com/CZ1900/suanzhang-dsh
The license is MIT.
It targets scenarios where you can already open dsh web and wish to view DeepSeek call costs locally on your machine. The plugin itself does not call the model; it mainly performs local cost calculation, balance display, official price synchronization, and cost aggregation.
Core Features¶
suanzhang-dsh provides the following verified display and calculation capabilities:
- The sidebar always displays the current balance and today’s spending.
- The Billing tab lists detailed costs by step.
- Visualize costs by model, tool, day, and session.
- Cost prediction: Average per step × Number of steps.
- Official prices are synchronized automatically; if scraping fails, it falls back to built-in prices.
- Clicking any step row jumps to the “Trace” tab and highlights the corresponding step.
- Supports
DeepSeek V4-Flash/V4-Pro(including peak and valley pricing); also supportsdeepseek-chat/deepseek-reasoner. - Other models will show “Unpriced”.
- Supports cross-session and cross-day aggregation.
- The plugin does not call the model or consume tokens; it is primarily local calculation, plus two HTTP requests for balance queries and retrieving official prices.
Prerequisites¶
It is recommended to confirm the following conditions before installation:
- You already have a local DeepSeek Harness environment that can be opened, meaning
dsh webcan open normally. - Node version is not less than 22.
You can confirm the Node version with the following command:
node -v
If you choose to install from GitHub, you also need Git to be available on your machine and access to github.com. Company networks, proxies, or firewalls may block access to GitHub. In this case, you can switch to installing via local copy.
The DeepSeek API Key is used for balance queries. The plugin defaults to reading:
DEEPSEEK_API_KEY
If the API Key is not configured, the balance bar will prompt “Not configured”, but cost aggregation and pricing can still be used.
The scope of API Key usage is quite clear: it is only used for a single balance query request; it is not stored, printed, logged, or included in screenshots; information returned to the frontend is stripped of the Key beforehand.
Installation & Enablement¶
Method 1: Install from GitHub¶
First, execute the installation command:
pnpm add https://github.com/CZ1900/suanzhang-dsh.git
This step will add the plugin repository to the current project dependencies.
Then, edit cordis.patch.yml under the Harness profile and add the following at the top:
- insert:
- id: suanzhang
name: suanzhang-dsh
After saving, restart:
dsh web
After restarting, refresh the page, and you can see the sidebar balance and the “Billing” tab.
Method 2: Install via Local Copy¶
If GitHub access is restricted, you can place the repository in the node_modules directory of the DSH profile.
In the DSH profile directory, for example:
~/.dsh/profiles/web
Execute:
cp -r /path/to/suanzhang-dsh node_modules/
Replace /path/to/suanzhang-dsh with the local plugin directory.
Then, similarly, add the following in cordis.patch.yml:
- insert:
- id: suanzhang
name: suanzhang-dsh
After restarting dsh web, refresh the page to see the result.
Typical Usage¶
After installing and restarting, the common operation path is as follows:
- Open
dsh web. - Check the current balance and today’s spending in the sidebar.
- Click on the sidebar balance to jump directly to the “Billing” page.
- View the detailed cost breakdown listed by step on the “Billing” page.
- View the cost distribution by model, tool, day, and session.
- Use cost prediction to estimate future costs using “Average per step × Number of steps”.
- Click any step row to automatically jump to the “Trace” tab and highlight that step.
If you just want to confirm that the environment meets the requirements, you can check the Node version first:
node -v
Pricing & Data Boundaries¶
The pricing and data sources of suanzhang-dsh can be divided into a few categories.
Balance Query¶
Balance queries will access the DeepSeek official interface. The default baseURL is:
https://api.deepseek.com
The API Key is only used for this single balance query request and is not used for local cost calculation.
Official Price Synchronization¶
Official price synchronization will access the DeepSeek public documentation page:
https://api-docs.deepseek.com
This request is unauthenticated and read-only.
If scraping fails, the plugin will fall back to built-in prices, which does not affect cost aggregation and display.
Local Cost Aggregation¶
Cost calculation and local aggregation read the local machine’s session logs. Display, sorting, charting, and other calculations are completed locally in the browser and do not leave the machine.
Supported Models & Key Parameters¶
Supported Models¶
Verified support includes:
DeepSeek V4-FlashDeepSeek V4-Prodeepseek-chatdeepseek-reasoner
Among them, DeepSeek V4-Flash / V4-Pro support peak and valley pricing.
Other models will show “Unpriced”.
Default Key Parameters¶
The following parameters come from verified sources, with default values hardcoded in the plugin:
| Item | Default Value |
|---|---|
| API Key Reference | DEEPSEEK_API_KEY |
| baseURL | https://api.deepseek.com |
| Peak Hours | 9:00–12:00, 14:00–18:00, Beijing Time |
| Low Balance Threshold | ¥20 |
The polling frequency can be adjusted at the 60000 millisecond mark in lib/client.js; if you wish to lower the refresh frequency, you can increase this millisecond value.
Code Entry¶
The verified code structure is as follows:
lib/index.js: Host side, containing balance, pricing, aggregation, and today-related capabilities.lib/client.js: Browser-side UI.
Use Cases & Notes¶
suanzhang-dsh is suitable for scenarios such as:
- Already using DeepSeek in DSH.
- Not wanting to manually convert token prices.
- Hoping to see balance and today’s spending directly in the sidebar.
- Hoping to break down the cost of each step within a single conversation.
- Hoping to aggregate costs by model, tool, day, and session.
- Hoping that clicking on a specific step cost will jump to the corresponding trace step.
Notes to consider:
- The plugin runs with the permissions of the current dsh process; you should check the source code and license before installing.
- The plugin itself does not consume tokens; it is the dsh conversation that actually consumes tokens.
- The API Key is only used for balance queries and does not participate in local cost calculation.
- If the sidebar or “Billing” tab does not appear, first confirm that
id: suanzhangandname: suanzhang-dshhave been added tocordis.patch.yml, then restartdsh weband refresh the page. - If the balance shows “Not configured API Key” or the query fails, first go to Harness settings to confirm that the DeepSeek API Key is configured.
- If
pnpm addinstallation fails, prioritize checking local Git, network, proxy, or firewall; switch to installing via local copy if you cannot access GitHub.
Conclusion¶
The value of suanzhang-dsh is quite direct: putting balance, today’s spending, step costs, cost distribution, and cost prediction into the DeepSeek Harness interface, relying mainly on local session logs for calculation.
GitHub repository address:
https://github.com/CZ1900/suanzhang-dsh