Preface¶
When switching models or channels in DeepSeek Harness (DSH), you often have to open the console or call the API individually to see the balance. DeepSeek peak-valley prices and Alibaba Cloud Bailian Token Plan night discounts also have time differences, making it easy to run tasks at expensive price windows unknowingly. Below is an introduction to the community client plugin dsh-balance-plugin (maintainer adithyanraj03), which embeds the current model’s Provider balance (or plan quota) into the right side of the Composer dock, accompanied by peak-valley/night discount countdowns and a local timezone popover details.
What is this¶
dsh-balance-plugin is a client plugin for DeepSeek Harness (npm package name @adithyanraj/dsh-balance-plugin, current version 0.16.0, license MIT, requires Node ≥ 22.18). The plugin injects the Web client session UI via a Cordis patch, displaying Provider brand, balance chip, status dot, and billing window countdown (which affects per-token billing) in the Composer dock; API keys are parsed via the host-side credentials seam, so the browser does not touch the keys.
Supports 6 Providers: DeepSeek, OpenRouter, Moonshot/Kimi, Zhipu GLM (Z.ai), MiniMax, and Alibaba Cloud Bailian Model Studio (Token Plan, optional dependency bl CLI).
Core Features¶
Composer Balance Chip¶
The chip is fixed at the far right of the dock (after contextual metrics). When the session is empty, it falls on the hero tool row; after sending a message, it moves to the dock. Hover to open the popover, click to refresh balance; styles use DSH’s --dsw-* theme variables.
The chip displays the Provider name, remaining balance or plan quota, and billing window countdown (e.g., DeepSeek peak-valley, Bailian night discount), presented as a colored capsule and a sweep clock: running in a cheap window is cyan, the last hour before it starts is red, and the last five minutes show a fluctuation alert.
Local Timezone Popover¶
When hovering, display the billing window (including AM/PM and timezone label), countdown, and Provider’s own details (cash/gift balance, points, prompt quota, or Token Plan used percentage, etc.) under the local machine time.
Provider Following the Current Model¶
The model selected in the current session determines which Provider to query (including modlens vision wrapper and OpenAI-compatible custom channels pointing to Model Studio; Qwen series model names are used for identification). Model Studio sessions use the Qwen knot identifier on the chip.
The balance source and billing window (original text) for each Provider are as follows:
| Provider | Balance Source | Billing Window |
|---|---|---|
| DeepSeek | api.deepseek.com/user/balance |
Peak hours Mon–Fri 09:00–12:00, 14:00–18:00 (UTC+8); Valley hours half price |
| 阿里云百炼 Model Studio | Token Plan, via bl CLI (optional) |
Night 22:00–08:00 (UTC+8): Qwen −40%、DeepSeek-on-plan −50%、qwen4-max-preview all day −80% |
| OpenRouter | openrouter.ai/api/v1/credits |
— |
| Moonshot / Kimi | /v1/users/me/balance (.ai / .cn mirrors) |
— |
| 智谱 GLM(Z.ai) | Account statement (bigmodel / z.ai mirrors) | — |
| MiniMax | /v1/token_plan/remains |
— |
Showcase When Using Local Models¶
When the session model has no billable Provider (local or custom models), the chip no longer guesses a single Provider but instead cycles through the six supported ones (Alibaba Cloud prioritized, the rest roughly every 10 seconds); Providers without keys are skipped. Each card notes the next billing window change for that Provider (e.g., off-peak in 2h, nights start in 4h). Hovering pauses the carousel, clicking jumps to the next. You can pin it to a specific Provider by naming the channel alibaba-cloud, deepseek, openrouter, etc.
Host-Side Keys and Bailian Quotas¶
The browser does not hold the API Key: the host parses it via the credentials seam and communicates with the Provider. Bailian quota gateway only accepts console login or AccessKey derived tokens, not model API keys, so the plugin reads usage via the official CLI instead of storing Bailian keys in this plugin:
npm install -g bailian-cli
bl auth login --console # Browser login; international accounts can add --console-site international
When logged in and bl is available, the chip shows the used percentage and window reset countdown; otherwise, it is in “Night Discount Only” mode and prompts where the quota is. Readings are cached for 5 minutes. When the console session expires, the percentage position becomes a refresh/login button; clicking the chip opens the terminal to execute login via the host. Setting DSH_BALANCE_AUTOLOGIN=1 automatically opens the login flow on expiry.
Key parsing order: first ~/.dsh/.credentials.yaml, then environment variables DEEPSEEK_API_KEY, OPENROUTER_API_KEY, MOONSHOT_API_KEY, ZAI_API_KEY / GLM_API_KEY / ZHIPU_API_KEY, MINIMAX_API_KEY. Bailian does not require a Key stored by this plugin.
Installation and Enablement¶
The plugin runs with the current DSH process permissions. It is recommended to check the source code and MIT license on GitHub before installing. The community directory page is independent of DeepSeek / Fangyuan, not an official app store.
Web Configuration (pnpm)¶
Install from npm (must use scoped name; the unscoped name dsh-balance-plugin on npm is an unrelated package):
pnpm dsh plugin --profile web add @adithyanraj/dsh-balance-plugin
Or install from GitHub:
pnpm dsh plugin --profile web add github:adithyanraj03/dsh-balance-plugin
pnpm 10+ may intercept postinstall for unapproved packages, causing dependencies to install but the plugin not being written to the bundle. If ERR_PNPM_IGNORED_BUILDS occurs, approve it first and reinstall:
cd ~/.dsh/profiles/web && pnpm approve-builds # Check @adithyanraj/dsh-balance-plugin
pnpm dsh plugin --profile web add @adithyanraj/dsh-balance-plugin
Confirm it is mounted (both dependencies and dsh.profile.bundles contain the package):
cd ~/.dsh/profiles/web && node -e "const p=require('./package.json');
console.log(p.dependencies['@adithyanraj/dsh-balance-plugin'],
p.dsh.profile.bundles.includes('@adithyanraj/dsh-balance-plugin'))"
Desktop Application¶
Open Plugins (left sidebar of Settings) → Add plugin, paste the repository address and click Install:
https://github.com/adithyanraj03/dsh-balance-plugin
Desktop plugins will not update automatically for now; upgrading requires uninstalling and reinstalling. The host loads it at startup, so you need to restart the application after installing or upgrading.
Typical Usage and Optional Configuration¶
No extra configuration is needed for daily use: after configuring each Provider key (and optional Bailian bl login) in DSH Web or Desktop, switching models allows you to see the corresponding balance and countdown in the dock.
For development or demos, you can enable mock data (no real account needed):
| Config Item | Default | Meaning |
|---|---|---|
DSH_BALANCE_MOCK=1 or URL ?mock=1 |
Off | Each Provider uses fixed mock balance |
DSH_BALANCE_BL |
PATH on bl |
Bailian CLI executable file path |
DSH_BALANCE_AUTOLOGIN=1 |
Off | Automatically open login terminal when Token Plan session expires (default only shows login button on chip) |
Interaction habits (as described in README): Hover to view popover; click chip to refresh; in local model scenarios, hover to read carousel, click to switch Provider.
Applicable Scenarios and Notes¶
Suitable for developers who need to rotate multiple cloud models in DSH Composer for a long time and need to see the balance and peak-valley/night billing at a glance. Bailian Token Plan users need to install locally and bl auth login --console if they want to see usage percentage.
Notes:
- When the plugin requests a balance, it uses your configured keys and local
blsession. The permissions are consistent with the DSH host process; do not expose credentials files in untrusted environments. - Alibaba Cloud usage has a 5-minute cache, which does not equal the real-time console’s second-level refresh.
- Desktop and Web installation paths are different; choose the corresponding steps above based on the endpoint you are using.
Conclusion¶
dsh-balance-plugin consolidates “who is billing for the current model, how much is left, and when cheap windows start/end” into one chip in the Composer, reducing the cost of switching consoles and calculating time zones. For further information, visit the community directory page skillhub.cn/plugins/adithyanraj03/dsh-balance-plugin, and see the source code and full documentation at GitHub: adithyanraj03/dsh-balance-plugin.