DeepSeek Harness Balance & Peak/Off-Peak Time Slot Plugin: dsh-visualcost

Preface

When DeepSeek Harness (DSH) runs on the desktop, checking API balance and today’s spending often requires visiting a web page. During long conversations or batch development tasks, frequently switching to a browser to check balance and usage disrupts the workflow. dsh-visualcost displays the balance, today’s per-model spending breakdown, and the current peak/off-peak pricing period directly in DSH’s composer status bar.

Overview

dsh-visualcost is a community-maintained DSH plugin that displays the DeepSeek API balance, today’s per-model spending breakdown, and the current peak/off-peak pricing period in the composer status bar. It calls DeepSeek’s official balance and usage APIs directly to retrieve data, with no reliance on third-party services.

Core Features

  • Status bar capsule: Displays the balance and the current period label, e.g., ¥63.14 · ● Off-Peak. Large balances are compressed (e.g., ¥100.00M), and the capsule turns red when the balance falls below the configured threshold.
  • Hover tooltip: Shows the remaining time until the next peak/off-peak switch, e.g., 4 hours 25 minutes to switch. If the interval exceeds one day, it displays X days Y hours.
  • Click popup: Displays the current period, remaining balance, spending amount (accurate to the cent, with thousands separators), along with a per-model spending bar chart and legend.
  • Balance alert toggle: If the platform has disabled the balance alert, the popup shows a red Balance Alert Disabled line and provides a Settings link that jumps directly to the platform’s usage page.

Data Sources

  • Balance: Retrieved via GET https://api.deepseek.com/user/balance using the DEEPSEEK_API_KEY credential.
  • Today’s spending: Retrieved from the platform usage API GET /api/v0/usage/by_api_key/cost, with parameters for the current day’s start and end times in Beijing time (start/end, tz=28800), using the logged-in platform session token. If the API call fails, it falls back to the observed balance decrease or a local token-based estimate.
  • Balance alert threshold: Read from /auth-api/v0/users/current to retrieve the platform-configured “Balance Alert” threshold.

Peak/Off-Peak Pricing and Holidays

Peak/off-peak periods (Beijing Time):
- Peak: Monday to Friday 09:00–12:00 and 14:00–18:00, excluding statutory holidays, billed at standard rates.
- Off-Peak: All other times (weekends, holidays, make-up workdays), billed at half price.

Holiday data is not bundled with the plugin. On the first daily read of the Beijing date, the plugin fetches the current year’s holiday calendar from NateScarlet/holiday-cn and caches it in memory. If the fetch fails, it retains the previous cache and retries after 15 minutes; near year-end, it pre-loads the next year’s holiday data in advance.

Installation and Activation

The plugin directory is a plain-text structure with no build step required.

Install directly from GitHub:

dsh plugin --profile desktop add github:NAME7220/dsh-visualcost

Or clone and add the local directory:

git clone https://github.com/NAME7220/dsh-visualcost.git
dsh plugin --profile desktop add <path-to-this-directory>

Or use the plugin manager’s install_bundle command within DSH by specifying the absolute path to the directory.

After installation, refresh the window. If the conversation module has been cached, it is recommended to restart the desktop application.

Typical Usage

After enabling the plugin in DSH desktop, a capsule button appears in the composer status bar showing the current balance and period label. Hover the mouse over it to see the time until the next switch; click the capsule to view today’s spending and per-model breakdown. If the platform has disabled the balance alert, clicking the capsule allows you to jump to the platform usage page via the “Settings” link in the popup to configure it.

Applicable Scenarios and Notes

  • Suited for developers using DeepSeek Harness 0.2.2-rc.5 on Windows desktop who need to continuously monitor balance and spending while keeping track of peak/off-peak pricing periods.
  • The plugin runs with DSH process permissions and has access to local files and processes. The DEEPSEEK_API_KEY and platform session token are used exclusively to call DeepSeek’s official APIs. Review the source code and license (MIT) before installation.
  • The platform usage API is a private endpoint and may change across versions. The plugin is currently developed and verified against DeepSeek Harness 0.2.2-rc.5 (Windows desktop).

Conclusion

dsh-visualcost integrates balance, spending, and peak/off-peak period information into DSH’s status bar, reducing the need to switch to a web page for checks. For more details and source code, refer to the directory page and the GitHub repository.

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

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

Xiaoye