dsh-balance: DeepSeek API Balance and Available Duration Next to the Composer Input Box

Preface

When running Composer or agents in DeepSeek Harness (DSH), token counts only reflect local usage, and balances on the platform console often lag by several minutes—the numbers barely move while you’re working. Recharges and batch settlements can also cause “copy-the-reading” numbers to mismatch real spending. If you want to see “how much longer I can use” directly under the Composer input box, you need to treat platform readings as periodic anchors, then decrement in real time based on local token consumption—this is exactly what the community plugin dsh-balance (npm package @zzxxxxxx/dsh-balance) does. The following sections describe its positioning, capabilities, installation, and configuration highlights; all facts come from the GitHub repository README and package metadata.

What is this

dsh-balance is published by maintainer zzzxxxxxxxxxx and categorized in the SkillHub directory as a networking tool. In DSH profiles with a web interface, it provides a reading pill under the input box showing the estimated balance and estimated available duration (ETA); the host polls DeepSeek’s balance endpoint semi-regularly, while the browser uses a semi-read-only snapshot—API keys do not leave the browser.

The plugin’s current version is 0.1.0, licensed under MIT, and requires DeepSeek Harness ≥ 0.2.0-rc.1.

Core Features

Anchor readings instead of lagging meter copies

Platform settlement typically lags by about 1–5 minutes. Each reading obtained from the platform serves only as a periodic anchor; the displayed value is “anchor − k × local consumption,” decreasing in real time based on local tokens. A reading taken at time T reflects usage up to before T − settlementLagMs; local accumulation starts from that cutoff to avoid double-counting the last few minutes.

Tiered pricing and correction factor k

Based on official peak-hour rates (cache hit/miss/output), the default price table covers deepseek-flash and deepseek-v4-pro; off-peak periods are priced relative to peak using offPeakFactor (default 0.5). Peak is defined as Beijing time Monday–Friday, 09:00–12:00 and 14:00–18:00 (excluding statutory holidays; other times at half price). A scalar k is learned from the median of recent balance decreases to absorb outdated price tables, unlisted models, and unified discounts. When the price table is accurate, k should be near 1.0—a useful self-check.

Recharges and abnormal drops

Only balance decreases are accumulated; recharges increase the wallet but do not enter consumption statistics, so k is not polluted. Large decreases not explained by local usage are recorded as “non-usage adjustments.” When etaIntegratesSchedule is enabled, ETA integrates across peak/off-peak periods to avoid underestimating near 18:00 by using peak prices.

UI and API

  • Pill: an example form is ¥36.35 · 2 days 4 hours; the status dot is normally green, turns orange below etaWarnMs, red below etaCriticalMs or when the balance runs out, and gray when uncalibrated or unable to connect.
  • Panel: clicking the pill shows the platform reading, locally estimated consumption, current estimated balance, time window and switching, consumption rate, correction factor, etc.; a “refresh now” button at the bottom right requests the host to refresh immediately.
  • No slash commands, no settings page; the host provides GET /dsh-balance/state and POST /dsh-balance/refresh.

Outbound destinations are only the balance endpoint; an optional second destination is a remote holiday source explicitly enabled (disabled by default). The credential reference is the same as the built-in deepseek-official provider: DEEPSEEK_API_KEY.

Installation and enabling

Environment requirements: DeepSeek Harness ≥ 0.2.0-rc.1, Node ^22.19.0 || >=24.0.0.

Installation from npm is recommended (note the scope—do not confuse it with the unscoped package dsh-balance):

dsh plugin --profile <profile> add @zzxxxxxx/dsh-balance

After installation, restart dsh (profiles are composed at startup).

The API key comes from the credential reference DEEPSEEK_API_KEY; you can configure it under Settings → Models, in $DSH_HOME/.credentials.yaml, or via environment variables; successful model calls indicate it is ready.

Uninstall:

dsh plugin --profile <p> remove @zzxxxxxx/dsh-balance

Restart is also required after uninstalling. In profiles without a web interface, the host still polls but does not display the pill.

Typical usage

  1. Run the above add command in the target profile and restart DSH.
  2. Open a session with the Composer web interface and confirm that the pill appears under the input box.
  3. For details or to manually align with platform readings, click the pill to open the panel; use “Refresh now” if needed.
  4. To adjust polling intervals, settlement lag, price tables, peak/off-peak windows, or ETA thresholds, modify fields under the profile plugin line’s config: (see below) and restart.

This plugin does not provide an independent settings page; all behavior is driven by the config in the cordis.patch.yml insert.

Configuration highlights

Configuration is written under the plugin insert’s config:; changes require a restart. Common fields (see the repository README for full defaults):

- insert:
    - id: dsh-balance
      name: '@zzxxxxxx/dsh-balance'
      config:
        apiKeyEnv: DEEPSEEK_API_KEY
        apiOrigin: https://api.deepseek.com
        balancePath: /user/balance
        refreshIntervalMs: 60000
        settlementLagMs: 300000
        priceTable:
          deepseek-flash: { input: 1, cacheRead: 0.02, output: 4 }
          deepseek-v4-pro: { input: 4.5, cacheRead: 0.15, output: 13.5 }
        offPeakFactor: 0.5
        peakWindows: ['09:00-12:00', '14:00-18:00']
        priceTimeZone: Asia/Shanghai
        etaWarnMs: 86400000
        etaCriticalMs: 14400000
        holidaySourceEnabled: false
        persist: true

Some semantics worth knowing:

  • settlementLagMs defaults to 300000 (5 minutes); the ETA numerator comes from the anchor, so it may be slightly smaller than that bound, but it does not drift with the lag.
  • The correction factor needs several decreases to stabilize; before that, the status is gray and “uncalibrated,” and the rate falls back to estimating from the balance difference.
  • The price table currency (priceCurrency) must match the wallet (default CNY); otherwise it falls back to weights for relative weighting.
  • Statutory holidays can be written via holidays / makeupWorkdays, or enabled via holidaySourceEnabled to fetch a remote source; unpublished years are not treated as “no holidays.”

Use cases and caveats

Suitable for: Developers who work long-term in DSH Composer, want to see DeepSeek API balances and approximate available duration in real time within the local UI, and are willing to accept “estimates rather than bill-level precision.”

Caveats:

  • The plugin runs with the current dsh process permissions and will access API keys and the balance endpoint; review the source code and the MIT license before installing, and evaluate the trust boundary yourself.
  • The README states the plugin is still early-stage and may have issues; report feedback in Issues.
  • SkillHub and similar catalogs are community directories and have no official affiliation with DeepSeek/HFAI; star counts and spread data are as shown by each site at the time (the repository clue indicates 0 stars).

Conclusion

After the steps above, you can get balance and ETA next to the Composer dock driven by “anchor + local tokens + peak/off-peak prices,” reducing the number of times you need to open the console to compare numbers. Catalog page: SkillHub — dsh-balance; source code and full configuration details: GitHub — zzzxxxxxxxxxx/dsh-balance.

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

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

Xiaoye