Introduction¶
The DSH desktop client only shows a token usage capsule by default; to check the actual cost, you need to manually visit the DeepSeek website. In scenarios involving sub-agents, image generation, voice, and other features, billing becomes more complex. dsh-cost folds the cost from session logs, displays it below the input box, and includes the charges for sub-agents, image generation, and voice in the total.
Plugin Overview¶
dsh-cost is a standalone plugin for the DSH desktop client, maintained by fengnowuyu-beep. It was originally part of dsh-toolbox but has now been split out and can be independently enabled/disabled and upgraded.
The plugin is installed on the client side, displays the total cost (including all sub-agents) and a breakdown for the current conversation below the input box, and estimates the charges for image generation and voice.
Core Features¶
Current Conversation Cost¶
Displays the total cost of the current conversation below the input box. The amount is consistent with the token count shown in DSH’s built-in token capsule. The price is folded from session logs, and the replacement rules are identical to DSH’s own tokenUsage projection.
Cost Breakdown¶
Click the displayed total amount capsule to view the amount for each billing line. The breakdown includes:
- Input · Cache Miss
- Input · Cache Hit (Cache Read)
- Cache Write
- Output
Each line shows its respective amount and token count, along with the cache hit rate, peak sample, per-model amount, price source, and timestamp.
Image Generation Cost¶
Image generation costs are listed by model with the number of images and the amount, priced by delivered pixels. In the panel, this is shown with a light amber background + a left accent bar + an “Estimated” chip.
Pricing structure:
- 1K text-to-image ¥0.1430, 2K ¥0.1531, 4K ¥0.4522
- Image editing with 1 reference image ¥0.1744 (3 reference images ¥0.2346)
- 4K limited-time 50% discount (≥16.60 megapixels, before 2026-11-18 00:00)
Prices are calculated via linear interpolation; actual costs will vary with prompt token length.
Voice Cost¶
Voice costs are calculated based on the per-second unit price of paraformer-v2 multiplied by the voice duration. The panel also carries an “Estimated” label.
Pricing structure:
- ¥/second (0.00008, ≈¥0.288/hour)
- Only voice duration is counted; silence is not counted
Sub-agent Allocation¶
This plugin includes all costs generated by sub-agents spawned from the main conversation, tracking up to three levels of sub-agents. Each sub-agent gets a line in the panel, labeled with the task name it was delegated.
If the “Include sub-agent costs” toggle is turned off, only the current conversation is counted.
Price Sources¶
The plugin supports multiple price sources:
- Built-in official price list (available offline)
- Fetched from the DeepSeek official pricing page
- Custom JSON URL
The price cache is stored in ~/.dsh/cost/prices.json.
Settings Page¶
In the DSH Settings page → Cost Amount, you can configure:
- Toggle: Show cost amount
- Display position
- Include sub-agents
- Include image generation and voice
- Include workspace voice transcription
- Currency
- Exchange rate
- Pricing source
- Validity period
- Manual refresh
Cost Calculation Method¶
Consistent with Token Counting¶
The amount is folded from session logs. The replacement rules are identical to DSH’s own tokenUsage projection, so the amount always describes the same set of tokens shown in the token capsule.
Peak/Off-peak Pricing¶
Each sample is priced according to the time it occurred:
- Peak hours (UTC Mon–Fri 01:00–04:00, 06:00–10:00) are priced at peak rate
- All other times are priced at off-peak rate (half price)
Chinese statutory holidays cannot be automatically detected.
Cache Write Billing¶
Cache writes are billed at the “cache miss” price (the official price list does not have a separate cache write line item).
Model Identification¶
Model identification prioritizes the provider/model attached to the message, then falls back to the request/header / request/context at the time of the request. Retired aliases (deepseek-v4-flash, deepseek-chat, deepseek-reasoner) are mapped to deepseek-flash.
Multi-currency¶
The official price list publishes both RMB and USD prices. Switching currency triggers an immediate recalculation. If a model lacks a price in the selected currency, the exchange rate from settings is used for conversion.
Pricing for Archived Conversations¶
The old implementation only recognized live sessions in the current process. Now there are two paths:
- Session in the current process: uses the
sessionsservice + incremental folding - Session only in archive: read via
sessionPersistence.open(id, 'read')(read-only open, does not acquire write ownership)
Pricing a conversation should never resume it—that would spawn an agent out of thin air.
Installation & Activation¶
Install within DSH:
# In DSH: Settings → Plugins → Install, enter the directory or package name
E:/Data/Project/DeepSeekHarness/DSH-Homemade-Plugins/dsh-cost
Or add the dependency and bundle to the profile’s package.json:
"dependencies": { "dsh-cost": "link:E:/Data/Project/DeepSeekHarness/DSH-Homemade-Plugins/dsh-cost" },
"dsh": { "profile": { "bundles": [ /* … */ "dsh-cost" ] } }
Then run pnpm install in the profile directory and restart DSH.
Code changes require a restart to take effect: the loader caches already-imported modules. The UI side will pick up the new bundle on its own, but the Host side (routing, pricing, cost calculation) must restart DSH to load.
Migration from dsh-toolbox¶
On the first launch after the split, this plugin reads the cost configuration from the old plugin’s ~/.dsh/toolbox/settings.json one time and copies prices.json into its own directory, so currency, exchange rate, and price cache are all preserved. The old file is not modified (it still belongs to the other plugin).
File Paths¶
~/.dsh/cost/settings.json Settings
~/.dsh/cost/prices.json Price cache
~/.dsh/cost/logs/cost.log Rejected pricing requests, price refresh logs
Testing¶
npm test # 109 test cases, all offline, DSH does not need to be running
Test coverage:
- Real route handler functions: loopback fence, method validation, settings round-trip and out-of-range fallback, first-launch takeover of old plugin config, live/archived session pricing, image generation cost inclusion and toggle, sub-agent aggregation and depth limit/toggle, price routing, copy keys present in both Chinese and English
- Folding replacement rules, retry clearing, per-model breakdown, peak/off-peak, cross-currency, unpriced tokens, per-line amount and total consistency, multi-session merging
- Image result parsing (single/batch/editing/failure), 1K/2K/4K tiers and 4K limited-time discount, cross-tier interpolation, editing reference image tier, cross-currency, voice duration parsing and pricing, failed calls not billed, workspace scan depth limit/ignored directories/
.droppedexclusion, wav-based deduplication, merged reports - Official pricing page parsing (using captured en/zh pages as fixtures), peak determination, aliases, conversion, external JSON, refresh failure retaining previous copy
- Registration placement, dictionary key consistency, real capsule rendering (including visible failure state), sub-agent allocation panel, toggles and currency, memoization of pricing results, panel popping toward the side with available space, settings page save and read failure
Use Cases¶
Suitable for DSH users who need precise monitoring of conversation costs, especially:
- Scenarios using sub-agents for complex tasks
- Scenarios with frequent image generation usage
- Scenarios requiring voice transcription with cost tracking
- Scenarios needing precise visibility into the source of each charge
Notes¶
The plugin runs with the current DSH process permissions. Review the source code and license before installing.
Image generation and voice billing in the plugin are estimates, and the panel will mark them as “Estimated.”
The 10-hour monthly free quota is not modeled. The panel reports “how much you would pay at list price,” not your actual bill.
Voice costs are obtained from two sources: the Billed Ns ≈ ¥X line in the in-conversation log, and segments-*.json files found within two levels below the conversation’s cwd in the workspace. Both sides deduplicate by the --wav audio path, so the same transcription is only counted once.
Summary¶
dsh-cost lets you see conversation costs without leaving the DSH interface, with precise breakdowns for sub-agents, image generation, voice, and other items. It folds costs from session logs, supports official price lists, web scraping, or custom JSON as price sources, prices by peak/off-peak periods, and supports switching between RMB and USD.
Plugin repository: https://github.com/fengnowuyu-beep/dsh-cost