Introduction¶
When using DSH for long conversations or model tuning, checking how much balance remains and how many tokens the current session has consumed often requires switching to the DeepSeek console or digging through logs. DeepSeek Harness (DSH) splits capabilities into plugins, and the community directory contains many client-side plugins that specifically modify the Web / Desktop interface. Below is an introduction to dsh-api-balance (maintainer X-Xyy): it attaches a status chip to the right side of the conversation title bar. Clicking it reveals a breakdown of your balance, current session usage, and context occupancy — all without leaving the conversation page.
What Is This¶
dsh-api-balance is a DSH client plugin (dsh.client.platform: web) compatible with both DSH Web and DSH Desktop. It displays DeepSeek API balance and current session token usage in real time within the conversation title bar. The Host side queries the balance on your behalf, while the browser side only renders numbers and counts — the API key is never handed to the frontend.
- Directory page: skillhub.cn/plugins/X-Xyy/dsh-api-balance
- Source code & documentation: github.com/X-Xyy/dsh-api-balance
- License: MIT (
package.jsonversion 1.0.0)
Core Features¶
Title Bar Chip¶
The chip appears on the right side of the conversation title bar, alongside buttons such as “Open in App” and “Download Session Log.” Example rendering:
● ¥88.99 · 12.3k tok
The dot indicates: green = balance available, yellow = low balance, red = query failed, gray = fetching.
Detail Panel¶
Clicking the chip expands a panel in the upper-right corner containing:
- Balance: total amount, availability status, split into “Top-up Balance / Gift Balance,” with data source noted.
- Session Usage: model routing, request count, and input, output, cache hit, and total tokens (data sourced from the
usagefield ofassistant/messageevents in the session log). - Context Occupancy: e.g.,
263.4k / 1.0M (26%)with a progress bar (fromctx.tokenMeter). - “Refresh” and “Close” buttons with an update timestamp; expanding the panel forces a fresh fetch.
Refresh Cadence¶
The page polls every 20 seconds, and only while the conversation view is open. The Host side also caches balance results for 15 seconds, so opening multiple windows won’t multiply requests to DeepSeek.
Installation & Activation¶
Install command (from the repo README, with web profile):
dsh plugin --profile web add github:X-Xyy/dsh-api-balance
The package requires no build step — the client is a pre-built module file with no third-party runtime dependencies. After restarting DSH or refreshing the page, the chip should appear on the right side of the title bar.
Uninstall:
dsh plugin --profile web remove dsh-api-balance
If the profile’s cordis.patch.yml still contains a corresponding insert line, it must be manually removed.
Typical Usage¶
- Install using the command above, then open any conversation and check whether the chip appears on the right side of the title bar.
- Click the chip to open the detail panel and verify that the balance and session token counts match expectations.
- Click “Refresh” for immediate data, or rely on the 20-second polling and the forced refresh on expansion.
How balance and credentials are read (for reference against your own settings):
- Balance request:
GET {baseURL}/user/balance. baseURLandapiKeyEnvare read from thellm-deepseeksection insettingsfirst; otherwisehttps://api.deepseek.comand theDEEPSEEK_API_KEYenvironment variable are used.- The API key is read via
ctx.credentialson every query — it is not cached, persisted to disk, written to logs, or sent back to the browser. Requests are issued by the Host usingnode:http(s); this plugin does not use shell or child processes.
The browser fetches snapshots via the loopback address (the route carries no key):
GET /dsh-api-balance/snapshot?sessionId=<id>[&force=1]
Use Cases & Notes¶
Who It’s For: Developers who use the DeepSeek API in DSH daily and want to monitor balance and session tokens in the same interface; users who already have llm-deepseek or DEEPSEEK_API_KEY configured in DSH.
Permissions & Trust: The plugin runs on the Host side with the current dsh process privileges. It is recommended to review the source code and the MIT license before installing. The snapshot route does not require authentication — other programs on the same machine may also be able to read balance and token counts (but not the API key). If the loopback environment is untrusted, add your own checks or do not install.
Compatibility: Declared only for the Web client platform; does not depend on dependencies in package.json and does not declare any official @deepseek-ai/* packages. It uses the react seed module and host services provided by the module loader.
Conclusion¶
dsh-api-balance brings DeepSeek balance and session token usage into the conversation title bar, using color-coded status and a detail panel to reduce the cost of switching pages to check account details. The community directory is not officially affiliated with DeepSeek or Hunyuan. For installation and upgrade instructions, refer to the repository.