Introduction¶
When conducting multi-turn sessions in DeepSeek Harness, a common requirement is not only to obtain the model output but also to confirm the token consumption for the current turn and the entire session accumulated so far, the approximate cost based on the current contract price, and whether it is approaching the set session quota.
dsh-billing provides local billing, projection, and Web interface display for this scenario. It is suitable for viewing cost reference values during DSH development or debugging, but it is not a billing system and will not automatically block model calls.
What is it¶
Wanbinyu/dsh-billing is a session billing and quota plugin for DeepSeek Harness, maintained by Wanbinyu. This is an independent community project and is not part of the official DeepSeek Harness release.
It mainly does three things:
- Stat token costs by provider/model.
- Generate
billingsession projection. - Display current turn/session costs, quota progress, unpriced model warnings, and model details in the Web composer dock.
Costs are local reference values, not invoices, and will not automatically block model calls.
Core Features¶
dsh-billing capabilities focus on session-level billing and Web display:
- Stat token costs by provider/model.
- Generate
billingsession projection. - Support per-session quota.
- Display current turn/session costs, quota progress, unpriced model warnings, and model details in the Web composer dock.
- Bundle exports both host and Web client entry points simultaneously.
- Prices prioritize configuration, followed by the built-in USD model catalog.
- Same model IDs under different providers are counted separately, e.g.,
deepseek/deepseek-v4-flashandopenrouter/deepseek-v4-flash. - Quota progress color intensifies at 50%, 80%, and 100% thresholds.
The host side is responsible for pricing and projection, while the browser side renders the interface from the host’s calculated projection.
Installation and Enablement¶
Installation as a Bundle¶
The installation command given in the repository README is as follows. This command installs the v0.6.3 community bundle:
dsh plugin --profile web add https://github.com/Wanbinyu/dsh-billing/releases/download/v0.6.3/dsh-billing-community-bundle-0.6.3.tgz
After installation, restart dsh.
The bundle enables both host projection and Web cost bar via a single billing configuration entry. Prices prioritize configuration, followed by the built-in USD model catalog.
Manual Installation¶
If the host project requires control over the composition layer, you can install two packages:
npm install ./packages/dsh-billing ./packages/dsh-client-ui-billing
Then add the following to the profile’s cordis.patch.yml:
- insert:
- id: billing
name: dsh-billing
config: {}
- id: ui-billing
name: dsh-client-ui-billing
This enables dsh-billing on the host side and dsh-client-ui-billing on the Web side.
Typical Usage¶
Configuring Prices and Quotas¶
When configuring prices, precise provider/model is prioritized. Writing only the model ID is still valid and serves as a fallback for all providers.
Example configuration:
- id: billing
config:
models:
deepseek/deepseek-v4-flash:
input: 1
output: 2
cacheRead: 0.02
cacheWrite: 0
currency: CNY
quota:
limit: 5
The prices above are just documentation examples; actual prices are configured according to the contract.
When using CNY or other currencies, please explicitly configure prices for each model. Models without prices will still be counted in unpricedModels. They will not fabricate costs; quota.estimated will become true, indicating that the quota progress only includes known prices and cannot be treated as a complete bill.
If you modify the billing line after the bundle has been inserted, Harness’s patch will replace the entire config block, so you need to preserve all configuration fields you wish to continue using.
Viewing Projection Results¶
The billing session projection includes currency, total cost, per-model costs, token details, unpriced models, and quota status. The interface is as follows:
interface BillingProjection {
currency: string
totalCost: number
models: {
provider: string
model: string
cost: number
uncachedInputTokens: number
outputTokens: number
cacheReadTokens: number
cacheWriteTokens: number
}[]
unpricedModels: string[]
latestTurn?: {
turn: number
cost: number
uncachedInputTokens: number
outputTokens: number
cacheReadTokens: number
cacheWriteTokens: number
unpricedModels: string[]
}
quota?: {
limit: number
used: number
remaining: number
percent: number
estimated: boolean
}
}
latestTurn appears after the first usage is received, providing the client with costs and token details for the most recent turn.
Projections assign usage to steps based on request/header. Subsequent samples for the same (turn, step) will simultaneously replace early samples in both the session accumulation and current turn data to avoid double billing. Usage without a preceding header is placed in a reserved (unknown) bucket.
Generating Built-in Catalog and Full Verification¶
The built-in catalog only uses USD and is generated from the pi-ai model catalog via the following script:
node packages/dsh-billing/scripts/generate-catalog.mjs
Run full verification:
npm run build
npm run verify
Applicable Scenarios and Notes¶
Suitable for the following scenarios:
- Need to view current turn and session accumulated costs in a DSH Web session.
- Need to view token details by provider/model.
- Need per-session quota progress notifications.
- Need to enable billing and quota display in a local DSH project.
The following limitations must be clearly understood before use:
- This is an independent community project and is not part of the official DeepSeek Harness release.
- Costs are local reference values, not invoices or bases for forced throttling.
- Quotas will not automatically block model calls.
- Quota is currently calculated per session; deployment-level budgets are not yet implemented.
- Compatible with DeepSeek Harness versions
0.1.0-rc.6torc.8and0.1.1-rc.1torc.2; dev dependencies are fixed at0.1.1-rc.2. package.jsonrequires Node.js>=22.19.0.- License is MIT.
- The plugin runs with the current dsh process permissions; source code and license should be checked before installation.
Conclusion¶
dsh-billing provides a local session billing and quota view: it places costs, token details, and quota progress into the DSH Web session, making it convenient to view and verify during development. When using it, please treat it as a local reference value, not a bill or throttling limit.
Verified public entry points:
- GitHub Repository: https://github.com/Wanbinyu/dsh-billing