Introduction¶
When conducting conversation experiments or debugging with DeepSeek Harness, controlling API costs is a common requirement. Although Harness itself tracks token usage and latency, it lacks an intuitive cost display, making it difficult to estimate the expenditure of a single turn or an entire session in real-time. The dsh-cost plugin provides visual cost estimation for web sessions by reading Harness’s token projection data.
Features¶
The plugin provides the following core capabilities:
- Current Turn Cost & Cumulative Session Cost: Displays the cost of the current turn after the response is complete and accumulates the total cost of the entire session.
- Detail Panel: Clicking the cost tag expands a detailed calculation breakdown, including the model used, pricing time period (peak/off-peak), and usage and unit price details for each token bucket.
- Cache Hit Rate: Displays the proportion of the prompt that was cache hits.
- DeepSeek Time-of-Use Pricing: Supports DeepSeek’s peak/off-peak pricing logic, automatically recognizing weekends and holidays.
- Read-Only Mode: The plugin only reads Harness’s token projections; it does not send requests, modify sessions, or touch the model API.
- Extensible Price List: Based on a data-driven price list registration mechanism, it easily extends support for billing from other providers.
Installation¶
Before installation, ensure your environment meets the requirements: DeepSeek Harness version must be 0.1.7-rc.1 or higher, and Node.js version must be 18 or higher.
Run the following command to install:
dsh plugin --profile web add @jackguo0310/dsh-cost
After installation, if dsh web is currently running, you need to restart the process once and refresh the page for the changes to take effect.
Usage¶
After installation is complete, start a web session:
dsh web
Below the conversation reply, the cost capsule will appear beneath the native DSH token and time capsules. The format is typically: Current ¥x · Total ¥y · Cache z%.
Click the cost capsule to view specific pricing details.
Notes¶
- Estimates: The values displayed by the plugin are estimates, not official bills. DeepSeek’s official billing shall prevail. Minor discrepancies may exist in calculations regarding cache hit rates, pricing window boundaries, and statutory holidays.
- Pricing Window Logic: The pricing window is determined by the completion time of the turn. If a conversation turn spans the boundary between peak/off-peak periods, the pricing for that turn will be attributed entirely to one side (based on completion time).
- Cross-Model Switching: If the model is switched during a conversation turn (e.g., due to a retry), the pricing for that turn cannot be split by model. It will be uniformly calculated based on the price of the first model and marked as an estimate.
- Session Total Range: The accumulated session cost only covers the loaded turns; unloaded historical turns are not included in the total.
- Environment Dependency: The plugin relies on specific client interfaces of DeepSeek Harness. If interface changes occur due to Harness version updates, the plugin may not function correctly.
Conclusion¶
dsh-cost solves the cost tracking pain point for DeepSeek Harness users in a lightweight manner. It not only displays current consumption but also provides detailed calculation logic, allowing developers to optimize prompts based on cache hit rates and time-of-use pricing. To modify the price list or add support for other providers, please refer to the configuration in the source code.
Project URL: https://github.com/JackGuo0310/dsh-cost