DeepSHPlugins
dsh-bill 项目预览
GITHUB / COMMUNITY PROJECT

dsh-bill

安全与运维JavaScriptMIT

按在线价格目录计价的费用统计(models.dev + OpenRouter,8000+ 模型,每次调用按自身时刻定价):每轮成本行、把花费归因到工具输出 / 模型输出 / 系统提示词 / 终端命令的「费用」标签页、预算、月度预测、约 166 种实时汇率货币,以及 bill_stats agent 工具。

2 StarsJannchie 更新时间 2026-08-25
访问 GitHub 仓库
dsh-bill 项目预览
dsh-bill 界面截图dsh-bill 界面截图

项目介绍

中文

按在线价格目录计价的费用统计(models.dev + OpenRouter,8000+ 模型,每次调用按自身时刻定价):每轮成本行、把花费归因到工具输出 / 模型输出 / 系统提示词 / 终端命令的「费用」标签页、预算、月度预测、约 166 种实时汇率货币,以及 bill_stats agent 工具。

English

Cost tracking priced from an online catalogue (models.dev + OpenRouter, 8000+ models, each call priced at its own instant): a per-turn cost line, a Cost tab attributing spend to tool output / model output / system prompt / commands, budget, monthly forecast, ~166 live-rate currencies, and a bill_stats agent tool.

项目信息与收录信号

快照 2026-09-11
作者 / 组织
Jannchie
仓库
Jannchie/dsh-bill
GitHub Stars
2
Forks
1
开发语言
JavaScript
许可证
MIT
最近推送
2026-08-25
Manifest
数据中检测到声明

公开仓库不自动等于可商用;许可证与当前兼容性以原项目文档为准。Manifest 和数据评分不构成安装安全认证。

数据评分

60/ 100
维护活跃
89
文档与实用信息
99
生态关注度
23
安装便捷信号
55
项目声明信号
100

近 17 天仍在更新;README 含完整安装与使用说明;关注度尚低(2)。

评分来自已有数据快照的五维模型,仅作浏览参考,不是实际使用评测或安全检测结论。

安装与使用

所有项目资料与许可均以对应 GitHub 仓库为准。

dsh plugin --profile web add dsh-bill

复制命令不会自动执行。请先阅读仓库文档,确认环境要求与许可证。

项目截图

仓库 README

GitHub 原文

已保存的仓库文档快照;文档抓取时间未记录,可能与上方目录介绍处于不同版本。安装前请核对当前仓库说明。

dsh-bill

English | 中文

Cost tracking for DSH (DeepSeek Harness). A line under each turn tells you what that turn cost; the Cost tab tells you what the money went on.

Per-turn cost in the conversation

Cost attribution

Install

dsh plugin --profile web add dsh-bill

Restart dsh web to pick it up.

Features

  • Cost attribution — the bill split by kind of content: tool output, model output, system prompt, terminal commands (grouped by git / pnpm / rg), tool input, attachments, system reminders, user input. The sunburst drills in.
  • Per-turn cost — one line under every finished turn: what it cost, how many steps, the cache-hit rate. It reads the session log itself, so turns from before you installed the plugin are covered too.
  • Always on screen — a line under the shipped stats line (all-time, this session, peak share), and today's spend against the budget in the sidebar. Each of the four surfaces can be turned off individually in settings.
  • Report — a Cost tab in the conversation, beside Chat and Trajectory: total, tokens, cache hit, peak share, monthly forecast, account balance; broken down by model, by session, and by purpose (including loop overhead such as context compaction); a daily trend and a weekday × hour heatmap.
  • Budget — a daily / monthly / all-time limit that turns amber past 80% and red when you go over.
  • Multi-currency — live rates for ~166 currencies; each model's base rate is shown in the currency its vendor prices it in.
  • Agent tool — bill_stats, so the model can answer questions about spend directly.
  • English and Chinese follow the DSH language setting; history from before the install is backfilled from the session log.

How it differs from similar plugins

Three substantive differences:

No hand-maintained price table. Every other plugin ships a built-in table of 2–4 DeepSeek models, which means no prices at all once you switch provider — and which is why they all need a "edit the price table by hand" entry point. dsh-bill pulls models.dev and OpenRouter through llm-pricing, covering 8000+ entries, so a new model is priced the day it ships.

Price is a timeline, not a number. The others compute a cost and store it (or recompute at today's price), so history goes wrong the moment a vendor changes its rates or a call crosses a peak/off-peak boundary. dsh-bill prices each call at that call's own instant, and never recomputes history.

It answers "on what". The others answer only "how much" — they consume the provider's aggregate token counts and never look at the request content. dsh-bill splits the request into classified segments at capture time and apportions cost by position in the cache prefix.

They do some things better: usage-stats reads balances and subscription quotas from 11 providers (dsh-bill only does DeepSeek), cost-meter can read OpenCode Go's subscription quota, and both surface more always-on entry points than dsh-bill does.

Point-by-point comparison (read from source, sampled 2026-08-16)

The sample is the cost-related plugins under the GitHub dsh-plugin topic with ★ ≥ 40, plus the four published to npm. Lower-starred plugins such as deepseek-harness-wallet were not checked individually.

dsh-billcost-meterusage-statsdsh-costcost-logdsh-usageusage-billing
stars / version—★42 / 1.3.1★40 / 0.2.0★3 / 0.2.1★2 / 1.0.0★2 / 0.1.10.2.2
price sourceonline cataloguebuilt-in table + hand-scraped docsnonebuilt-in tablebuilt-in tableuser-enteredbuilt-in table
models covered8000+ entries4 DeepSeek—4 DeepSeek2 DeepSeekone at a time, by handDeepSeek
unlisted modelflagged, excluded from totalsbilled at flash rateflagged unknownbilled as v4-proflagged ≈flagged --counted as 0
history never recomputed✓✗—✗✓✓manual backfill
content attribution✓✗✗✗✗✗✗
forecast✓✗✗✗✗✗✗
budget✓✓✗✗✗✗✗
account balance✓✓✓✓✗✗✗
pre-install history✓✗✓✗✓✓✓
agent tool✓✗✗✗✗✗✓
currencies166, live rates3, fixed rates—follows UI language¥/$single¥ only

Pricing

  • two catalogues, models.dev and OpenRouter, cached for 24h and written to disk, falling back to a built-in historical snapshot on failure;
  • DeepSeek's own direct rates override the catalogue, and the peak / off-peak rate is chosen from the call's timestamp;
  • model names are normalised, and anything that still fails to match is flagged ? and excluded from totals — nothing is estimated;
  • priceOverrides can override or add any price (rarely needed).

Attribution method

Every request pays for the full context again, so one tool output read into the conversation keeps being billed on every subsequent request until it slides out of the window. Attribution is computed per request and summed.

Two things matter:

  • Price by position. Under prefix caching the first N tokens of the prompt bill at the cache rate and the rest at full rate — on DeepSeek the two differ by up to 156×. Segments are ordered exactly as the provider received them, the cached prefix is charged at the cache rate, and only the tail pays full price. Apportioning by an average unit price files the money under the wrong category.
  • Counts only. Attribution happens at capture time on the live request; only the per-category amounts are written to disk. No prompt text is stored.

Per-segment token counts are estimated from character share (providers return only a total), and the total is the real billed figure, so the parts sum exactly to what you paid.

The session log holds token counts and model routes but not the request bodies — which is why pre-install history can be backfilled as spend, but cannot be attributed retroactively. The report states what fraction is covered.

Configuration

The budget, its currency, and which of the four surfaces are shown are all set on the Cost page in settings, and stored in $DSH_HOME/dsh-bill/prefs.json. (Not in the harness's own settings document: its API proxy serves a fixed allowlist of namespaces to the browser, so a plugin's namespace is never readable or writable from there.)

maxRecords (the in-memory ring buffer size, default 20000) and priceOverrides are plugin config and are validated at startup — a mistyped field is reported by name rather than leaving the report quietly empty. ~/.dsh/profiles/web/cordis.patch.yml is only needed when you want to override a price:

- insert:
    - id: bill
      name: 'dsh-bill'
      config:
        priceOverrides:
          'anthropic/claude-sonnet-4-6':
            inputPerM: 3.0        # USD per million input tokens (uncached)
            outputPerM: 15.0
            cacheReadPerM: 0.3
            cacheWritePerM: 3.75

Data and privacy

  • each call's provider / model / token usage and attributed amounts are written to $DSH_HOME/dsh-bill/records.jsonl (a 20 000-entry ring buffer; older entries are folded into a rollup);
  • the API key used for the account balance is read and used host-side and never reaches the browser;
  • nothing is sent anywhere except the price catalogues, the exchange-rate endpoint, and the balance query; no conversation content is stored.

Implementation

LayerHow
Capturehooks the llm/stream waterfall, wraps the stream to observe usage chunks, passes everything through untouched
Pricingllm-pricing resolves catalogue / peak rate / override at the call's own instant
Attributionthe request is split into classified segments at capture time and apportioned by position in the cache prefix
Backfillscans the session log for sessions it never recorded, deduplicating on turn:step
Per turnthe billTurns session projection folds the session log host-side and pushes to the client — no polling
Storagein-memory ring buffer plus append-only JSONL, folded into a rollup before eviction; preferences in their own small JSON document; atomic replace and file locking borrowed from dsh-atomic-write
Transportthe ctx.connection.rpc channel /dsh-bill when there is one, falling back to POST /dsh-bill/api
UIconversation.view / conversation.chat.turnTail / conversation.composer.dock / sidebar.footer.action / settings.section, built on the host's --dsw-* design tokens

License

MIT

使用前核对

安装步骤、兼容版本与授权范围以原项目当前文档为准。Stars 和评分是快照中的导航信号。

安装与排错 · 项目问题反馈

同类项目