Introduction

When driving DSH with the DeepSeek API, there are two common pain points: first, checking the balance requires switching to the official backend, interrupting current tasks; second, estimating “how long the remaining balance will last” is quite difficult—DeepSeek’s pricing varies between peak and off-peak hours, and the price difference between cache hits and misses is an order of magnitude. Manual calculation is practically infeasible.

dsh-quota-meter solves this problem. It directly displays the remaining API balance in the bottom of the DSH Web interface sidebar, estimates available tokens based on “current model × off-peak/peak pricing,” and comes with a graph of actual spending per conversation round.

What is it

dsh-quota-meter is a DSH Web plugin maintained by huolianJiao, licensed under MIT, and currently at version 0.1.0. It requires dsh ≥ 0.1.0-rc.6 and a configured DeepSeek API key.

One-sentence description: It moves the DeepSeek API balance, estimated available tokens, and actual spending into the DSH sidebar.

Core Features

  • Balance Badge: When the sidebar is collapsed, it shows an icon with a status dot; when expanded, it displays a line showing “Balance · Estimated tokens · Period”.
  • Details Panel: Total balance / Gift balance / Recharge balance, availability status, hybrid estimation based on model × off-peak/peak, and cache intervals (0%–100% hit boundary, current period highlighted).
  • Actual Usage: Cache hit rate, input/output ratio, and a bar chart of actual spending per round. The bar chart is priced based on the timestamp of each round, with details visible on hover.
  • Visual Configuration: Edit pricing tables, peak windows, fallback ratios, etc., directly in the settings page. Changes take effect immediately without a restart.
  • Security: The API key is only parsed by the local host process and is never sent to the browser; the balance endpoint is only accessible via a loopback address.

The “Actual Usage” part is worth explaining: the hybrid estimation and cache intervals provide an estimate of how long the balance will last if the cache hit rate fluctuates between 0% and 100%, while the per-round spending bar chart is based on the billing standards of real requests (including cache hit ratio, input/output token counts). Comparing these two provides a much more accurate grasp of your budget.

Installation and Activation

First, confirm that your dsh version is ≥ 0.1.0-rc.6, then run:

dsh plugin --profile web add github:huolianJiao/dsh-quota-meter

If installing from a local checkout, use:

dsh plugin --profile web add link:./dsh-quota-meter

After installation, restart the web profile (run dsh web again) and refresh the page to see the balance badge at the bottom of the sidebar.

Configuring the API Key

The plugin defaults to reading the credential reference DEEPSEEK_API_KEY (which can be switched in the settings page). Choose one of the following:

Environment variable:

DEEPSEEK_API_KEY=sk-...

Or write to the DSH credential file $DSH_HOME/.credentials.yaml:

DEEPSEEK_API_KEY: sk-...

Plugin Configuration

There are two ways.

Settings Page (Recommended): Go to Settings → “DS API Billing”, and visually edit the pricing table, peak windows, fallback ratios, etc. Changes take effect immediately without a restart.

Patch File (To Hardcode Defaults): Override configuration in the profile’s cordis.patch.yml by id. Changes take effect after a restart:

- id: dsh-quota-meter
  config:
    apiKeyEnv: DEEPSEEK_API_KEY
    baseURL: https://api.deepseek.com
    pollIntervalMs: 60000
    summaryModel: deepseek-v4-pro
    peakWindows:
      - { start: "09:00", end: "12:00" }   # Beijing Time, [start, end)
      - { start: "14:00", end: "18:00" }
    pricing:                                # Yuan / Million tokens
      - model: deepseek-v4-flash
        offPeak: { input: 1.5, cacheHit: 0.05, output: 4.5 }
        peak:    { input: 3.0, cacheHit: 0.10, output: 9.0 }
      - model: deepseek-v4-pro
        offPeak: { input: 4.5, cacheHit: 0.15, output: 13.5 }
        peak:    { input: 9.0, cacheHit: 0.30, output: 27.0 }

Coverable keys include apiKeyEnv, baseURL, pollIntervalMs, summaryModel, peakWindows, pricing, etc. Note that peakWindows is in Beijing Time and uses a half-open interval [start, end); the unit for pricing is Yuan / Million tokens. When official prices are adjusted, simply modify this table.

Their respective roles: the settings page is suitable for daily adjustments and immediate effect; the patch file is suitable for solidifying the team’s unified pricing table and peak windows.

Development Notes

The plugin requires zero builds and works immediately after modification:

  • Modify lib/client.js (browser-side): Changes take effect by refreshing the page;
  • Modify lib/index.js (host-side): Changes take effect by restarting the web profile.
npm test   # Run smoke tests

The peerDependencies in package.json (@deepseek-ai/cordis ^4.0.1, @deepseek-ai/dsh-client-runtime / dsh-client-locale / dsh-client-ui-model-selection ^0.1.0-rc.6) are all marked as optional and will not force dependency pulling.

Use Cases and Notes

Suitable for these scenarios:

  • Developers who use DSH + DeepSeek API for long periods and want to keep track of their balance at any time without frequently switching to the official backend;
  • Batch tasks that require precise budget control: the hybrid estimation gives the magnitude of token counts, while the per-round spending graph shows real consumption;
  • Users who use multiple models and care about the price difference between off-peak and peak hours: the details panel displays data separated by model × period, making the price difference clear at a glance.

Please note two points before installation:

  1. The plugin runs with the permissions of the current dsh process. While dsh-quota-meter has security restrictions in its design (API key is only parsed by the local host process, balance endpoint is only accessible via loopback address), before installing any third-party plugin, you should read its source code first to confirm its behavior meets expectations.
  2. The plugin is under the MIT license, as noted in both the README and package.json. Confirm that the license meets your usage scenario before use.

Conclusion

dsh-quota-meter is very restrained in what it does: it directly displays the DeepSeek API balance, estimated available tokens based on models and periods, and actual spending per round in the DSH sidebar, while making the pricing table configurable. If you use DeepSeek heavily on DSH, this plugin can save you a lot of time switching backends and calculating price differences.

  • Directory: https://www.skillhub.cn/plugins/huolianJiao/dsh-quota-meter
  • GitHub: https://github.com/huolianJiao/dsh-quota-meter