dsh-cost-track: Accounting and Budget Control for DSH Model Calls

Introduction

When running agents in DeepSeek Harness (DSH), model calls happen continuously: prompt tokens, completion tokens, and model IDs are scattered across logs, making it hard to answer questions like “How much did I spend today?” or “Will I exceed the budget this month?” Writing your own scripts to aggregate costs is both time-consuming and prone to falling out of sync with DSH’s invocation paths.

Below is a community plugin dsh-cost-track (maintainer hj01857655). After each model call, it calculates costs based on a price list, writes them to an append-only local ledger, and supports monthly budget alerts with optional call interception. A spending panel is also available in the settings page. The DSH ecosystem emphasizes “everything is a plugin”; community directories like SkillHub are independent sites with no official affiliation with DeepSeek/High-Flyer. Always refer to the package’s documentation and source code before installation.

What Is This

dsh-cost-track is a usage and budget tracking plugin for DSH: it records the prompt/completion tokens and model ID for every model call, converts them into monetary amounts and persists them to disk, making it easy to trace spending by day, month, or session.

The maintainer is hj01857655, and the npm package is licensed under MIT. The community directory page is at https://www.skillhub.cn/plugins/hj01857655/dsh-cost-track. As of the visit on 2026-10-21, the GitHub repository linked in the directory entry at https://github.com/hj01857655/dsh-cost-track returned 404, and the pre-fetched README was unavailable. The features and commands described below are based on the README published with the npm package dsh-cost-track (see registry.npmjs.org/dsh-cost-track).

Core Features

Based on the npm README, the plugin currently provides the following capabilities:

  1. Call Accounting: For each model call, the prompt tokens, completion tokens, and model ID are priced and appended to .cost/ledger.jsonl (append-only).
  2. Built-in Pricing: Comes with a built-in DeepSeek model rate table; custom models can override unit prices (per million tokens) via .cost/pricing.json.
  3. Budget: A monthly spending cap can be set; when cumulative spending exceeds the threshold, an alert is triggered; when enforce: true is configured, subsequent model calls will be blocked.
  4. Time Range Queries: Supports filtering spending by today, this week, this month, or an arbitrary date range.
  5. Session-based Aggregation: View which conversation consumed the most tokens.
  6. Cost Panel in the Settings Page: Displays today’s/this month’s spending, per-model breakdowns, recent sessions, and a budget progress bar. The host registers GET /api/cost-track.panel and rebuilds data from the ledger on each request. Headless hosts without a Web connection will skip this route.
  7. CLI: Can perform aggregation, set budgets, or manually append a record without depending on the DSH process (see examples below).

Installation and Activation

The plugin targets the web profile (dsh.client.platform is web in the README). First, install it via npm distribution:

dsh plugin --profile web add dsh-cost-track

The README also describes installing from the GitHub source (matching the repository slug from the directory clue):

dsh plugin --profile web add github:hj01857655/dsh-cost-track

If the above GitHub address is unavailable, use dsh plugin --profile web add dsh-cost-track. After installation, you can confirm the plugin is loaded in DSH settings; Node >= 20 is required (per the npm package’s engines field).

Typical Usage

Automatic Accounting

Once the plugin is enabled, model calls from the DSH side are recorded by the plugin side, so manual operations for each call are generally unnecessary.

CLI

Examples from the README:

dsh-cost-track summary                          # show spend summary
dsh-cost-track budget --monthly 50 --enforce    # set $50/month budget with enforcement
dsh-cost-track record --model deepseek-chat --prompt-tokens 1000 --completion-tokens 500 --session s1

budget is used to set the monthly cap and whether to enforce blocking; record is suitable for script-based supplemental logging or aligning with external statistics.

Default Pricing and Overrides

Default rates (per million tokens, USD):

Model Prompt Completion
deepseek-chat $0.14 $0.28
deepseek-reasoner $0.55 $2.19

For non-DeepSeek models or custom unit prices, write .cost/pricing.json in your project:

{
  "my-model": { "promptPerMillion": 1.0, "completionPerMillion": 2.0 }
}

After saving, the panel and ledger will use the new rates for calculations.

Panel

Open the Cost page in DSH Settings to view today’s/this month’s spending and budget progress, per-model tokens and costs, recent sessions sorted by cost, as well as budget status (OK / warning / exceeded) and the enforcement toggle.

Use Cases and Caveats

Who it’s for: Teams and individuals who debug agents in DSH long-term, need to convert token spending into monetary amounts, or want to cap monthly API expenses.

Usage notes:

  1. The plugin reads and writes local files such as .cost/ledger.jsonl with the current dsh process permissions; before installation, you should read the source code and MIT license inside the npm package and assess whether it meets your security and compliance requirements.
  2. Budget enforcement must be explicitly enabled (e.g., via --enforce in the CLI or enforce: true in the config); by default it primarily alerts.
  3. Directory pages and GitHub clue repositories may lag behind npm releases; feature changes are subject to the README inside the package.
  4. Community directory metadata such as stars is subject to the site’s display (the GitHub star count in the clue was 0) and does not imply a quality endorsement.

Conclusion

dsh-cost-track turns the token consumption of each model call in DSH into an auditable ledger and provides aggregation and budgeting capabilities via the settings page and CLI, making it suitable for DSH developers who need to keep call costs “visible and controllable.”

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

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

Xiaoye