Preface

When running sessions with DSH, checking how much a conversation costs and how much balance remains usually requires opening a separate page to view the bill. DeepSeek has implemented peak-valley billing starting from 2026-08-17; different models have different unit prices at different times, making manual cost verification more cumbersome.

The community already has dsh-cost-balance that does something similar, but the original version suffers from slot ID conflicts, incorrect ctx passing, and other issues. The statistics bar might never render, and in some cases, it can even crash the entire frontend. dsh-cost-balance-pro fixes these issues on top of the original. Below is an introduction to its positioning, features, installation method, and what has been changed relative to the original version.

What is this

dsh-cost-balance-pro is a DSH plugin by kingcharleslzy-ai, licensed under MIT, and targets the web platform platform. One-sentence positioning: A session cost/balance statistics bar visible as text below the input box, featuring a settings page and one-click restore.

Core Features

The collapsed state directly displays Balance (¥) · Cost ($). Click to expand the detail panel, which shows cache hit / Token / Cost / Balance.

Peak-Valley Pricing

DeepSeek has implemented peak-valley billing starting from 2026-08-17. Starting from 2026-08-23, peak hours are limited to Monday to Friday, with off-peak prices all day on weekends. Peak hours are UTC 01:00-04:00 and 06:00-10:00 (Beijing 09:00-12:00 / 14:00-18:00), and the off-peak price is half the peak price.

The plugin calculates prices automatically based on the current time:

  • The collapsed state displays Peak/Off-peak badges; Peak is orange, Off-peak is green.
  • The expanded panel displays a description of the current time slot.

Price Auto-Sync (v0.2.0+)

  1. Fetches the official English pricing page on startup and every 12 hours.
  2. Automatically detects new models and price changes (e.g., deepseek-v4-flash-vision-exp), allowing you to follow official prices without upgrading the plugin.
  3. Falls back to the last cached data on fetch failure, then to built-in default prices.

Price priority: User explicit configuration > Official sync > Built-in default price. Sync results are cached in $DSH_HOME/dsh-cost-balance-pro-prices.json.

Built-in default prices serve as a fallback covering the peak-valley prices (USD/1M) for V4-Flash / V4-Flash-Vision / V4-Pro:

Model Slot Cache Hit Cache Miss Output
V4-Flash Peak 0.014 0.44 1.32
V4-Flash Off-Peak 0.007 0.22 0.66
V4-Flash-Vision Peak 0.014 0.44 1.32
V4-Flash-Vision Off-Peak 0.007 0.22 0.66
V4-Pro Peak 0.044 1.32 3.96
V4-Pro Off-Peak 0.022 0.66 1.98

Settings Page

The entry point is Settings -> Plugins -> Balance Stats Bar. You can adjust:

  • Display toggles: Balance, Cost, Hit Rate
  • Font size: 10–16px
  • Color: Follow theme / Gray / Custom color picker
  • One-click restore

Complete fields and default values are as follows:

Field Type Default Description
showBalance boolean true Display balance in collapsed state
showCost boolean true Display cost in collapsed state
showHitRate boolean true Display cache hit rate in expanded panel
costCurrency enum cny Cost currency: cny RMB / usd USD
balanceCurrency enum cny Balance currency: cny RMB / usd USD
usdCnyRate number 6.82 USD→CNY exchange rate (for balance/cost conversion, implied official peak-valley price)
fontSize number 12 Font size in collapsed state, limited to 10–16
colorMode enum auto auto follow theme / mono gray / custom custom
customColor string #8b5cf6 Text color when colorMode=custom (#RRGGBB)

Configuration is persisted in $DSH_HOME/dsh-cost-balance-pro.json, retained after restart, and the stats bar refreshes instantly after saving.

Installation and Enablement

  1. Run the installation command:
dsh plugin --profile web add dsh-cost-balance-pro
  1. Restart the service once after installation (or at the next login).

  2. Refresh the page to see the statistics bar below the input box; adjust styles via the settings page.

Overriding Prices

If you don’t want to rely on official sync, you can override the entire line of config in the profile’s cordis.patch.yml by plugin ID, passing a prices field with the following structure:

{ Model: { peak: { hit, miss, out }, offPeak: { hit, miss, out } } }

User configuration always takes precedence over official sync results.

Fixes Relative to dsh-cost-balance

The original version’s issues all occurred in the client loading chain, which is a common reason for “installed but not visible”:

  1. Slot registration ID changed to unique cost-balance-pro, no longer conflicting with the official statistics bar—the original version with the same slot, ID, and priority would crash the entire frontend.
  2. ctx is passed to the component via props—the original version had a module-level naked ctx causing a ReferenceError during slot entry rendering, so the pill/bar was never rendered successfully.
  3. The collapsed state changed from a 5px invisible thin line to visible text.
  4. The client factory added return module.exports—without it, the loader receives undefined, and the plugin silently fails.
  5. The client module declares exports.inject = ['timer']ctx.interval requires the timer injection.

Development and Release

Run client contract tests locally for validation:

npm test          # Client contract test (node:test)
npm pack --dry-run

Release process: push a v* tag to trigger GitHub Actions, which automatically publishes to npm via OIDC trusted publishing (with provenance).

Suitable Scenarios and Notes

Suitable for DSH users on the web platform who want to see session costs and balances in real-time and need to follow peak-valley pricing. If you only need the default style, you can use it immediately after installation; if you want to change font size, color, or currency, adjust it in the settings page.

Two notes:

  • The plugin runs with the current DSH process permissions; you should check the source code and license before installing.
  • Price sync relies on the official English pricing page; if fetching fails, it will fall back to cache and built-in default prices, so prices may have a time difference from the official website.

Summary

dsh-cost-balance-pro places session costs and balances below the input box. Peak-valley pricing and price sync are handled automatically. It fixes several practical issues in the frontend loading of the original version and is suitable for DSH users who want “install and see” cost visibility.

  • Plugin Directory Page (independent site maintained by the community, no official affiliation with DeepSeek or Huanfang): https://www.skillhub.cn/plugins/kingcharleslzy-ai/dsh-cost-balance-pro
  • GitHub Repository: https://github.com/kingcharleslzy-ai/dsh-cost-balance-pro