dsh-plugin-balance-ui: View Balance, Usage, and Cost Estimates in the DSH Web Sidebar

Introduction

When using DeepSeek Harness (dsh) with the Web client, you often have to open another page or dig through session logs to find out how much money remains in your account or how many tokens you burned today. The official balance endpoint can show your balance, but that information isn’t in the same UI surface as “how much dsh on this machine actually used today, and roughly how much that costs at current peak/off-peak prices.”

Below is an introduction to the community plugin dsh-plugin-balance-ui (maintainer novaschai7, GitHub: novaschai7/dsh-plugin-balance-ui). It adds a panel at the bottom of the dsh Web client sidebar, displaying your DeepSeek account balance, today’s token usage, today’s estimated spend, and whether the current Beijing-time billing tier is peak or off-peak. Hovering reveals breakdown and reconciliation details. The plugin is categorized as a Client plugin, currently has 0 GitHub stars, version 0.1.0, and is licensed under MIT.

What Is This

dsh-plugin-balance-ui is an account and usage panel plugin for the DeepSeek Harness Web client. Data is primarily derived locally from information dsh already has; apart from the DeepSeek official balance endpoint, no other third-party services are called.

What the Sidebar Shows

When the sidebar is expanded, the panel’s footer area roughly contains the following rows (refer to the README for exact meanings):

Row Meaning
Balance From GET /user/balance, displayed in the account currency
Today Total tokens for the day (input + output + cache hit), in compact format
Spend Estimated spend for the day based on the published price list, in CNY
Window Current Beijing-time tier: peak or off-peak
Reconcile Difference between local estimate and actual balance decrease (covers up to 7 fully sampled days)

When the sidebar is collapsed, the above values are stacked as compact text in the rail. Hovering shows a tooltip: top-up and granted balance, input/output/cache-hit token counts, request counts, itemized spend estimates by tier, the current price per million tokens, and the next Beijing-time switch point.

Where the Numbers Come From

The calculation methods described in the README are as follows.

Balance — The host side uses dsh’s credential mechanism to make requests to https://api.deepseek.com/user/balance with credentials attached, cached for 30 seconds.

Usage — The host side walks session logs under $DSH_HOME/sessions (default ~/.dsh/sessions), decompresses .jsonl.zstd, and sums tokens from each assistant/message since local midnight. Cache duration is 10 seconds, read-only.

Spend — The browser side prices each model row separately at peak and off-peak rates according to DeepSeek’s published CNY price list. reasoningTokens is reported by the host but not billed separately (already included in outputTokens); cache-write is treated as zero price (the price list only lists cache-hit input, cache-miss input, and output).

Peak and Off-Peak

Peak hours are Beijing time (UTC+8) weekdays 09:00–12:00 and 14:00–18:00, excluding Chinese public holidays; all other times (including weekends and holidays) are off-peak, with rates roughly half of peak. The host tags each assistant message with its billing window for tiered pricing; the tier badge switches at the next Beijing-time boundary (09:00 / 12:00 / 14:00 / 18:00 / midnight), rather than relying solely on polling intervals.

The price list is cited from the DeepSeek pricing documentation (CNY / million tokens). The README lists peak/off-peak input, output, and cache-hit unit prices for deepseek-flash and deepseek-v4-pro; retired deepseek-v4-flash and deepseek-v4-flash-vision-exp are aliased to deepseek-flash. Models not in the price list are marked as unpriced, and the spend row shows —.

The 2026 public holiday list is explicitly maintained in the plugin (based on Guobanfa Mingdian [2025] No. 7); the list must be updated annually (the new notice is usually published around November of the following year). Years not yet included are treated as “no holidays,” which may slightly overestimate spend during weekday peak hours. Spend is an estimate, not a bill; it does not include discounts, granted credits, or price changes after publication.

Reconciliation Row

The plugin periodically samples the account balance (roughly every 15 minutes, as well as during footer polling), and infers actual spending from the sum of balance decreases. Top-ups and grants (increases) are not counted as spend. The Reconcile row compares the difference between local estimates and this inference over days that have been “fully sampled since their respective midnights” (gradually growing up to 7 days); the tooltip breaks it down by day and explains observable causes (local unrecorded calls, discounts/grants, top-ups and sampling intervals, holidays, unpriced models, etc.). New installations show Insufficient samples before the first full day is complete.

The README explicitly notes two limitations: local sessions have no cache-write field, so if the official side bills for cache write, the estimate won’t capture it; reconciliation only applies to CNY accounts, and other currencies are not compared for errors.

Installation and Activation

Search for balance-ui in the dsh plugin marketplace (dsh-market) to install, or use the command line (must match the README exactly):

dsh plugin --profile web add dsh-plugin-balance-ui

After installation, restart the dsh service so the new profile layer can be composed.

Environment and Dependencies

  • Use a dsh profile bound to the Web application.
  • The DeepSeek API key must be provided via dsh credentials as DEEPSEEK_API_KEY; without a key, usage-related rows still work, only the balance row reports an error.
  • Node.js ≥ 22.15.0 (the host side uses zlib.zstdDecompressSync).

Host-Provided Read-Only Routes

The host side registers four same-origin, read-only JSON routes (all rejecting non-GET/HEAD requests and cross-origin requests) for the client to fetch data:

Route Purpose
GET /dsh-balance Balance and currency information
GET /dsh-usage Today’s token summary, peak/off-peak buckets, by model row
GET /dsh-usage-history?days=7 Historical usage bucketed by local day, days is 1–30
GET /dsh-spend-ledger?days=7 Daily sampled account changes, top-ups, grants, and sampling intervals

Typical usage requires no additional configuration: after installation and restart, open the dsh Web client, expand or collapse the sidebar, and the panel appears in the footer; hover over the panel for details.

Use Cases and Caveats

Suitable for developers who chat in the dsh Web client long-term and want to see balance, today’s usage, and estimated spend at peak/off-peak rates on the same screen. The DSH ecosystem advocates “everything is a plugin”; the SkillHub plugin directory is a community site with no official affiliation with DeepSeek / Hithink RoyalFlush.

The plugin runs with the permissions of the current dsh process; it reads local session logs and calls the DeepSeek balance endpoint. Before installing, review the GitHub repository source code and MIT license to ensure it meets your security and compliance requirements.

Summary

dsh-plugin-balance-ui puts DeepSeek balance, today’s tokens aggregated from local sessions, CNY spend estimated at Beijing-time peak/off-peak tiers, and optional reconciliation hints into the dsh Web sidebar footer, reducing the need to switch pages and calculate manually.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye