Introduction

If you are running sessions on the DeepSeek Harness (DSH) Web GUI, you likely encountered this issue: while the session stats row tells you how many tokens were used, it doesn’t tell you the cost in RMB or how much balance remains. To figure this out, you have to switch to platform.deepseek.com/usage to check the bill. However, the official bill itself has a settlement delay of a few minutes, making it inconvenient to estimate costs halfway through a long session.

DSH’s philosophy is “everything is a plugin,” and this kind of metric fits perfectly as a dock item. The ljcscp/dsh-session-cost introduced below does exactly that: displaying the DeepSeek account balance and the current session’s estimated spending directly within the Web GUI.

What is this

ljcscp/dsh-session-cost is a plugin for the DSH Web GUI, licensed under MIT, currently version 0.1.0. It displays a line of metrics below the session stats row in the composer dock:

This session ¥0.90 · Balance ¥30.82

Hovering reveals details: input/cached read/output token counts, the model used for the session, the pricing source, and the balance composition (granted + topped up).

Core Features

Account Balance: Queries the official GET /user/balance interface. The API key remains on the host side and is parsed via the DSH credentials seam on every refresh; it is never sent to the browser.

Session Spending: Token usage × Official DeepSeek price. Prices are automatically scraped from the official pricing page every 6 hours; no plugin update is needed for price changes.

Peak and Valley Pricing: Automatically applies peak and valley periods launched on 2026-08-17—Beijing Time 09:00–12:00 / 14:00–18:00 is peak hours, and valley hours are half price. The plugin applies the corresponding price tier based on the current Beijing Time hour.

Pricing by Model: Reads the actual model used for the session from the provenance of the latest assistant message (deepseek-v4-flash / deepseek-v4-pro) and bills according to their respective price tiers.

Billing Formula: Consistent with official rules (deducted fee = token consumption × unit price of model):

spend = uncachedInput × inputPerMillion
      + cacheRead × cacheReadPerMillion
      + output × outputPerMillion        (per 1M tokens)

Cached write is billed at the uncached input price because DeepSeek only reports hit/miss usage buckets.

Installation

There are two prerequisites:

  1. DeepSeek Harness 0.1.0-rc.5 or a later version (web profile);
  2. A DeepSeek API key stored via the DSH credentials seam (DEEPSEEK_API_KEY, written by the web Models page).

Installation supports three ways; choose any one.

From git URL (no npm account required):

dsh plugin --profile web add https://github.com/ljcscp/dsh-session-cost

From npm:

dsh plugin --profile web add @ljcscp/dsh-session-cost

From local checkout (for development):

git clone https://github.com/ljcscp/dsh-session-cost.git
dsh plugin --profile web add link:$(pwd)/dsh-session-cost

After installation, restart dsh web and refresh the page; the metrics will appear below the session stats row in the composer dock. It uses a default zero-configuration setup and works out of the box.

Optional Configuration

Default is zero configuration. If you need to adjust behavior, you can add a section to the composite config:

- insert:
    - id: session-cost
      name: '@ljcscp/dsh-session-cost'
      config:
        refreshMs: 60000
        pricingRefreshHours: 6
        apiKeyEnv: DEEPSEEK_API_KEY
        baseURL: https://api.deepseek.com

Meaning of each configuration item:

Configuration Item Type Default Description
refreshMs number 60000 Balance cache lifecycle (ms), retries after 10 seconds on failure
pricingRefreshHours number 6 Official pricing page refresh interval (hours)
apiKeyEnv string DEEPSEEK_API_KEY Credential reference storing the DeepSeek API key
baseURL string https://api.deepseek.com Interface base address, the plugin appends /user/balance after this
trustedHosts string[] [] Non-loopback hosts providing services outside the trusted fence

How it Works

The plugin is split into two parts:

Host side (src/index.ts) registers a trusted webserver route /session-cost, providing a balance snapshot (cached for refreshMs) and an effective pricing snapshot (parsing the official pricing page based on pricingRefreshHours and applying the current Beijing Time hour after peak/valley periods take effect). The API key never leaves the host.

Browser side (src/client/) is a conversation.composer.dock item that reads the tokenUsage projection, detects the session model from the provenance of the latest assistant message, applies the effective price tier, and renders the metrics, refreshing once per minute.

Use Cases and Considerations

Suitable for these types of users:

  • Those running long sessions on the DSH Web GUI who want to keep track of costs at any time;
  • Those using both deepseek-v4-flash and deepseek-v4-pro simultaneously and want to confirm which price tier is actually used for each session;
  • Those who want peak/valley pricing and official price adjustments to take effect automatically without manually maintaining price tables.

A few points to know before use:

  • The metrics are estimated values calculated based on official prices; official bills on platform.deepseek.com/usage have a settlement delay of a few minutes, so the numbers on both sides may not match temporarily.
  • trustedHosts (default []) is used to configure non-loopback hosts providing services outside the trusted fence; it does not need to be changed for default deployment.
  • The plugin runs with the permissions of the current dsh process; it is recommended to check the source code and license before installation. This project is MIT; the browser build presets (shared/) are adapted from dsh-balance-meter (BSD-3-Clause), which itself was adapted from deepseek-harness (MIT).
  • For local development or building from source: Node engine requires ^22.19.0 || >=24.0.0, and the package manager is pnpm@11.7.0.

After the steps above, the plugin can continuously provide balance and session spending metrics in the composer dock, eliminating the need to switch to external pages to check bills.

Conclusion

dsh-session-cost solves a small but specific problem: making cost information appear directly on the interface of your session, using the official interface for balance, automatically syncing prices with the official pricing page, and automatically applying peak/valley periods and model tiers.

Project addresses:

The community directory is an independent site and has no official affiliation with DeepSeek / Sycamore; it is used solely for indexing purposes.