dsh-simple-usage-info: View DeepSeek balance and peak/off-peak billing windows below the input box

Preface

When running sessions via the official API route in DeepSeek Harness (DSH), tokens are billed according to peak and off-peak rules. Checking the remaining account balance or determining whether the current time is a peak or off-peak period often requires switching to a console or opening a separate page. If you want to estimate the cost of the current conversation while a session is in progress, the lack of an integrated entry point within the Composer makes it even more inconvenient.

Below is an introduction to the community plugin dsh-simple-usage-info (maintained by MarJose123). It embeds DeepSeek API balance, current billing window (Peak / Off-peak), and estimated cost for the current session into the Composer dock of the web interface—specifically, the ambient row located below the message input box and after the context meter bar. Clicking this bar expands the details. The plugin is categorized as a “Web Tool” in the SkillHub directory. In the ecosystem, DSH adheres to the philosophy that “everything is a plugin.” The SkillHub plugin directory is an independent community site and has no official affiliation with DeepSeek or Hithink RoyalFlush.

What is this

dsh-simple-usage-info is a DeepSeek Harness plugin (the npm package name matches the plugin ID; the current README corresponds to version 0.2.4, license MIT). It does not replace model routing. Instead, assuming the existing DEEPSEEK_API_KEY credentials, it displays the balance and billing status on the browser side and provides a session-level cost estimation when there is token consumption.

The balance query and the deepseek-official model routing resolve the same set of DEEPSEEK_API_KEY environment variables (the default config item apiKeyEnv is DEEPSEEK_API_KEY), so there is no need to configure a separate Key for the plugin.

Core Features

Interface Position and Interaction

The plugin adds an info bar below the Composer input area; screenshots can be found in the repository’s showcase. The pill on the bar displays Off-peak (green) or Peak (red). Clicking it reveals a full breakdown (balance, window, pricing, etc.).

Peak/Off-Peak Windows and Holidays

Billing windows are calculated in the browser’s local timezone according to the rules published by DeepSeek: Off-peak is half price; Peak hours are 01:00–04:00 and 06:00–10:00 UTC on weekdays (Monday to Friday), excluding Chinese statutory holidays. The holiday list is fetched from NateScarlet/holiday-cn (synced daily with State Council announcements) to keep the date table updated. The config allows modification of peakWindows, peakDays, and holidayURL, or you can use the bundled table as an offline fallback.

Session Estimated Cost

When there is non-zero token usage in the current session, an Estimated cost block appears. It converts cached input, uncached input, and output into USD and CNY based on current peak/off-peak unit prices. Supported models are deepseek-flash (DeepSeek-V41-Flash) and deepseek-v4-pro (DeepSeek-V4-Pro-0813), with rates consistent with the model selected for the session.

Server-Side Interface

The plugin provides HTTP routes for data such as balance; after the service starts, you can request:

curl -s -H 'Host: 127.0.0.1:3080' http://127.0.0.1:3080/usage/balance

The pricing.holidayData in the response distinguishes the source of holidays: remote (fetched remotely), bundled (offline fallback), or none.

Environment and Dependencies

Please confirm before installation:

  • DeepSeek Harness 0.2.0-rc.2 or higher
  • Node 20+
  • DEEPSEEK_API_KEY is configured (can be written in the DSH Models page or exported before startup)

Installation and Enablement

The DSH plugin manager forwards to pnpm. If you do not have pnpm locally, install it first:

bun add -g pnpm        # or: corepack enable pnpm / npm i -g pnpm

It is recommended to install via the web profile:

dsh plugin --profile web add dsh-simple-usage-info

The above command installs the npm package, writes to the profile’s dependencies, and appends the package name to dsh.profile.bundles. Since the package declares dsh.bundle.patch, its built-in cordis.patch.yml will inject the loader line, so manual modification of the bundle list is generally not required. After installation, restart the Web service (dsh web).

Manual Enablement (cordis.patch.yml)

If the package is already available at a path resolvable by the profile (local link, private source, etc.), you can append to $DSH_HOME/profiles/web/cordis.patch.yml:

- insert:
    - id: usage-info
      name: dsh-simple-usage-info

Then restart dsh web. Do not use both the bundles entry generated by the recommended installation and the insert line above simultaneously, otherwise the plugin will be loaded twice.

Split Steps without pnpm

dsh plugin only installs dependencies via pnpm. You can first install it in the profile directory using any package manager, or symlink a local checkout and declare it in the dependencies of package.json. Then activate it via an insert line in cordis.patch.yml or by appending "dsh-simple-usage-info" to dsh.profile.bundles. See the GitHub README for details.

Configuration

In the profile’s cordis.patch.yml, set config under the usage-info corresponding line. Common items are as follows (refer to the README for the complete table):

Key Default Value Meaning
refreshMs 60000 Cache duration for a single balance result
timeoutMs 15000 Upstream request timeout
baseURL https://api.deepseek.com API root address
apiKeyEnv DEEPSEEK_API_KEY Environment variable name storing the API Key
peakWindows ['01:00-04:00', '06:00-10:00'] Peak hours (UTC, HH:MM-HH:MM)
peakDays [1, 2, 3, 4, 5] Peak days of the week (0=Sunday)
offPeakDiscountPercent 50 Off-peak discount percentage

Example: Customize peak windows and append holidays:

- id: usage-info
  config:
    peakWindows:
      - '01:00-04:00'
      - '06:00-10:00'
    holidays:
      - 2027-01-01

If peakWindows, weekdays, or clock formats are invalid, the plugin will report an error and skip that line during the loading phase to avoid responding to requests with incorrect windows.

Typical Usage and Verification

  1. Install according to the previous section and restart dsh web, ensuring DEEPSEEK_API_KEY is available.
  2. Open the Web Composer, view the balance and Peak/Off-peak pill below the input box; estimated costs are visible when there is token consumption.
  3. When confirmation on the script side is needed, execute against the running service:
curl -s -H 'Host: 127.0.0.1:3080' http://127.0.0.1:3080/usage/balance
  1. Without modifying your existing $DSH_HOME, you can execute bun run verify:compose within the plugin repository to check if the profile correctly composes the usage-info line.

Developers can also run bun run preflight (offline assertions), bun run preflight:live (real balance and holiday fetching), and bun run preview:panel (preview popover markup) within the repository. The plugin has no separate build step; lib/index.js and lib/client.js are directly loadable ESM files.

Use Cases and Notes

Who it is for: Developers who use the DeepSeek official API in DSH Web for long periods and want to see the balance, whether it is currently a peak period, and the rough cost of the current session on a single screen.

Runtime Permissions: The plugin is loaded with the current DSH process and will use the API Key in the process environment to access the configured API and holiday URLs. It is recommended to read the source code and LICENSE before installation to ensure it meets your security and compliance requirements.

Networking: Balance and (default) holiday data require outbound access; setting holidayURL to an empty string switches to an offline strategy, relying on options like useBundledHolidays.

Conclusion

dsh-simple-usage-info consolidates DeepSeek account balance, peak/off-peak billing windows, and session estimated costs below the Composer input area. It shares credentials with the existing DEEPSEEK_API_KEY, making it suitable for users who want to control costs and avoid peak hours in DSH daily.

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

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

Xiaoye