Shows the current provider's account balance or coding-plan quota above the composer, with usage percentages and reset countdowns.
Install
# from npm (prebuilt)
dsh plugin --profile web add dsh-usage-state
# from GitHub (first run asks for allowBuilds approval — follow the hint, retry)
dsh plugin --profile web add github:takboo/dsh-usage-state
Any plugin you install runs third-party code with your own permissions — it can read your files, use your credentials, and reach the network, and tool approvals don’t sandbox it. GitHub-sourced plugins also run build scripts at install time — pnpm blocks those until you allow them, so an install can stop with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED or ERR_PNPM_IGNORED_BUILDS; dsh prints the exact key to add under allowBuilds in your profile’s pnpm-workspace.yaml, and the install works on the next run. Allowing a build is a trust decision: only install sources you trust, and pin a commit (github:owner/repo#sha).
README
中文 | English
0.4.15 adds OpenAI organization monthly spend (Admin Key), plugin-row configuration and local Save/Reset drafts. It fixes legacy configuration saves, endpoint editing, credential ownership and lifecycle cancellation while keeping the existing host support declarations. See the GitHub Release for the tarball and checksum and the Changelog for details.
Show the current model provider's account balance or coding-plan quota above the composer input in DSH (DeepSeek Harness). The line matches the input card's width and preserves the native statistics and context meter.
z.ai / GLM · ◔ 5h 12% (4h0m) · ◔ 7d 59% (3d17h)
DeepSeek · ¥58.13
Features
- Recognized providers default to Auto and reuse existing DSH credentials. Configuration is per provider; the model list is informational.
- Balances, used percentages, reset countdowns and SVG rings, with configurable amber/red thresholds (80%/95% by default) and an option to hide rings.
- An explicit OpenAI Admin mode reports organization-wide USD spend for the current UTC month, separately from balances and plan quotas.
- A failed source request keeps the last successful reading for the same effective account identity, with its age and reason. An RPC failure also marks retained values as stale.
- Hover details include source, mode, reset time and balance components. The UI follows DSH's Chinese/English language setting.
- Current account readings only: no cost attribution, price catalog, budgets or historical bills.
Install
Requires DSH matching ^0.2.0-rc.2 || ^0.2.1-rc.1 (verified on 0.2.0-rc.2 and 0.2.1-rc.1/rc.2/rc.3/rc.5). The prebuilt plugin declares Node ≥20. Install into the web profile you actually use.
Install from npm:
dsh plugin --profile web add dsh-usage-state
# Restart DSH afterwards: the bundle patch is read at startup.
You can also install from GitHub:
dsh plugin --profile web add github:takboo/dsh-usage-state
This repository commits prebuilt artifacts for DSH's GitHub installation path. A floating Git branch may be ahead of npm; record the source and version/commit when reproducing an issue. This does not describe every npm Git installation's lifecycle.
You can also search for Balance & Quota, dsh-usage-state or takboo in dsh-market; check the actual installation source and version afterwards. The plugin is on the curated list; catalog visibility depends on the selected region and a successful catalog build.
Use historical version 0.3.2 on DSH 0.1; it does not work on 0.2. Version 0.4.0 has a broken RPC mount, so upgrade to the latest compatible release. See the Changelog for version history.
Quick start
Version 0.4.15 introduces the plugin-row settings entry and draft workflow below; 0.4.14 and earlier use the separate settings entry. The new entry has been opened on Desktop 0.2.1-rc.5, with Save/Reset verified in an isolated browser on the same version. Earlier hosts in the declared range still need entry-specific validation; historical RPC checks do not certify the migrated page.
- Open Plugins → Balance & Quota → Configure, rather than the global settings sidebar.
- Each provider has one compact row. Choose Auto, a supported API Key balance / Account balance / Coding Plan mode, or Hidden from its dropdown. The row shows the detected mode, source and status; models and advanced overrides stay collapsed.
- Sub2API reuses the provider's existing endpoint. Expand advanced settings only when an address is missing or an override is needed. Harness manages account-mode sign-in, with no API key input. Ordinary OpenAI keys still cannot query a balance; explicitly select “Organization spend (Admin Key)” and configure a separate Admin credential to opt in.
- Click Save settings to apply mode, order, endpoint, refresh and display changes together. Reset adopts the latest saved configuration; leaving the page discards unsaved edits. Draft configuration does not change the line above the composer.
- Refresh now explicitly queries readings for the saved configuration; it does not save edits. Check the row's reason and the troubleshooting guide (Chinese) on failure.
A credential name is not the secret itself. Use a name such as OAI_USAGE_READONLY, matching [A-Za-z_][A-Za-z0-9_]*: start with an ASCII letter or underscore, followed by letters, digits, or underscores. Hyphens, spaces, and non-ASCII characters are not supported. Invalid API Key or Admin credential names show a validation message and block settings saves and key writes/deletions. Correct the name; a restart does not fix invalid syntax.
Configuration and credentials save separately. Save key now / Clear key now are immediate actions and are not undone by resetting configuration. After editing a provider's mode, source, endpoint or credential name, save settings and wait for the current target's permission description before editing its key. Display or order drafts do not block independent key actions. API Key advanced settings offer endpoint, credential name and key controls. Explicit provider overrides take precedence over legacy source defaults, and descriptions and requests share the candidate order. Pinned endpoints do not try mirrors; configuration or credential identity changes discard previous-identity readings. Configuration and credential permissions are separate. Pending saves prevent duplicate submissions, and failed saves preserve the draft. If another page changes configuration, reset and reapply your edits rather than silently overwriting external changes.
Sources
| Source | Balance / spend reading | Coding-plan reading | Main credential |
|---|---|---|---|
| DeepSeek official API Key | CNY/USD balance | — | DEEPSEEK_API_KEY |
| DeepSeek account sign-in | CNY/USD recharge and bonus balance | — | Current Harness login |
| Official OpenAI | No ordinary-key balance API; explicit Admin mode reports organization-wide UTC-month USD spend, not balance | — | Separate manual adminKeyRef; no auto key lookup |
| z.ai / Zhipu GLM | — | 5h / 7d used % | ZAI_API_KEY and related refs |
| Kimi / Moonshot | CNY balance | Kimi Code subscription windows | MOONSHOT_API_KEY / KIMI_CODING_API_KEY |
| OpenCode Zen Go | — | 5h / 7d / 30d used % | OPENCODE_GO_API_KEY / OPENCODE_API_KEY |
| Sub2API | Balance or key allowance | Depends on the instance, e.g. 5h / 1d / 7d / 30d | SUB2API_API_KEY and instance URL |
DeepSeek Desktop account sign-in: deepseek-account automatically uses “Account balance” through the Harness account service, adding recharge and bonus wallets. deepseek-official uses “API Key balance”. Queries and caches are separate; account mode never probes or falls back to DEEPSEEK_API_KEY. Sign in through Harness account settings. Account mode requires the host account service; older hosts without it need an upgrade. Harness owns the endpoint and login grant; account mode has no API key fields.
Official OpenAI: auto and ordinary-key modes still explain the balance API limitation and link to official billing, without looking up an ordinary key or probing a balance endpoint. To opt into spend reporting:
- An organization owner creates a key in Admin keys, granting only read access to Usage where possible. Ordinary project/inference keys cannot replace it; do not automatically expand permissions after a 403.
- Explicitly select “Organization spend (Admin Key)”, enter a separate Admin credential name, and save settings first. Then save the key immediately in the credential area, or reference a credential already managed by Harness. Secrets never enter plugin config; inference credentials are not discovered or reused for this mode.
- The official Costs API reports organization-wide USD spend reported so far in the current UTC calendar month. This is not project-, model-, session-, or key-specific, and is not a balance, remaining budget, or final invoice. The tooltip shows the actual month and query time; ingestion may lag, and the query timestamp is not an ingestion watermark. A complete query without cost rows shows “No cost data”; only an explicitly returned numeric zero displays zero. Costs use UTC daily buckets; requests omit a current-second
end_timeso today's costs are not excluded. Returned buckets are still validated against the captured clock, within the current month through that day.
Official-source detection uses the exact parsed hostname api.openai.com, not model names, protocol compatibility, or substring matching. Third-party gateways require their own balance protocol. Admin transport is stricter: it always uses https://api.openai.com/v1/organization/costs with redirects rejected, ignoring HTTP/custom-port/gateway endpoint overrides. Explicitly select the OpenAI source to associate a gateway model route with official organization spend; the plugin cannot infer that these accounts match. Credential changes and UTC month rollover clear old spend; failures retain values only for the same identity and month. Only the first effective provider owns each source+mode target; this is not independent multi-organization support.
Kimi Code routes kimi-code, kimi-coding, and kimi-for-coding, plus custom providers declaring api.kimi.com / api.kimi.ai, automatically read subscription usage. The plugin displays only returned windows: 5h, 7d, monthly total, and monthly code usage. Moonshot regional APIs retain CNY balance mode. Explicit settings take precedence.
Percentages mean used. z.ai keys belong to their China/global region; China is the default endpoint and failures may try the mirror. The current cache merges by source and mode, so separate keys/instances must not be treated as supported independent accounts. Endpoints, field semantics and extension steps are in the adapter guide (Chinese).
Screenshots
OpenCode Zen Go's three windows on the independent line above the input:

Actual settings-migration screenshots on Desktop 0.2.1-rc.5, with the private sidebar cropped out. These captures predate Admin mode and do not show its credential controls. Light theme: compact provider rows, mode dropdowns and collapsed advanced controls. OpenAI auto mode shows its balance API limitation inline:

Dark theme with official DeepSeek advanced settings expanded: models are reference-only; endpoint and credential-name overrides are optional. Key saves/clears take effect immediately and are not undone by configuration Reset.

Refresh and credentials
The host schedules refreshes 2 seconds after a turn ends and has a 5-minute fallback timer. The browser reads the RPC mirror every 30 seconds. Ordinary polling initializes a missing or changed account identity, otherwise it does not shorten idle queries to once a minute. Successful requests have a default 60-second minimum; explicit refresh can bypass it, and active retries after failure are not throttled by that successful-request interval. Editing the idle interval reschedules the timer.
The plugin queries balances/quotas and reads the selected model and provider catalog. It writes no session logs and reports no readings to third parties. The host does not return stored key values to the browser; a key the user actively pastes is sent through DSH's credential service to the credential file in the selected home. Credential precedence follows the host: DSH 0.2.1-rc.1/rc.2/rc.3 Web/Desktop prefers saved credentials, with environment values as fallback; 0.2.0-rc.2 prefers the environment. The settings page reflects the host’s actual write permissions.
Known limitations
See the Backlog (Chinese) for remediation status and verification scope.
- Account scope: one target is still selected per source and mode. Identity isolation does not add independent multi-account support.
- Live verification: real Desktop account sign-in and balance comparison, Kimi Code monthly quotas, Sub2API accounts, long provider names, Chinese settings, high-threshold colors, real credential writes and nonzero OpenCode readings still lack live coverage. Local interaction tests do not replace that acceptance.
- Scope: the line can be absent without a selected model or when hidden; clicking it does not open settings; readings are not saved as history.
Development and docs
Development supports Node 22.18+ on the 22 line or Node 24.11+. Canonical builds pin Node 24.22.2 (.node-version) and npm 11.19.1 (packageManager), above the runtime floor. Basic checks:
npm ci
npm run typecheck
npm run build
npm test
See the development guide (Chinese) for local profiles, watch and HMR requirements. The documentation index (Chinese) links architecture, design, release, audit and research material by task.
Acknowledgements and license
Thanks to dsh-cost-meter by Han-1413141 (MIT) for data-source behavior references. This TypeScript implementation was written independently; endpoint, field and compatibility provenance is recorded in the upstream analysis. DSH provides settings, credentials, RPC, slots and theme tokens; UI controls are implemented by the plugin. The original balance/quota icon is distributed under the project's MIT license.
MIT. Report problems or attribution suggestions through Issues.
Links
More in this category
bowenliang123/dsh-context★ 4963
DSH context insight panel: Context dashboard + /context command + Context browser — one-stop context lifecycle management with categorized composition, content details, evolution trends, compaction/injection events, and stats.
Han-1413141/dsh-cost-meter★ 675
Per-session and daily API cost, budget with usage %, official balance, history dashboard, and one-click official price sync with peak/off-peak pricing.
wssfk12138/dsh-damage-pulse★ 290
Tracks DeepSeek token usage, per-call and session costs, and account balance with cache-aware charge animations in the DSH Web UI.
zh667/TokenLedger★ 204
Sidebar usage panel that attributes tokens to the relay site that served each request, read from your existing provider config: today/month/all-time totals, per-site and per-model breakdowns, a year activity heatmap, and New API / Sub2API / DeepSeek balances.
Ychris12138/dsh-usage-stats★ 188
Multi-provider usage dashboard with provider/model token breakdowns, calendar drill-downs, account balances, and OpenCode Go / Z.ai subscription quota tracking.
Mt-Youya/dsh-plugins#sessions-insight★ 126
Browse Claude Code, DSH and Codex session logs by working directory, with per-turn context composition, token usage, compaction markers and cost estimates.
Community comments
Comments are public GitHub Discussions. Loading them connects to GitHub and Giscus; a GitHub account is required to post.