Introduction¶
When running models in DSH, most people don’t just use the official API. You may be tuning models on Alibaba Bailian, but market usage plugins almost all have the same built-in DeepSeek official price. The result is: same model name, different service providers, price might differ by several times; the official [DeepSeek] platform has peak and valley hours, but Bailian may not; private deployment models with tenant prefixes cannot be found in any public price list. Finally, token statistics are very accurate, but the amount is wrong, and wrong silently.
Below introduces looriann/dsh-cost-ledger. Its positioning is DSH’s “Cost” tab, showing how much token cost per day and per model. It recognizes not just DeepSeek; the same weights sold via Bailian, official, or third-party resale, when prices differ, it checks prices by the “Provider + Model” tuple, not guessing by model name. The interface is modeled after the DeepSeek official console: stacked bar chart by day, hover to see daily details.
What is this¶
This is a client plugin maintained by Looriann, classified under client (web platform). The repository address is https://github.com/Looriann/dsh-cost-ledger, the community directory page is https://www.skillhub.cn/plugins/Looriann/dsh-cost-ledger. Current GitHub stars: 1.
It solves the core problems in three layers:
- Identity: Check price by the “Provider + Model” tuple, not just by model name.
- Origin: Each model row carries a confidence badge (manual entry / official / aggregate directory / inherited / unpriced).
- Price Fixing: If not found, explicitly mark “unpriced”, click to fill, save and recalculate history immediately.
The plugin’s design philosophy is: better to show “unpriced” than a professional-looking fake ¥0.00.
Core Features¶
| Capability | Description |
|---|---|
| Daily Chart | Stacked bar chart of Day × Model, hover to see daily cost per model, toggle “Amount / Tokens” |
| KPI Bar | Today / Last N days / This month / Cache Hit Rate / Sample Count |
| Price Source Badge | Badge per model row, instantly see if the number is fetched or manually entered |
| In-place Price Fixing | Open unpriced banner, fill four unit prices (RMB / million tokens), save and recalculate |
| Bundled Price List | Built-in Alibaba Bailian official RMB prices for 142 models: All Qwen models + DeepSeek / Kimi / GLM / MiniMax Bailian versions |
| History Backfill | First launch auto-scan ~/.dsh/sessions/, past few days’ ledger immediately available |
| Auditability | npm run replay recalc in terminal using the same code, interface numbers must be reproducible |
The “Auditability” feature is what distinguishes it from ordinary usage panels: the interface and replay share the same code under lib/, so the numbers on the interface must be reproducible in the terminal.
Installation & Enablement¶
There are two ways to install.
Method 1: Plugin Store, search cost-ledger, full package name is @looriann/dsh-cost-ledger, click install.
Method 2: Command Line, install under the DSH desktop profile:
dsh plugin --profile desktop add @looriann/dsh-cost-ledger
After installation, restart DSH and hard refresh the browser with Ctrl+Shift+R. Open any session, and the top tab bar will have an extra “Cost” tab.
Dependencies are written in package.json, runtime is zero-dependency:
"engines": {
"node": "^22.19.0 || >=24.0.0"
}
The README also specifies that DSH 0.2.0-rc.2 / 0.2.1-rc.2 is required. The Node range here comes from the engines field in package.json, and the DSH version constraint comes from the original README. Note that the command must match the original text exactly, especially do not try to guess dsh plugin add github:owner/repo based on the directory name.
Typical Usage¶
- Open any session, click the top “Cost”.
- The first open will automatically backfill history; the chart and KPI will appear in a few seconds.
- If an orange banner “N models unpriced” appears at the top, click the chip inside to fix the price, fill four unit prices and save.
When you need to verify the original ledger, run replay in the repository directory:
npm run replay # Replay all sessions, print daily tokens and amounts
npm run replay -- <log file> # Single session, round-by-round cost
To re-fetch official prices:
npm run prices # Re-fetch official prices, merge into ledger (does not overwrite manual entries)
Development self-check commands are also listed, all are original scripts:
npm run check # Syntax check (8 modules)
npm test # 22 unit cases + 8 plugin smoke tests
npm run replay # Replay local real logs
npm run seed # Rebuild bundled price list from fetch results
npm run rename # Rename package in one click (when changing npm scope)
Where do prices come from¶
By priority from high to low:
| Source | Description |
|---|---|
| Manual entry | Highest priority, never overwritten by auto-fetch |
| Official price list | Bundled seed (Alibaba Bailian official page, 142 models, including Bailian versions of third-party models), or re-fetch via npm run prices |
| Aggregate directory | Planned to integrate models.dev / LiteLLM |
| Inherited same model | Same model has an entry under another provider, borrowed but marked as degraded |
| Unpriced | Only tokens, no money, interface clearly marks in red |
Regarding auto-fetching, the README is quite direct: the model plaza on bailian.console.aliyun.com is a logged-in SPA, scripts cannot scrape the table; however, the same table has a public Markdown export at help.aliyun.com/zh/model-studio/model-pricing.md, which can parse out CNY unit prices, tiered ranges, and free quotas, currently for 142 models. The official page only lists input/output unit prices, cache unit prices are not listed separately. The plugin calculates cache unit price based on Bailian’s public rules (cache hit 10%, explicit create 125%) and marks the cacheRule field in the price list. The only things that truly cannot be fetched are private deployments (those with tenant prefixes like cmaas-glm-5.3), which are designed to be left blank for manual entry.
Why numbers are trustworthy¶
- Don’t guess tokens: Directly read the harness
assistant/messageevents, the four itemsinput / cacheRead / cacheWrite / outputare booked as-is. - No double billing: Key is
sessionId + turn + step, duplicate reports for the same step replace, not accumulate. - Integer micro-units:
micro = round(tokens × unit_price), avoid float errors snowballing;null ≠ 0. - Calculate on read: Amount is always calculated based on the current price list, changing price doesn’t require rebuilding history.
Data is completely local:
~/.dsh/cost-ledger/
├─ samples.ndjson ← Append-only usage samples (single source of truth)
└─ prices.json ← Your price list
No internet, no upload of any content, and does not read dialogue content, only reads numbers in usage. Deleting samples.ndjson and restarting is like starting from scratch.
Applicable Scenarios & Notes¶
Suitable for these people: running models on both DeepSeek official and Bailian, needing to distinguish actual spending by provider for the same model; having private deployment models not in public price lists; wanting interface numbers to be reproducible in the terminal, not just viewing a panel.
There are a few points to note before using:
- The plugin runs with the current DSH process permissions. Before installing, you should check the source code (
lib/andscripts/) and the license, not just the README. The license is MIT, author Looriann. The README notes that the event parsing semantics reference the public implementations of@kidli1412/dsh-session-costanddsh-context, and the code is independently written. - It is a purely local tool. It does not access the internet except when you manually run
npm run pricesto access the Alibaba Cloud documentation page. Therefore, there is no backend account system, and consequently no cloud billing capability. - It displays estimates calculated based on the price list you filled in, not an official bill. Common reasons for mismatches with the official bill include missing cache read/write prices, different tier levels, not deducting official free quotas, and rounding.
- It only reads
session/event, only registers its own/api/cost-ledger/*routes, and only adds a page to the tab bar, modifying no built-in components. The README clearly states it will not conflict with other usage plugins.
Conclusion¶
dsh-cost-ledger breaks a prone-to-error problem into small parts: first remember every token item, then price by the “Provider + Model” framework, marking “unpriced” if not found for you to fill. Its value lies not in making the interface look like an official console, but in making the amount traceable, recalculable, and not silently wrong.
Directory page: https://www.skillhub.cn/plugins/Looriann/dsh-cost-ledger
GitHub: https://github.com/Looriann/dsh-cost-ledger