When using DeepSeek Harness (DSH) for agent development, tracking the cost of each model call, managing balances across different vendors, and distinguishing peak-hour and off-peak billing often requires additional tools or manual calculation. This can easily lead to budget overruns or inconsistent billing criteria.

dsh-token-feiyong is a token billing and cost statistics plugin for DeepSeek Harness. It is maintained by singei8 and aims to intercept and record every model call, price it by cache hit, cache miss, and output, and provide local persistent ledger functionality.

Core Features

  1. Per-call billing: intercepts model calls and prices them separately as cache hit, cache miss, and output.
  2. Peak/off-peak time-based pricing: peak hours are Beijing Time Monday to Friday 9:00–12:00 and 14:00–18:00; all other times are off-peak.
  3. Multi-tier unit-price matching: prices are matched in the order user configuration -> model name -> built-in official table -> default.
  4. Input box badge display: real-time display of peak/off-peak status, single-call cost, cumulative cost for this conversation, today’s total, and balance/quota.
  5. Settings-page cost statistics: provides account, single-call, today, cumulative, by model, recent requests, and other statistics views.
  6. Provider-specific balance/quota: supports balance lookup and quota metering for vendors such as DeepSeek, Zhipu, and Volcano Engine Ark.
  7. Package quota metering (AFP): prepaid packages such as Volcano Engine Ark Agent Plan calculate consumption using the official AFP deduction coefficient.
  8. Local data persistence: detailed records and cumulative data are read back as a merged result; cumulative totals do not roll back; the ledger path is <DSH_HOME>/token-billing-ledger..
  9. Sub-session consolidation: costs from side conversations and subagents are merged by default into the parent main conversation’s “this conversation” and “single call” totals.
  10. Master switch: provides a plugin master switch that can independently control the enabled state and balance display.

Installation and Enablement

dsh plugin --profile web add github:singei8/DSH-TOKEN-feiyong

After installation, restart DSH to activate the plugin. The plugin is provided as an npm package with a dsh.bundle manifest. The repository already includes a prebuilt lib/ directory, so no local build is required.

Typical Usage

  1. View real-time costs: Cost information is persistently displayed below the input box, for example ● Peak · Single call ¥0.012 · This conversation ¥1.410 · Today ¥1.410 · Balance ¥32.31. This lets you see at a glance how much a given model call costs.
  2. Manage balances and packages: Check account balances in Settings → Cost statistics. For prepaid plans such as Volcano Engine Ark Agent Plan, the system calculates consumption using the AFP deduction coefficient and displays the remaining 5-hour/weekly/monthly quotas.
  3. Consolidated session statistics: Costs from side conversations and subagents are merged into the parent main conversation’s “this conversation” and “single call” totals by default, making it easier to manage the overall workflow cost.

Applicable Scenarios and Notes

  • Dependency notes: The plugin treats host capabilities as optional dependencies. If the host lacks any of webServer, llm, credentials, shell, fs, or settings, the corresponding features degrade gracefully instead of causing the plugin to crash.
  • Security and privacy: The API Key is only resolved on the host side via the env → credentials service. It is not placed in command-line arguments, not written to logs, and not forwarded to the frontend. The plugin sends no telemetry and makes no network requests except for balance lookups.
  • Data storage: The ledger file path is <DSH_HOME>/token-billing-ledger.. Known boundary: side conversations and subagents are merged into statistics by default, but they are still recorded separately at the lower level and are not double-counted.

Summary

dsh-token-feiyong solves cost tracking in the DSH environment through a local persistent ledger and real-time badge display. It supports mainstream models such as DeepSeek and Zhipu GLM, and also handles AFP metering for prepaid packages. See its GitHub repository for more details.