Introduction¶
Using DeepSeek Harness (dsh) for development usually involves the DeepSeek API. To know how much balance is left in the account, one typically has to leave the current environment and check the platform backend. dsh-deepseek-balance brings this into the dsh web interface: the balance is displayed directly at the bottom of the sidebar. Hover to see details, and click to force a refresh. Below is an introduction to the usage and implementation of this plugin.
What is this¶
dsh-deepseek-balance is a DeepSeek Harness (dsh) plugin maintained by kyya, version 0.1.0, licensed under MIT. It displays the DeepSeek API account balance in real-time at the bottom of the Web sidebar (above the settings button). DSH’s philosophy is “everything is a plugin”, and this is a small, specific example.
Core Features¶
- Displays the DeepSeek API account balance in real-time at the bottom of the Web sidebar (above the settings button).
- Balance data is periodically pulled by the Node side and polled by the browser side every 30s; clicking the indicator immediately forces a refresh.
- Status dot color indication: Green = Available; Yellow = Account Unavailable; Red = Fetch Failed; Blue = Loading.
- Hovering displays full details: Total / Granted / Top-up / Updated Time.
- The API key is parsed by the
credentialsservice during every fetch and is never sent to the browser.
Installation and Usage¶
First, install the plugin. It supports installation from git or a local directory:
# Install from git
dsh plugin --profile web add github:kyya/dsh-deepseek-balance
# Or from a local directory
dsh plugin --profile web add /absolute/path/to/dsh-deepseek-balance
Note: dsh plugin only installs dependencies; changes to the plugin set require restarting dsh web to take effect:
dsh web
After restarting, open http://127.0.0.1:3080, and you will see the balance indicator at the bottom left of the sidebar.
Configuration¶
By default, it reads the credential DEEPSEEK_API_KEY, with sources being: ~/.dsh/.credentials.yaml, the DEEPSEEK_API_KEY environment variable, or the key saved in “Settings -> Models”.
If adjustments are needed, override them in ~/.dsh/profiles/web/cordis.patch.yml. Note that this overrides the entire config line, so all fields must be written out:
- id: deepseek-balance
config:
refreshMs: 60000 # Background refresh interval (ms)
apiKeyEnv: DEEPSEEK_API_KEY # Credential reference name
baseUrl: https://api.deepseek.com
endpoint: /user/balance
How it Works¶
The plugin is split into two halves: host and browser:
| Half | File | Responsibility |
|---|---|---|
| host (Node) | index.js |
Periodically GET <baseUrl><endpoint> (Bearer auth), cache snapshot; expose /deepseek-balance via webServer.register |
| browser | client.js |
Register React indicator in sidebar.footer.action slot; poll /deepseek-balance, click with ?refresh=1 to force refresh |
The balance interface returns data in the following format:
{
"is_available": true,
"balance_infos": [
{
"currency": "CNY",
"total_balance": "123.45",
"granted_balance": "0.00",
"topped_up_balance": "123.45"
}
]
}
is_available corresponds to the green/yellow status dot, and the total, granted, topped-up fields in balance_infos correspond to the hover details.
Uninstallation¶
dsh plugin --profile web remove dsh-deepseek-balance
Use Cases and Notes¶
Suitable for developers who use both dsh web and the DeepSeek API and wish to keep track of their account balance at any time. Two reminders:
- The plugin runs with the permissions of the current dsh process. It is recommended to check the source code and license before installing.
- When overriding configuration, all fields of
configmust be written out completely; omitting them will cause those fields to be lost.
Conclusion¶
dsh-deepseek-balance solves a high-frequency problem with very little cost: seeing the DeepSeek API balance without leaving dsh web, and the key never leaves the Node side. Project address and community directory:
- GitHub: https://github.com/kyya/dsh-deepseek-balance
- Directory page: https://www.skillhub.cn/plugins/kyya/dsh-deepseek-balance
The directory is independently maintained by the community and has no official affiliation with DeepSeek or Hypothesis.