Introduction

The DeepSeek Harness (DSH) ecosystem emphasizes plugin architecture and flexibility. Whether developing agents or using them day to day, accurately tracking token consumption, cache hit rate, and the associated cost for each conversation turn is essential for controlling costs. The dsh-cost plugin, maintained by zydg, is designed to address this need. It subscribes to the DSH conversation event stream, automatically appends a statistics line at the end of the chat log after each round, and provides balance querying and data export.

Core Capabilities

  • Automatic statistics line: Subscribes to the uiConversation event and automatically appends a statistics line after each assistant response, including the current round’s token usage (input / cache hits / output), cache hit rate, cost estimate, and DeepSeek API balance.
  • Peak/off-peak pricing: Based on the official DeepSeek V4.1 Flash / V4 Pro price list, it automatically determines peak/off-peak periods according to the actual time of each call and calculates the cost accordingly.
  • Balance display: Queries the balance via GET https://api.deepseek.com/user/balance, displaying it at the end of the statistics line and above the input box.
  • Model and pricing management: Supports manually editing models, peak periods, and prices on the settings page, or modifying them through the API (setPrices, resetPrices).
  • Data persistence and export: Call records and balance snapshots are stored in the workspace file dsh-cost/data.json, and can be exported as CSV or JSON.

Installation and Activation

Install the plugin using the DSH package manager:

dsh plugin --profile web add github:zydg/dsh-cost

After installation, restart the web application and refresh the page to apply the changes. You can also directly enter the following command in the conversation to have the AI automatically run the installation and restart:

帮我安装一下这个dsh plugin --profile web add github:zydg/dsh-cost并重启

Usage and Notes

  • Cost and balance: The cost is an estimate; actual charges are based on the official DeepSeek bill. The DEEPSEEK_API_KEY must be configured to display the balance.
  • Data privacy: Records contain only token metadata (no message content or API key).
  • Conflict handling: If another plugin occupies the /dsh-cost/api route, remove the conflicting plugin first.
  • Scope of applicability: Availability with other models/service providers has not been verified. It is designed only for official DeepSeek models and the official pricing system.

Summary

dsh-cost provides visualized cost monitoring for DeepSeek Harness, suitable for developers who need fine-grained control of API call costs. The project is open source, and its repository can be accessed on GitHub: https://github.com/zydg/dsh-cost.