Introduction¶
When running DeepSeek sessions via the DSH (DeepSeek Harness) web interface, token usage, current session cost, cumulative cost, and account balance are often scattered in different locations. dsh-token-cost is a DSH web extension that provides a draggable DeepSeek whale floating ball to view token usage, current session/cumulative cost, and DeepSeek account balance.
It reuses the DEEPSEEK_API_KEY configured in DSH to query the official DeepSeek balance, and records costs per session via the DSH server-side logs, rather than performing rough estimates on the frontend.
What is this¶
dsh-token-cost is a DSH web extension maintained by PeterZoneZz with an MIT license.
It targets usage with DSH’s web profile. After installation, it provides a whale floating ball in the browser page to view:
- Remaining balance percentage
- Current session cost
- Token usage for Input / Cache Read / Cache Write / Output
- Cumulative cost of all sessions
- DeepSeek official account balance
The GitHub repository address is:
https://github.com/PeterZoneZz/dsh-token-cost
Core Features¶
Whale Floating Ball¶
The plugin provides a small glassmorphism-style ball floating on the page. When the mouse hovers, the whale wiggles, and the outer ring progress bar displays the remaining balance percentage.
Expand, Collapse, and Drag¶
Click the whale to expand the card; clicking it again collapses the card. The card can also be dragged when open, and the whale and card move together.
Supported ways to close the card:
- Click outside the card
- Press
Esc - Click
✕ - Click the whale again
When releasing the drag near the left or right edge of the screen, the floating window automatically snaps to the edge. The window position is recorded in the browser’s local localStorage.
The card expands on the side with the most space next to the whale and tries not to exceed the screen.
DeepSeek Official Account Balance¶
The plugin reuses the DEEPSEEK_API_KEY configured in DSH and calls the DeepSeek official interface:
GET /user/balance
The card displays the total balance and the composition of bonus/recharge.
If DEEPSEEK_API_KEY is not configured, token usage and cost display are not affected; only the balance section will show a fallback message.
Remaining Balance Visualization¶
The remaining balance is calculated based on the balance found when opening the DSH page:
Remaining % = Current Balance ÷ Baseline Balance
If recharged mid-session, the baseline balance increases, and the remaining percentage resets to 100%.
Server-side Precise Billing¶
The plugin registers the tokenCost session projection unit, replaying session logs event-by-event on the DSH server.
Billing is calculated based on the actual unit price of the model used for each request. Therefore, when switching models mid-session, costs are still calculated according to the corresponding model, rather than estimating using the current model multiplied by total tokens on the client side.
Usage Breakdown¶
The card displays:
- Current session cost
- Input tokens
- Cache read tokens
- Cache write tokens
- Output tokens
- Cumulative cost of all sessions
- Cost breakdown by model
Appearance¶
The plugin supports:
- Light/Dark theme adaptation
- Chinese/English bilingual support
- Number counting animation effect
Installation and Enablement¶
1. Get the Project Locally¶
The installation steps in the README use placeholder examples:
git clone <your-repo-url> dsh-token-cost
This is not a complete, copy-pasteable installation command. You can first get the source code from the GitHub repository to a local path:
https://github.com/PeterZoneZz/dsh-token-cost
2. Install into DSH’s Web Profile¶
After putting the project in a local path, run:
dsh plugin --profile web add file:/path/to/dsh-token-cost
Here file:/path/to/dsh-token-cost needs to be replaced with the actual local path. This method uses the local file dependency to install the plugin.
3. Restart DSH Web¶
After installation, restart DSH Web:
dsh web
Then refresh the page in the browser, and you can see the whale floating ball in the bottom right corner.
Configure Balance Query¶
Balance query depends on DEEPSEEK_API_KEY. There are two common configuration methods:
- Write
DEEPSEEK_API_KEYin the model settings page of DSH Web. - Set environment variable before starting DSH:
export DEEPSEEK_API_KEY=sk-...
When this Key is not configured, token usage and cost display are still available; only the balance section will show a fallback message.
Configure Price Table and Balance Query¶
The price table and balance query can be overridden via the profile’s cordis.patch.yml.
The price unit is:
Yuan / Million tokens
Prices are matched by model ID, falling back to default if no specific model matches.
Billing rules are:
cacheWriteis billed at the input pricecacheReadis billed at the cache hit price
Example:
- id: token-cost
config:
prices:
deepseek-chat: { input: 2, cacheRead: 0.5, cacheWrite: 2, output: 8 }
deepseek-reasoner: { input: 4, cacheRead: 1, cacheWrite: 4, output: 16 }
deepseek-v4-flash: { input: 1, cacheRead: 0.25, cacheWrite: 1, output: 4 }
default: { input: 2, cacheRead: 0.5, cacheWrite: 2, output: 8 }
balance:
enabled: true
apiKeyEnv: DEEPSEEK_API_KEY
baseUrl: https://api.deepseek.com
pollMs: 60000
The prices above are just configuration examples; they should be adjusted according to DeepSeek’s official prices during actual use.
Typical Usage¶
The following introduces several common operations after installation.
View Remaining Balance¶
Hover the mouse over the whale floating ball, and the outer ring progress bar will display the remaining balance percentage.
View Cost and Balance¶
Click the whale to expand the card. You can see:
- DeepSeek account balance
- Current session cost
- Input / Cache Read / Cache Write / Output tokens
- Cumulative cost of all sessions
- Cost breakdown by model
Move the Floating Ball¶
Press and drag the whale to adjust the floating window position. When releasing near the left or right edge of the screen, the floating window automatically snaps to the edge.
Close the Card¶
You can close the card in any of the following ways:
- Click outside the card
- Press
Esc - Click
✕ - Click the whale again
Applicable Scenarios and Notes¶
This plugin is suitable for developers using DeepSeek on the DSH web interface, especially in scenarios requiring frequent confirmation of token usage, current session cost, cumulative cost, and account balance.
Pay attention to the following points before use:
- Balance query depends on
DEEPSEEK_API_KEY; if not configured, the balance section will show a fallback. - The price table can be overridden via
cordis.patch.yml; official price changes require synchronization. - The floating window position is recorded in the browser’s local
localStorage. - The plugin accesses DSH session logs and calls the DeepSeek official balance interface, sharing the same runtime permissions as the current DSH process. Source code, configuration, and license should be reviewed before installation.
- The plugin license is
MIT.
Conclusion¶
The value of dsh-token-cost lies in aggregating DeepSeek’s token usage, session cost, cumulative cost, and account balance into a single floating ball on the DSH web interface, facilitating quick cost confirmation during actual debugging and agent operation.
GitHub repository address:
https://github.com/PeterZoneZz/dsh-token-cost