Foreword

When using DeepSeek within DSH Web, checking the account balance, current session model, and token usage typically requires leaving the current session. Below is an introduction to a community plugin: it adds a balance button to the session header; clicking it opens a dropdown to view the account balance, current session model, real-time token usage, and cost estimates based on the DeepSeek official price list.

The philosophy of DSH is “Everything is a plugin”. The community directory is an independent site with no official affiliation with DeepSeek or Fanshu. This plugin is suitable for developers already using DSH Web and the DeepSeek API.

What is this

lmmzss-jk/dsh-plugin-balance is a Web plugin for DeepSeek Harness (DSH), maintained by lmmzss-jk, and licensed under MIT.

The installation name is:

@lmmzss/dsh-plugin-balance

The repository address is:

https://github.com/lmmzss-jk/dsh-plugin-balance

It reuses the DSH-configured DEEPSEEK_API_KEY, making it zero configuration. The plugin places the account balance, current session model, and token usage into the session header, reducing the steps of repeatedly switching away from the session to check the account.

Core Features

Session Header Balance Button

  • The button is located to the left of the native Session log button.
  • The client registers to the conversation.session.header.utilities slot with order: -10.
  • The button automatically hides when the “Settings” page is opened and restores after closing the settings.

After clicking the button, the dropdown panel displays:

  • Account balance.
  • Current session model.
  • Real-time token usage.
  • Cost estimates calculated based on the DeepSeek official price list.

Real-time Token Usage

  • Token usage subscribes to the token-meter session projection.
  • The token number updates in real-time during the model’s streaming response.

Price Sync and Peak/Valley Adaptation

  • The host syncs the official pricing page every 6 hours using ETag conditional requests.
  • Automatically extracts peak and valley prices along with their effective dates.
  • Falls back to the built-in price list when offline.
  • The client fetches the latest price when opening the panel and caches it locally for 12 hours.
  • Automatically determines peak or off-peak periods based on Beijing time.
  • Switches between old and new price lists according to the effective dates of official pricing adjustments.

Status Prompts and Multi-language

  • Status prompts are provided for low balance, exhausted balance, invalid or unconfigured API Key, and network errors.
  • It is adaptive between Chinese and English, automatically switching text based on the browser language.

Request Proxy

  • The host proxies the request to /user/balance.
  • The API Key is not exposed to the browser.

Installation and Enablement

First, confirm that the DSH environment meets the following:

Node.js >= 18
@deepseek-ai/cordis ^4.0.1 (optional peer dependency)

Next, confirm that the DeepSeek API Key is configured. It can be located in:

Settings → Models
~/.dsh/.credentials.yaml

Install the plugin:

dsh plugin --profile web add @lmmzss/dsh-plugin-balance

Restart dsh web after installation for the plugin to take effect.

After enabling, go to the DSH Web session header and check the balance button to the left of Session log; click the button to view the account balance, current session model, real-time token usage, and cost estimates.

Uninstall the plugin:

dsh plugin --profile web remove dsh-plugin-balance

Typical Usage and Local Development

If you are only using the plugin, completing the installation and enablement above is sufficient.

If you wish to view the source code or make local modifications, you can first load it via a local path:

dsh plugin --profile web add /path/to/dsh-plugin-balance

Modifications to lib/client.js take effect after refreshing the page; modifications to the host or configuration require restarting dsh.

You can run the following during development:

npm test
node scripts/prepublish-check.mjs

Suitable Scenarios and Notes

Suitable for the following scenarios:

  • Frequently calling DeepSeek within DSH Web.
  • Wanting to view balance and current session token usage directly in the session header.
  • Needing rough cost estimates based on the DeepSeek official price list.

Notes:

  • Cost estimates are calculated in real-time based on the DeepSeek official price list and are for reference only.
  • The actual bill takes precedence over platform.deepseek.com/usage.
  • Prices are synced from the official page every 6 hours and cannot cover situations where the official page has not updated in time.
  • “Cache Write” is always 0 because the DeepSeek API does not report this field; this is a normal phenomenon.
  • The plugin runs with the permissions of the current dsh process; please check the source code, license, and dependencies before installing.
  • The community directory is an independent site with no official affiliation with DeepSeek or Fanshu.
  • Specific directory page URLs do not appear in this material.

Links

  • GitHub: https://github.com/lmmzss-jk/dsh-plugin-balance
  • Community Directory: Specific URL is not provided in this material; please refer to the actual directory site entry.