The DSH context ring shows token consumption, but what developers usually care most about is cost. As the context gets longer, the cached prefix becomes more expensive, and additional turns increase cumulative overhead; once the window accumulates enough content, the input and output cost for each turn rises significantly. The dsh-cache-billing plugin integrates billing calculations into the context ring popup, providing three breakdowns—current step, current turn, and session cumulative—calculates amounts in real time based on peak/off-peak rates, and helps decide whether to switch windows.
Plugin positioning¶
dsh-cache-billing is a DSH client plugin provided by maintainer better-er. It solves the problem of “high cache hit rate but invisible cumulative cost,” displays fee details in real time on the client side, supports accounting logic for third-party relays, and prices by default using the DeepSeek-V4.1-Flash model.
Core features¶
Third-party relay support¶
It is not limited to the official DeepSeek routing: as long as the Provider is not empty, billing information is displayed. If the relay’s price list differs from the official one, amounts are estimated by matching the model name to the price list, and it shows “priced as DeepSeek-V4.1-Flash,” ensuring that an account can still be calculated.
Three-tier billing breakdown¶
It supports statistics at three timing levels:
1. Current step: the cost of a single API call.
2. Current turn: the cumulative cost of multiple steps within the current turn.
3. Session cumulative: the total spending for the entire session, accumulated one entry at a time using the rate at the time of each event, without comparing prices across turns.
The billing hierarchy is clearly indented, listing the token counts and amounts for cache hits, cache misses (input/output).
Automatic peak/off-peak pricing¶
It automatically determines rates based on Beijing time:
* Peak hours: weekdays from 09:00–12:00 and 14:00–18:00.
* Off-peak hours: all other times, as well as all day on Saturdays, Sundays, and Chinese statutory holidays.
Price configuration is in the MODEL constant in src/index.ts; the statutory holiday table is in HOLIDAYS_2026 in the same file.
Single model and precision levels¶
- Pricing model: uniformly priced as DeepSeek-V4.1-Flash.
- Display precision:
- Current step: four decimal places
- Current turn: three decimal places
- Session cumulative: two decimal places
- Trailing zeros are not omitted; even amounts precise to 0.0001 yuan can be identified.
Installation¶
Use the following command to install the plugin. After installation, the plugin is automatically mounted and takes effect after restarting DSH web.
dsh plugin --profile web add github:better-er/dsh-cache-billing
Usage¶
After installation, open the DSH web interface and click the context ring on the right side of the input box. You can view the current billing breakdown at the bottom of the popup, displayed on the same screen as the “how much context has been used” information.
Development and configuration notes¶
- Plugin form: a standard host plus client dual-half plugin.
- Billing scope: only recognizes the four token types in
usage: input, cacheRead, cacheWrite, and output. - Source code configuration: prices, peak/off-peak time periods, the model name allowlist, and display names are all defined in the MODEL constant in
src/index.ts. After changing the configuration, runnpm run buildto rebuild. - Holidays: the statutory holiday list is
HOLIDAYS_2026, located insrc/index.ts.
Ecosystem links¶
- GitHub: https://github.com/better-er/dsh-cache-billing
- Catalog page: https://www.skillhub.cn/plugins/better-er/dsh-cache-billing