Introduction¶
When running DSH (DeepSeek Harness), you often need to manage wallet balances and Token Plan usage across multiple providers. Manually checking each provider’s console is repetitive and makes it easy to miss price fluctuations or discount windows. This plugin inserts a card below the DSH sidebar that aggregates the balances and usage of the providers you actually have enabled — showing only entries with data, and surfacing details like today’s drawdown, color-coded thresholds, night discounts, peak-hour indicators, and more.
What It Is¶
- Name: Balance Display (dsh-balance-display)
- Maintainer: dsh-balance-display contributors
- Repository: https://github.com/poloniumn/dsh-balance-display
- Category: Client
- Version: 2.1.1
- License: MIT
- Dependencies: DSH >=0.2.0-rc.2, Node >=20.0.0
- Core value: See wallet balances and Token Plan usage for all enabled model providers at a glance in the DSH sidebar.
Installation & Activation¶
Option 1: Library Manager (Recommended)¶
- Open the “Library Manager” panel in DeepSeek Harness.
- Switch to the “My Projects” tab.
- Use “Pull from Account” and enter
https://github.com/poloniumn/dsh-balance-display; or use “Local Import” and point to the directory you cloned. - Place it into the
dsh pluginfolder. - Restart DSH — the host-side code and sidebar card are loaded once at startup, so a restart is required for changes to take effect.
Option 2: Manual Clone¶
git clone https://github.com/poloniumn/dsh-balance-display.git
Place the cloned directory into DSH’s dsh plugin directory, or run the following from within the repository:
dsh plugin install .
Optional npm install:
dsh plugin install dsh-balance-display
The bundle injects a single loader entry dsh-balance-display; no additional host-side configuration is needed. All credentials are stored in the DSH credential store at ~/.dsh/.credentials.yaml — they are never written into plugin config, logs, or localStorage.
Usage¶
After installing and restarting, a card appears below the sidebar:
- Click the headings “Token Plan,” “Account Balance,” or “Third-Party Channels” to expand the corresponding section.
- Rows missing credentials display “Key not configured / –“. Clicking one jumps directly to “Settings → Plugins → Balance Display” where you can paste the value and click “Save & Test.” Values are validated before saving; errors are reported in place.
- The card refreshes every minute; if an upstream request fails, the last successful snapshot is retained so the card never flashes to blank.
Configuration¶
Settings Entry Point¶
The configuration entry is under “Settings → Plugins → Balance Display.” It shares the same console cookie settings page as dsh-model-panel: if dsh-model-panel is installed and loaded, that entry is reused; otherwise this plugin registers a page at the same location.
Credential Reference¶
The settings page is a single tabbed view, grouped by credential type. Each credential occupies its own card with a masked value, a link to the provider’s console, the current balance/plan usage, and a paste field. It supports Cookie-Editor JSON export, Netscape cookies.txt, or a full Cookie: header line, and also accepts file drag-and-drop.
Examples of where to obtain common credentials:
DEEPSEEK_API_KEY: https://platform.deepseek.com/api_keysQWEN_TOKEN_PLAN_COOKIE: Alibaba cookie (see below)XIAOMI_API_KEY: https://platform.xiaomimimo.com/console/api-keysXIAOMI_TOKEN_PLAN_CN_API_KEY: https://platform.xiaomimimo.com/console/plan-manageOPENCODE_GO_API_KEY: https://opencode.ai/console/workspace (automatically falls back toOPENCODE_API_KEYif not found)ZAI_CODING_CN_API_KEY/ZAI_CODING_API_KEY: Z.ai China / International (the two sites use different auth schemes)OPENROUTER_API_KEY: https://openrouter.ai/settings/keysSILICONFLOW_API_KEY,NOVITA_API_KEY,HYPERBOLIC_API_KEY,DEEPINFRA_API_KEY,AI_GATEWAY_API_KEY: each platform’s API Keys pageNANOGPT_API_KEY,SYNTHETIC_API_KEY,CHUTES_API_KEY,OLLAMA_API_KEY,APIGOTO_API_KEY: each platform’s API Keys pageMINIMAX_CN_API_KEY/MINIMAX_API_KEY: MiniMax China / InternationalZENMUX_MANAGEMENT_API_KEY: ZenMux Management Key (inference keys cannot query quota)KIMI_API_KEY,MOONSHOT_API_KEY: reuses the key from DSH model routing; must be filled in under the provider configuration
Alibaba (Qwen Token Plan) Cookie¶
Qwen has no public API for querying plan usage — the numbers only exist behind a console session. So the plugin stores the console’s Cookie request header:
- Log in at https://platform.qianwenai.com/home/billing/subscription/token-plan
- Open DevTools → Network → pick any request to
platform.qianwenai.com - Copy the full
Cookierequest header - Paste it under “Settings → Plugins → Balance Display” → “Qwen Token Plan console cookie” → Save & Test
The cookie expires in roughly 7 days; when you see “Session expired,” simply copy it again. You can also use the CLI tool:
npx dsh-balance-qwen-cookie --paste # hidden input, validates before writing
npx dsh-balance-qwen-cookie --from-copy # reads directly from clipboard
npx dsh-balance-qwen-cookie --check # checks whether the stored credential is still valid
npx dsh-balance-qwen-cookie --remove
Display Content & Details¶
Only providers that are actually enabled in your DSH config are shown: the plugin reads the providers list from the llm-pi-ai config (including inherited / override layers) and keeps entries without disabled. DSH login itself provides deepseek-account; third-party channel rows appear only when dsh-connect is installed; EAC router credit rows appear only when our Free Model is installed.
Balance & Plan¶
- Today’s drawdown: the yellow
-¥0.42before the amount is the wallet decrease since midnight today. Topping up only resets the baseline; it does not erase the day’s usage. - Color coding: CNY balance below 10 turns yellow; below 1 (including negative) turns red.
- Plan rows: the label is “Provider · Plan”; the yellow
↓4%is the percentage consumed today (down arrow = consumption); the progress bar shows cycle usage and remaining days. - Night discount: when a provider’s discount window is active, a green “Night 60% off” tag appears after the plan name, listing the models covered by the discount. Qwen’s schedule and rates are fetched once per day from the model catalog; MiMo’s come from the public Token Plan FAQ.
- Peak hours: a green dot / red dot after the balance indicates whether you’re currently in a peak window; hover to see the time range.
EAC Router Credits¶
Each channel on the our Free Model EAC router page gets its own row: Remaining credits 1.2K, Remaining balance (USD) $3.50, Remaining tokens, or Remaining quota with a progress bar. Gemini quotas are not summed across model pools; channels without a configured account simply don’t appear.
Other Details¶
- Collapse state is remembered per browser: all three sections are collapsed by default; clicking a heading expands or collapses that section individually; all three collapsed is also a valid state.
- No gear icon on the card: configuration lives under “Settings → Plugins → Balance Display.” Rows missing credentials are still clickable, and when the card has no data a “Configure Key” button is available, so you can reach settings even if the dialog is unreachable.
Data Fetching¶
Provider API contracts are sourced from dsh-subusage (MIT, KouzakiUmi). Adapters declare only endpoints, auth modes, and pure parsing functions; all requests are handled uniformly by the host-side lib/upstream.js.
Common patterns and handling:
- Bare
Authorization: Z.ai International, Ollama Cloud — usesauth: 'raw', noBearerprefix x-api-key+ POST: NanoGPT balance, standalone endpointPOST {}, paired with a management-key host- Cookie session: Qwen, MiMo console — uses
auth: 'cookie'with Origin / Referer - Dual endpoints with partial-failure degradation: OpenRouter, ZenMux, Kimi, NanoGPT — primary endpoint required, secondary endpoint
optional: true; a 403 on the secondary drops only the auxiliary info, the row doesn’t fail - Business error codes inside a 200 response: MiniMax
base_resp.status_code, mapped toexpired/error - Varying currency units: Novita 1/10000 USD, Hyperbolic cents, DeepInfra negative balances, Vercel decimal strings — each
parse()explicitly converts - Same key, two reference names: OpenCode Go — tries each name in order via
secret.aliases
Unified guardrails: 10-second timeout, redirect: 'manual', 1 MiB response cap; 3xx is not misclassified as credential expiry; 401/403 → expired; 408/429/5xx marked as retryable; non-JSON responses treated as session invalidation. A few hand-written adapters still use the generic getJson with an 8-second timeout.
kimi-coding first tries the subscription quota endpoint (4-second timeout); on failure it automatically falls back to the Moonshot wallet, so both subscription keys and open-platform keys can produce data.
EAC router channels go through lib/ofm-credits.js, accessing our Free Model’s usage.badge via an in-process host Connection (createPeer + createSharedFetchHandler('/api')), because a bare loopback fetch to /api/* without a session is rejected by the gateway. usage.badge was chosen because it has host-side caching, contains only enabled accounts, and avoids amplifying the request count of minute-level polling.
Providers not yet ported are those that depend on local OAuth login files, QR-code scanning, or IAM signatures (Grok, Codex, GitHub Copilot, Volcano Ark, Command Code) — they require the host’s login and credential-record services and cannot be resolved with a single HTTP request.
Privacy & Network Requests¶
- Credentials are sent only to the addresses declared by the provider adapters, with timeouts. They are never sent to a URL supplied by the browser.
- The status endpoint is restricted to DSH window access: loopback host, loopback (or absent) origin, non-cross-site
Sec-Fetch-Site, plus the host’s ownconnection.requestRejection. - The write endpoint (
POST /dsh-balance/secret) accepts a single value, validates it, and writes to the DSH credential store; plaintext is never returned — the settings page only shows the masked value. - Beyond the configured provider endpoints, the plugin only contacts: two public documentation pages (DeepSeek pricing, MiMo plan FAQ — once per day), the Qwen model catalog (once per day, at the start of a discount window), local
dsh-connect, and our Free Model’s own/api/channel-pack(via in-process host Connection, no network hop, and it only reads the already-cachedusage.badge).
Data Files¶
Cache lives at <DSH_HOME>/dsh-balance-display/ (default ~/.dsh/…):
| File | Contents |
|---|---|
baseline.json |
Per-row daily baselines used to compute “Today’s drawdown” |
schedules.json |
Peak / night windows scraped from public pages |
qwen-discount.json |
Qwen discount labels and their fetch timestamps |
last-state.json |
The last snapshot with real data: used as a fallback when the credential store isn’t ready yet; never overwrites a valid cache |
Deleting this directory restores the initial state.
Ecosystem & Notes¶
- This plugin is part of the dsh-plugin ecosystem and has no official affiliation with DeepSeek / High-Flyer.
- The plugin runs with the current DSH process’s privileges. Review the source code and license before installing.
- Best suited for scenarios where you manage multiple model providers through DSH and need centralized monitoring of balances and plan usage.
Summary¶
The Balance Display plugin presents a unified view of wallet balances and Token Plan usage for all enabled providers in the DSH sidebar. It provides today’s drawdown, color-coded thresholds, night discounts, peak-hour indicators, EAC router credits, and more, while automatically reading configuration from the DSH credential store. After installation, simply restart DSH to activate. Configuration is accessible under “Settings → Plugins → Balance Display.”
- Plugin directory: https://www.skillhub.cn/plugins/poloniumn/dsh-balance-display
- GitHub: https://github.com/poloniumn/dsh-balance-display