dsh-plugin-balance-english
v1.4.6
Published
DeepSeek / OpenCode Go / OpenAI credit floating widget: shows above the input box, supports DSH model-list sync, custom quota endpoints, drag & theme adaptation; built-in DSH session token usage stats (by day/month/model) with official peak/off-peak cost
Maintainers
Readme
dsh-plugin-balance-english
A floating LLM credit / quota widget for DeepSeek Harness Web — plus DSH session token usage and cost stats.
English — the English variant of the original Chinese plugin.
✨ Introduction
dsh-plugin-balance-english is a DSH (DeepSeek Harness) Web plugin that floats a small widget right above the input box. It can:
- Query LLM account balance / plan usage: supports DeepSeek official, OpenCode Go, OpenAI, and any custom quota endpoint.
- OpenCode Go: the main window directly shows 5h / weekly / monthly usage percentage badges (auto-colored by usage level: green → amber → red).
- DSH session token usage stats: how many tokens your DSH chats consumed in total, accumulated per day / per month / in total and broken down by model, persisted to disk.
- Cost estimation: estimates token usage cost with official rates from DeepSeek (peak/off-peak), Kimi, GLM, and others.
The widget is draggable, adapts to light/dark themes, and keeps a refresh button when collapsed into a small pill.
🖼 Preview
① Animation — hover to expand, move away to collapse (spring animation)

② Usage detail — OpenCode Go 5h / weekly / monthly usage and reset times

③ Token usage stats — today / this month / total + last-7-days bar chart + per-model stats + cost estimate

④ In context — the floating widget inside the chat

⑤ Balance type — auto-detects DeepSeek official balance vs plan (OpenCode Go) usage

Features
| Area | What you get |
| --- | --- |
| Account type | DeepSeek official (/user/balance), OpenCode Go (/usage via host proxy), OpenAI credit_grants, or a custom quota endpoint synced from the DSH model list |
| OpenCode Go display | 5h / weekly / monthly percentage badges in the main row; the collapsed pill shows only the percentage; the detail panel shows reset times |
| Token usage | Today / this month / total token counts, a last-7-days mini bar chart, per-model breakdown (input / output / cache-hit) |
| Cost estimate | ≈¥ badge (official rates: DeepSeek peak = off-peak × 2, Beijing 9:00–12:00 & 14:00–18:00; Kimi K2/K3 and GLM 4.x/5.x at constant rates; non-CNY official prices converted at 7.2) |
| UX | Draggable with remembered position, click-outside collapses, theme-adaptive, refresh button on the pill too |
🚀 Install as a DSH plugin
The plugin is published to npm (dsh-plugin-balance-english) and ships a dsh.bundle manifest, so it installs with the standard DSH plugin command:
dsh plugin add dsh-plugin-balance-english # default profile
# or explicitly the Web profile:
dsh plugin --profile web add dsh-plugin-balance-englishThis resolves the npm package, writes the bundle entry, and enables the plugin. Restart
dsh web(or hot-reload) and refresh the browser page.
🛒 Install from the plugin market (listed on dsh-market)
This plugin is listed in the awesome-dsh-plugin catalog and available on dsh-market, the plugin market built into DSH Settings. With dsh-market installed, search for dsh-plugin-balance-english under Settings → Plugin Market and install / upgrade with one click:
dsh plugin --profile web add dshmarketManual install (edit the profile yourself)
If you manage the profile yourself (offline environment / no dsh CLI):
Add a dependency to your Web profile's
package.json(e.g.~/.dsh/profiles/web/package.json) — an npm version, a tarball, or a local path:"dependencies": { "dsh-plugin-balance-english": "^1.3.6" }Enable it in
cordis.patch.yml(the package ships the exact entry ascordis.patch.yml):- insert: - id: plugin-balance name: dsh-plugin-balance-englishInstall and restart:
cd ~/.dsh/profiles/web pnpm install # restart `dsh web`, then refresh the browser page
Requires the
webServerandcredentialsservices (provided by@deepseek-ai/dsh-web-appin the web profile). The host half depends oncredentials,webServer,llm,settings, andsessions.
⚙️ Usage
Click the switch button to open settings:
- DeepSeek official balance: the key can be left blank (auto-uses DSH's
DEEPSEEK_API_KEY) or entered in the browser (stored inlocalStorage); a custom/user/balancebase URL is supported. - OpenCode Go plan usage: nothing to fill in — auto-reads the DSH credential
OPENCODE_GO_API_KEY(falls back toOPENCODE_API_KEY). - Custom quota endpoint: pick a vendor from the DSH model list (auto-fills
baseURLandapiKeyEnv) or fill it in manually; secrets are resolved host-side and never sent to the browser.
Click the bar-chart button to open the Token usage panel: today / this month / total + last-7-days bar chart + per-model stats + cost badges.
🧮 Token usage & cost
The host half listens to the DSH session event stream (session/event), folds each request's reported token usage (cache-miss input + cache write, cache hit, output) by day / month / model, and persists it to ~/.dsh/storages/dsh-plugin-balance-english-usage.json.
- Idempotent: a newer sample for the same
turn:stepreplaces the earlier one; replaying logs after a reload / restart never double-counts. - Model attribution follows each request's
request/header, so sessions that switch models mid-flight stay in the right bucket. - Cost uses each vendor's official rates (DeepSeek peak/off-peak; Kimi K2/K3 and GLM 4.x/5.x at constant rates, non-CNY prices converted at ~7.2), priced by the exact moment each sample occurred (see the note in the UI).
- Served to the client at
GET /api/dsh-plugin-balance-english/tokens. - Store format is
version 9: legacy data is no longer estimated — it is rebuilt exactly by replaying the session event stream (including archived on-disk logs).
