Introduction¶
When running long conversations in DeepSeek Harness (DSH), token usage appears in the interface, but calculating “how much this session cost in total” or “how much this turn costs according to the official price list” often requires manual checking or waiting for billing statements. DeepSeek also has different unit prices for input hits/misses, output, and peak/off-peak hours, and holiday rules need to be remembered separately. The following introduces the community plugin dsh-deepseek-turn-cost (npm package name dsh-simple-cost, version 0.1.0, MIT), maintained by lhylhy2024. It is categorized as a client-side widget: having no additional dependencies besides DSH itself, it embeds account balance, peak/off-peak time slots, cumulative session costs, and per-turn costs directly into the interface, and provides button-triggered AI analysis for single turns exceeding a threshold.
What is this¶
In one sentence: A account balance + session/per-turn billing widget for DSH, estimating costs based on DeepSeek’s official price list, and identifying Beijing Time peak/off-peak hours and Chinese statutory holidays.
Maintainer: lhylhy2024; Source repository: https://github.com/lhylhy2024/dsh-deepseek-turn-cost (0 GitHub stars). The community directory entry https://www.skillhub.cn/plugins/lhylhy2024/dsh-deepseek-turn-cost is an independent ecosystem site and has no official affiliation with DeepSeek / High-Flyer. If the URL prompts that the plugin is not found, please refer to the GitHub README for installation and usage.
Three UI Locations¶
The plugin registers the UI through DSH slots to avoid duplicating the same numbers in the sidebar and the conversation.
| Location | Slot | Content |
|---|---|---|
| Right above the user bar at the bottom of the sidebar | sidebar.footer.action |
Account balance (¥ / $, including granted balance); Peak / Off-peak badge; minutes until the next switch |
| Info bar below the input area on the conversation page | conversation.composer.dock |
Cumulative cost for the current session, e.g., “Session ¥1.2345” |
| Action row for each assistant reply | conversation.chat.assistant-actions |
Estimated cost for the current turn after “Usage xxM tok”; AI Analysis (A button) appears when total tokens reach the threshold |
Cumulative tokens and turn counts are still displayed by DSH’s built-in ContextMeter; this plugin does not duplicate this.
Billing Logic and Built-in Prices¶
The built-in price version stamp is PRICE_VERSION = 2026-09-10 (README records the scrape date as 2026-10-13). Single turn cost is calculated as:
cost = hitInput/1e6 × P_hit + missInput/1e6 × P_miss + output/1e6 × P_out
Key points are as follows:
P_*is determined by the model and peak/off-peak status; off-peak price is 50% of the peak price (official parallel price lists, not a discount promotional text).- Peak: Beijing Time Monday to Friday (excluding statutory holidays) 09:00–12:00, 14:00–18:00; all other times are off-peak, including weekends and statutory holidays all day.
cacheWriteTokensare priced as missInput;reasoningTokensare counted towards output price.- CNY / USD each use a separate set of tables, selected by the balance interface
currency, without exchange rate conversion. - Time slots are determined by the start time of the turn.
Built-in unit prices (CNY / million tokens):
| Model | Hit·Off-peak | Hit·Peak | Miss·Off-peak | Miss·Peak | Output·Off-peak | Output·Peak |
|---|---|---|---|---|---|---|
| deepseek-flash | 0.02 | 0.04 | 1 | 2 | 4 | 8 |
| deepseek-v4-pro | 0.15 | 0.30 | 4.5 | 9.0 | 13.5 | 27.0 |
When official prices are adjusted, the maintainer needs to modify PRICES / HOLIDAYS at the top of index.js and update PRICE_VERSION; the interface does not actively remind of price changes.
Why the logic is on the Host side¶
The browser side cannot access complete per-turn tokens (they are in the Host session log snapshotEvents()), and account credentials can only be obtained via the Host’s ctx.deepseekAccount; AI analysis requires ctx.llm.stream, and the client Remote’s llm namespace does not have generation interfaces. Third-party plugins also cannot register Remote namespaces themselves.
Therefore, client.js accesses the loopback routes registered by index.js via same-origin fetch (only 127.0.0.1 / ::1):
GET /dsh-simple-cost/state?sessionId=
POST /dsh-simple-cost/analyze
The conversation component slot comes with a sessionId, not relying on the session id in the URL.
Installation and Activation¶
This plugin is not published on npm. The README provides two methods:
① Install from repository directory — After cloning locally, point DSH’s plugin_manager to the absolute path:
git clone https://github.com/lhylhy2024/dsh-simple-cost.git
plugin_manager { action: "install_bundle", target: "<Absolute path of the clone>" }
② Plugin Market — After submitting to the awesome-dsh-plugin list, it can be installed with one click via DSH’s built-in dshmarket.
After installation, refresh the page to see the three UI locations. Modifying client.js takes effect upon refresh; modifying index.js requires restarting the DSH process.
Typical Usage¶
- After logging into a DeepSeek account and ensuring DSH can access Host capabilities, open any conversation; view the balance and current peak/off-peak status along with the switch countdown at the top of the sidebar.
- View the cumulative estimate “Session ¥x.xxxx” in the info bar below the input box.
- View “· This turn approx ¥x.xxxx” in the assistant action row for each turn; when the total tokens for that turn are not lower than the threshold configured in the plugin, click A to trigger AI analysis (this consumes additional model tokens; the analysis side
maxTokensis set to 6000 to prevent thinking from consuming the entire budget). - If connecting to a non-default API base URL is required, the Host side can override the default
https://api.deepseek.comvia the environment variableDEEPSEEK_BASE_URL.
Use Cases and Notes¶
Suitable for: Developers who run long conversations in DSH daily, wish to perform local estimations based on official peak/off-peak and price lists, and quickly identify “which turn was particularly expensive.”
Must be aware:
- The plugin runs with the current DSH process permissions and requests the DeepSeek account balance interface (may fall back to the DSH platform wallet upon failure, with no split for granted balance). Please read the source code and MIT license before installation.
- There may be tiny differences due to per-turn rounding between estimates and real bills; the statutory holiday table is built-in up to 2026, crossing years requires updating
HOLIDAYS; the README explains that makeup work on weekends (调休) is still priced as off-peak. - Balance priority is
GET https://api.deepseek.com/user/balance; this is the only external network target (can be affected byDEEPSEEK_BASE_URL).
Conclusion¶
dsh-deepseek-turn-cost integrates balance, peak/off-peak reminders, session accumulation, and per-turn costs into native DSH slots. The Host loopback route supplements the billing data that the browser cannot access; zero dependencies besides DSH. Directory page: https://www.skillhub.cn/plugins/lhylhy2024/dsh-deepseek-turn-cost; Source code and full documentation: https://github.com/lhylhy2024/dsh-deepseek-turn-cost.