Introduction

DeepSeek Harness (DSH)’s plugin-based design allows developers to extend functionality on demand. When running agents locally or developing long sessions, tracking the cost of a single session and the official account balance is a common need. dsh-elegent-balance-tracker aims to solve this issue, displaying these two core metrics in real time below the input field statistics line and in the sidebar settings area.

Plugin Overview

Name: dsh-elegent-balance-tracker
Positioning: DeepSeek Harness billing plugin: current session cost + official account balance
Author: X-avier-W
License: MIT
Core Value: Provides local cost and balance tracking consistent with official pricing/API definitions.

Core Features

  1. Display current session cost: Displays cost below the input field statistics line. Based on when the message occurred (Beijing Time), selects official peak or off-peak pricing for calculation, including non-cached input, cache hits, and output tokens. It refreshes once the model finishes replying.
  2. Display official account balance: Displays balance at the bottom of the sidebar. Fetches accurate balance on startup, then automatically aligns with the official API every minute. Between alignments, generates an estimated balance by deducting real-time new costs from all local sessions.
  3. Calculate using peak/off-peak prices: Supports automatic switching of pricing tiers based on time.
  4. Automatic official price synchronization: Enabled by default; supports automatically fetching the official pricing page and detecting new models and changes to peak/off-peak rules.
  5. Purely local execution: Balance queries only request the official API (the API key does not leave the server); session logs are parsed locally only and are not reported to any external service.
  6. Independent statistics for subagents: Subagents are independent sessions and are tracked separately.

Installation and Activation

Install the plugin through the npm channel. After installation, you must restart dsh web for it to take effect.

dsh plugin --profile web add dsh-elegent-balance-tracker

After installation, refresh the browser page to see the cost and balance display.

Configuration

All configurations are optional and can be overridden in the cordis.patch.yml of the web profile (path $DSH_HOME/profiles/web/cordis.patch.yml).

Configuration items:
- apiKeyRef: credential reference for balance queries; defaults to using DEEPSEEK_API_KEY.
- priceSync: controls the switch and parameters for automatic official pricing synchronization.
- priceSchedule: custom peak/off-peak price table; takes precedence over officially synced prices.
- prices: manually overrides unit prices for specific models; takes precedence over officially synced prices.

Configuration example:

- patch:
    - id: dsh-elegent-balance-tracker
      config:
        apiKeyRef: DEEPSEEK_API_KEY
        priceSync:
          enabled: true
          url: "https://api-docs.deepseek.com/zh-cn/quick_start/pricing/"
          intervalMs: 43200000
        priceSchedule:
          - from: "2026-08-17"
            peak:
              deepseek-v4-flash: { input: 3, cacheRead: 0.1, output: 9 }
            idle:
              deepseek-v4-flash: { input: 1.5, cacheRead: 0.05, output: 4.5 }

Notes

  1. Accumulated data is not displayed: The official API does not provide cumulative top-up or cumulative consumption data, so the plugin does not display this information; it only displays the current balance composition.
  2. Purely local execution: Data is stored locally only and is not reported to external services.
  3. Subagent tracking: Subagents are independent sessions and their costs are tracked separately.
  4. Retries are counted in cost: Failed retries in session logs are included in cost calculations.
  5. Price precedence: Explicit user configuration > official automatic synchronization > built-in default prices.

Summary

This plugin provides transparent cost and balance management for DSH by locally parsing logs and periodically syncing with the official API. It is suitable for developers who need fine-grained control over DeepSeek invocation costs. You can view the plugin source code and directory at GitHub.