Introduction

DSH has already recorded the actual token usage for each step, but it does not inherently convert that usage into USD costs. For people running agent tasks daily, just looking at the token count is not enough: one also needs to know how much a particular assistant response round cost, the accumulated cost of a session, and how to update the price list after it expires.

dsh-llm-cost is a DeepSeek Harness (DSH) plugin designed to fill this gap: it generates a costUsage session projection on the host side, renders the cost of each turn below the message on the Web client, and displays the total session cost in the session header. It also provides the llm_cost_refresh tool to automatically extract current prices via LLM and web search, writing them into an override price file.

What is this

dsh-llm-cost is a DSH plugin by repository owner chenyinrusi under the MIT license.

The problems it solves can be summarized in three points:

  1. Convert existing DSH token usage into USD costs.
  2. Display the cost of each turn, each step, and the entire session in the Web UI.
  3. Use LLM and web search to generate an override price file when built-in price snapshots might be outdated.

This plugin requires DSH version >= 0.1.1-rc.2 and the package.json engines field to require node >= 20.

Core Features

Cost Projection: costUsage

The plugin writes cost results into the costUsage session projection, including the following fields:

totalCostUsd
pricedSteps
unpricedSteps
token buckets
byModel aggregation
steps[] step details

Where:

  • totalCostUsd represents the accumulated USD cost.
  • pricedSteps and unpricedSteps are used to distinguish between priced and unpriced steps.
  • byModel aggregates costs by model.
  • steps[] saves the details for each step, facilitating troubleshooting to understand why a particular round costs a certain amount.

Per-Turn Cost Display

On the Web client, the plugin renders the cost of the turn in the stats row below each completed assistant message, for example:

$0.0042 · 1.2K tok

If a model does not match a price, the plugin displays:

unknown

Unpriced models will not be displayed as $0.00 to avoid misinterpreting “unknown” as “free”.

Session Accumulated Cost

The plugin also displays the accumulated cost of the entire session in the top-right corner of the session header, and indicates:

+ N unknown

Price Auto-Maintenance: llm_cost_refresh

llm_cost_refresh is a tool for maintaining the price list. Its target pipeline is:

  1. Search for the current price of the target model via web search.
  2. Extract JSON price data using an available LLM route.
  3. Validate and write to pricingFile override file.

This tool does not overwrite the built-in snapshot; instead, it writes to an override file. Therefore, it is recommended to manually spot-check the extracted results before deciding to adopt them long-term.

Installation and Enablement

If installing via GitHub, use the following command:

dsh plugin --profile web add github:chenyinrusi/dsh-llm-cost#v0.6.1

If using a local tarball, for example in an intranet or offline environment, you can use:

dsh plugin --profile web add ./dsh-llm-cost-0.6.1.tgz

Plugin requirements:

DSH >= 0.1.1-rc.2
Node >= 20

The npm channel is not yet published. If you wish to install using the package name, you need to publish the npm package to the repository first:

npm login && npm publish

After installation, you can start a local Web verification with the following command:

pnpm dsh web --patch ./cordis.patch.yml

Typical Usage

1. Install Plugin

First, choose the GitHub or local tarball channel to install:

dsh plugin --profile web add github:chenyinrusi/dsh-llm-cost#v0.6.1

Or:

dsh plugin --profile web add ./dsh-llm-cost-0.6.1.tgz

2. Start Web Session

Enter a session via DSH Web, send messages, and wait for the assistant’s response.

After the reply is complete, you can view the cost row for that turn below the message. The accumulated cost of the entire session will be displayed in the top-right corner of the session header.

3. View Cost Details

The costUsage projection retains:

totalCostUsd
pricedSteps
unpricedSteps
byModel
steps[]

If a step shows unknown, it means that model did not match a built-in or override price.

4. Configure Price Refresh

The config in the plugin line in cordis.patch.yml can set the following keys, all optional:

pricing
pricingFile
refreshProvider
refreshModel

The meaning of each key is as follows:

  • pricing: Inline pricing overrides, merged on top of the built-in snapshot.
  • pricingFile: Path to the override file written by llm_cost_refresh.
  • refreshProvider: Provider route prioritized for price extraction calls.
  • refreshModel: Model ID prioritized for price extraction calls.

Configuration is validated by the zod Config schema. Omitting the config key means using all default values; config: {} is valid; do not write an empty config: key, as YAML will parse it as null and configuration validation will reject it; unknown keys will be silently discarded.

Price Refresh Rules

llm_cost_refresh can automatically execute the entire price update pipeline without requiring the agent to orchestrate steps.

The general process is:

  1. Use the installed web search provider in DSH to search for the current price of the target model.
  2. Use available LLM routes to extract JSON price data.
  3. Perform loose validation on the extracted results.
  4. Merge valid results into the price registry and write to pricingFile override file.

Automatic price maintenance requires two prerequisites:

A web search provider is installed in DSH, such as dsh-web-search-*
At least one available LLM route

If refreshProvider and refreshModel are configured, the tool will prioritize this provider/model pair. If not configured, the tool can also automatically select the cheapest available model.

Note:

  • The tool writes to an override file and does not overwrite the built-in snapshot.
  • It is recommended to manually spot-check the extraction results.
  • Invalid models or invalid prices will be discarded to avoid polluting the price list.

Peak and Valley Pricing

dsh-llm-cost supports peak and valley pricing.

The peak time windows are:

01:00–04:00 UTC
06:00–10:00 UTC

These two windows apply only to weekdays. Starting from 2026-08-23, UTC Saturdays and Sundays will be treated as off-peak all day.

For models that declare offPeakFactor, the off-peak cost will be multiplied by this discount factor; models that do not declare offPeakFactor will always be calculated at the peak price.

Price Matching Stages

The plugin matches prices according to the following stages:

0. provider === "ollama" → Free
1. Exact model ID match
2. Longest key substring match
3. Unknown → unknown

When a price is matched, the cost is calculated based on the corresponding unit price; when no price is matched, unknown is displayed instead of $0.00.

Development and Maintenance

In the plugin repository, common commands are:

npm test

Runs pure logic tests using node --test.

npm run gen

Regenerate price snapshots:

pricing.json
src/pricing-data.ts
npm run build

Packages the host, client, and declaration files using tsdown.

Use Cases and Notes

Scenarios suitable for using dsh-llm-cost include:

  • Using the DSH Web profile and wanting to see the USD cost for each turn.
  • Need to view the accumulated cost of a session.
  • Using multiple models and wanting to aggregate costs by model.
  • Need to maintain a price list without manually changing the configuration every time.

Notes before installation:

  • The plugin runs with the current dsh process permissions; check the source code, dependencies, and license before installing.
  • License is MIT.
  • The npm channel is not yet published.
  • Requires DSH version >= 0.1.1-rc.2.
  • Requires Node version >= 20.
  • Automatic price refresh requires a web search provider installed in DSH and at least one available LLM route.
  • unknown indicates that no price was matched, not that it is free.
  • llm_cost_refresh writes to an override file and does not overwrite the built-in snapshot.

Conclusion

The value of dsh-llm-cost lies in converting existing DSH token usage into directly viewable USD costs, while retaining detailed cost information for each turn and step. It also provides a price refresh tool to generate override files via LLM and web search once the built-in price list expires.

GitHub Repository:

https://github.com/chenyinrusi/dsh-llm-cost

The DSH Community Directory is an independent site and has no official affiliation with DeepSeek / Hypothesis; this material does not provide a specific directory page URL, but you can view the full README and release versions via the GitHub repository.