dsh-cost-meter 1.8.26 → 1.8.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +9 -7
  2. package/README.zh-CN.md +9 -7
  3. package/docs/billing-statistics.md +58 -2
  4. package/docs/billion-context-billing.md +74 -0
  5. package/docs/opendesign-billing.md +66 -0
  6. package/docs/provider-pricing-2026-10.md +14 -8
  7. package/docs/provider-pricing.json +555 -11
  8. package/docs/update-notes-2026-10-15.md +70 -0
  9. package/lib/backfill.js +58 -19
  10. package/lib/billing-history.js +128 -0
  11. package/lib/billing-stream.js +6 -3
  12. package/lib/billion-context-billing.js +210 -0
  13. package/lib/billion-context-compatibility.js +16 -0
  14. package/lib/billion-context-history.js +121 -0
  15. package/lib/billion-context-native.js +45 -0
  16. package/lib/billion-context-proxy.js +213 -0
  17. package/lib/call-inspection.js +7 -0
  18. package/lib/client.js +5 -5
  19. package/lib/client.pricing.js +1 -0
  20. package/lib/client.statistics.js +26 -13
  21. package/lib/coding-plans.js +10 -3
  22. package/lib/context-costs.js +1 -1
  23. package/lib/index.js +91 -59
  24. package/lib/ledger-persistence.js +18 -0
  25. package/lib/opendesign-prices.js +356 -0
  26. package/lib/opendesign-pricing.js +51 -0
  27. package/lib/opendesign.js +107 -0
  28. package/lib/openrouter-pricing.js +1 -0
  29. package/lib/plan-billing.js +16 -3
  30. package/lib/plan-provider-match.js +15 -3
  31. package/lib/pricing.js +19 -5
  32. package/lib/provider-prices-2026-10-15.js +240 -0
  33. package/lib/provider-prices.js +9 -1
  34. package/lib/session-cost-source.js +29 -0
  35. package/lib/session-usage-cache.js +53 -0
  36. package/lib/statistics-cache.js +86 -0
  37. package/lib/statistics-warmup.js +133 -0
  38. package/lib/store.js +66 -12
  39. package/lib/trajectory.js +252 -40
  40. package/lib/turn-cost.js +114 -32
  41. package/lib/typert.host.js +32 -10
  42. package/package.json +8 -3
package/README.md CHANGED
@@ -10,12 +10,14 @@ Community and feedback: [Join the WeChat group →](#community). The WeChat grou
10
10
 
11
11
  Per-conversation cost · daily totals · OpenCode Go subscription quota display · budget with usage percentage · official account balance · custom provider balance · balance progress bar · history · peak/off-peak pricing hours display (peak hours UTC 01:00–04:00, 06:00–10:00; weekends and Chinese public holidays are off-peak all day, with separate labels) · pre-switch popup & system-notification alerts for peak/off-peak changes (position / lead time / alert type configurable) · one-click price sync from the official docs · Codex-style token usage heat grid · multi-vendor model pricing (built-in 170+ model-ID catalog with auto-matching) · mainstream Coding Plan quota queries & display (Anthropic / Z.ai / MiniMax / Kimi / OpenRouter / SiliconFlow / CommandCode / SCNet / Volcano Ark / Qwen / Xiaomi MiMo / Factory Droid) plan/API dual-track billing (subscription quota vs pay-as-you-go money separated, per-1% & full-window token/equivalent-cost estimates with daily/weekly/monthly curves) · · quota strip above the input box (budget / Go / coding-plan usage in one row, toggleable)
12
12
 
13
- [![version](https://img.shields.io/badge/version-1.8.26-4176E6)](https://github.com/Han-1413141/dsh-cost-meter)
13
+ [![version](https://img.shields.io/badge/version-1.8.27-4176E6)](https://github.com/Han-1413141/dsh-cost-meter)
14
14
 
15
- **v1.8.26** fixes custom-provider plan matching with manual plan assignment, explicit name-based detection and recovery of fully covered recent usage. See the [plan assignment guide](docs/token-plan-stats.md#assigning-custom-providers-to-a-plan).
15
+ **v1.8.27** preserves historical prices, adds confirmed recalculation and model search, fixes session fee display, and adds billion-context internal billing plus OpenDesign pricing and quota queries.
16
16
 
17
17
  Desktop users: follow the [Desktop installation instructions](docs/install-troubleshooting.md#desktop-安装与更新) for the application's own CLI and `desktop` Profile.
18
18
 
19
+ Release notes: [Billing update — v1.8.27](docs/update-notes-2026-10-15.md#english). billion-context internal billing requires its paired compatibility build; versions below 0.1.181 receive an upgrade notice.
20
+
19
21
  If startup reports **Ledger is busy** and the cost widgets are missing, see [ledger lock recovery](docs/ledger-lock-recovery.md#english).
20
22
 
21
23
  [![npm](https://img.shields.io/npm/v/dsh-cost-meter?label=npm)](https://www.npmjs.com/package/dsh-cost-meter)
@@ -325,22 +327,22 @@ On Node.js 20, use `npm install -g pnpm@10` instead. See [pnpm installation and
325
327
  dsh plugin --profile web add dsh-cost-meter
326
328
  ```
327
329
 
328
- **PowerShell one-click script** (copy the whole line, paste, press Enter; pnpm is provisioned automatically, git is auto-detected — no clone needed; the install chain is **pinned to the release tag `v1.8.26`** — review the script before running):
330
+ **PowerShell one-click script** (copy the whole line, paste, press Enter; pnpm is provisioned automatically, git is auto-detected — no clone needed; the install chain is **pinned to the release tag `v1.8.27`** — review the script before running):
329
331
 
330
332
  ```powershell
331
- irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.8.26/install.ps1 | iex
333
+ irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.8.27/install.ps1 | iex
332
334
  ```
333
335
 
334
336
  **Or a plain command line** (the machine must already have pnpm and git; also pinned to the tag):
335
337
 
336
338
  ```sh
337
- dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.8.26
339
+ dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.8.27
338
340
  ```
339
341
 
340
342
  Without git, use the GitHub tag archive:
341
343
 
342
344
  ```sh
343
- dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.8.26.tar.gz
345
+ dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.8.27.tar.gz
344
346
  ```
345
347
 
346
348
  After installing, **restart** `dsh web` (plugin rows, the Typert manifest and the client bundle are all scanned at startup):
@@ -425,7 +427,7 @@ dsh plugin --profile web add link:./dsh-cost-meter # symlink; edit lib/client.j
425
427
  - Billing uses usage blocks reported through the host's `llm/stream`, including sub-agents, compression, title generation and other auxiliary calls in isolated LLM services. Child sessions retain their own `sessionId` and do not contribute to the parent badge; background calls without a `sessionId` contribute only to daily/monthly/lifetime totals. Memory or other plugins that call external APIs directly without reporting usage to the host cannot be tracked;
426
428
  - **Peak/off-peak tiers follow the request-initiation moment**: a streaming call can span the tier boundary hour; attributing by completion time would put a request started minutes earlier into the wrong tier;
427
429
  - **Peak effective-time anchoring**: the official pricing page no longer lists an effective time, and price sync no longer resets the peak effective moment to "now" — historical recomputes (session projection refolds / per-model backfill) always tier events against the 2026-08-16 16:00 UTC boundary, so peak-hour history is no longer re-costed at half price; ledgers polluted earlier are clamped back automatically on upgrade (idempotent migration);
428
- - **Switching pricing currency re-bases the whole history**: after the pricing-currency setting flips and re-syncs, historical entries are re-costed on the new price table in the background (days fully covered by session logs are replaced wholesale; sessions whose logs were cleaned keep their original basis), so history and the official bill share one basis, with a notice on completion; on upgrading to this version, existing ledgers that had switched currency and ended up with mixed bases are recomputed once automatically;
430
+ - **Historical pricing**: changing pricing currency, rates or mappings affects subsequent calls. Saved price versions preserve older details; explicit recalculation requires confirmation and retains original amounts, price versions and a full ledger backup. See the [update notes](docs/update-notes-2026-10-15.md#english).
429
431
  - **Aligning with official bills**: ① minute-level lag vs live official numbers is expected — the ledger flushes on a 2s debounce, and streams still in flight at shutdown are billed server-side while their usage block is never received (the gap concentrates in cache-hit columns); ② reasoning tokens are reported separately by the API and are **not billed** — the token columns sum five buckets and will never line up with the official three columns, so **reconcile by amount**; ③ with pricing currency set to CNY, entries are recorded directly on the official CNY price list (recommended for CNY-billed accounts); with USD, displayed amounts go through a fixed FX rate and carry a small structural difference (the two lists' per-column ratios are not uniform);
430
432
  - Budget and over-budget warnings **only warn — they never block calls**.
431
433
  - **Plan/API dual-track billing** (issue #64): calls on subscription-style channels (MiniMax, manually-marked Codex, etc.) are recorded as catalog-price equivalents only; budget/today-cost/overview cards count the pay-as-you-go (API) channel exclusively.
package/README.zh-CN.md CHANGED
@@ -10,12 +10,14 @@
10
10
 
11
11
  本会话费用 · 当日费用 · OpenCode Go 订阅额度显示 · 预算与已用百分比 · 官方账户余额 · 自定义 Provider 余额查询(可配任意 HTTP 端点) · 余额三段进度条 · 历史记录 · 峰谷计价时段显示(UTC 01:00–04:00、06:00–10:00 为峰时段;周末与中国法定假日全天按谷价,分别标注) · 峰/谷切换前弹窗与系统通知提醒(位置/提前量/提醒类型可配) · 官方价格一键同步 · 类 Codex Token 用量热图 · 多厂商多模型价格计费(内置 170+ 模型 ID 价格目录与自动匹配) · 主流 Coding Plan 额度查询与显示(Anthropic / Z.ai / MiniMax / Kimi / OpenRouter / SiliconFlow / CommandCode / SCNet / 火山方舟 / 千问 / 小米 MiMo 十一家,含 Volcano Ark AK/SK 签名与 MiMo 控制台 Cookie 查询) · Plan/API 双轨计费(订阅额度与按量金额分离统计,每 1% 额度与满窗的 token/等值金额估算及日/周/月曲线) · 输入框上方额度横条(预算/Go/Coding Plan 用量一条横排显示,可开关)
12
12
 
13
- [![version](https://img.shields.io/badge/version-1.8.26-4176E6)](https://github.com/Han-1413141/dsh-cost-meter)
13
+ [![version](https://img.shields.io/badge/version-1.8.27-4176E6)](https://github.com/Han-1413141/dsh-cost-meter)
14
14
 
15
- **v1.8.26** 修复自定义渠道的套餐匹配,支持手动选择套餐和按名称特征自动归属,并恢复能完整核对的近期用量。详见 [套餐归属说明](docs/token-plan-stats.md#自定义渠道如何关联套餐)。
15
+ **v1.8.27** 保留历史价格,新增确认后重算和模型搜索,修复会话费用显示,接入 billion-context 内部计费及 OpenDesign 价格与额度查询。
16
16
 
17
17
  桌面端用户请按 [Desktop 安装说明](docs/install-troubleshooting.md#desktop-安装与更新),使用应用自带的 CLI 和 `desktop` Profile。
18
18
 
19
+ 更新说明:[v1.8.27 计费更新](docs/update-notes-2026-10-15.md#中文)。billion-context 内部计费需要配套兼容包,低于 0.1.181 的版本会收到升级提醒。
20
+
19
21
  启动报 **Ledger is busy** 且费用卡片消失时,参见[账本锁恢复说明](docs/ledger-lock-recovery.md#简体中文)。
20
22
 
21
23
  [![npm](https://img.shields.io/npm/v/dsh-cost-meter?label=npm)](https://www.npmjs.com/package/dsh-cost-meter)
@@ -325,22 +327,22 @@ Node.js 20 请改用 `npm install -g pnpm@10`。版本要求见 [pnpm 官方安
325
327
  dsh plugin --profile web add dsh-cost-meter
326
328
  ```
327
329
 
328
- **PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.8.26`**,建议先下载审阅再运行):
330
+ **PowerShell 一键脚本**(复制整行粘贴回车;自动补齐 pnpm、自动探测 git,无需克隆仓库;安装链**固定到发布 tag `v1.8.27`**,建议先下载审阅再运行):
329
331
 
330
332
  ```powershell
331
- irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.8.26/install.ps1 | iex
333
+ irm https://raw.githubusercontent.com/Han-1413141/dsh-cost-meter/v1.8.27/install.ps1 | iex
332
334
  ```
333
335
 
334
336
  **或直接命令行**(机器上需已有 pnpm 与 git;同样固定到 tag):
335
337
 
336
338
  ```sh
337
- dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.8.26
339
+ dsh plugin --profile web add github:Han-1413141/dsh-cost-meter#v1.8.27
338
340
  ```
339
341
 
340
342
  没有 git 时可用 GitHub tag 打包直链:
341
343
 
342
344
  ```sh
343
- dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.8.26.tar.gz
345
+ dsh plugin --profile web add https://github.com/Han-1413141/dsh-cost-meter/archive/refs/tags/v1.8.27.tar.gz
344
346
  ```
345
347
 
346
348
  安装后**重启** `dsh web`(插件行、Typert 清单与客户端 bundle 均在启动时扫描):
@@ -425,7 +427,7 @@ dsh plugin --profile web add link:./dsh-cost-meter # 符号链接,改 lib/clien
425
427
  - 计费来源为通过宿主 `llm/stream` 上报的 usage 块,包含隔离 LLM 服务中的子代理、压缩、标题等辅助调用。子会话按自己的 `sessionId` 记录,不并入父会话徽章;无 `sessionId` 的后台调用只计入日/月/累计总额。记忆等插件若直接请求外部 API、未向宿主上报 usage,本插件无法统计该部分消耗;
426
428
  - **峰谷档位按请求发起时刻判定**:流式调用可能跨峰谷边界整点,以完成时刻归档会把数分钟前发起的请求算进另一个峰位;
427
429
  - **峰谷生效时刻锚定**:官方价格页已不再标注生效时间,价格同步不再把峰谷生效时刻重置为「同步时刻」——历史重算(会话投影回放 / 按模型回填)一律按 2026-08-16 16:00 UTC 分界判档,峰时历史事件不再被按谷价半价重算;此前被污染的存量账本升级时自动钳制修复(幂等迁移);
428
- - **币种切换即全量换基准**:「价格币种」切换并同步后,历史账目按新价目在后台整体重算(会话日志覆盖完整的日子整体替换,日志已清理的会话保持原口径),历史与官方账单同基准,完成后有提示;升级到本版时,此前切换过币种而新旧口径并存的存量账本自动重算一次;
430
+ - **历史价格保护**:「价格币种」、单价和价格映射的修改只影响后续调用,旧明细使用已保存的价格版本。主动重算前需要确认,并保留原金额、价格版本和完整账本备份。详见[更新说明](docs/update-notes-2026-10-15.md#中文)。
429
431
  - **官方账单对齐口径**:① 与官方实时数字存在**分钟级时差**属预期——账本 2 秒防抖落盘,关停瞬间仍在途的流会被服务端照常扣费而 usage 块无人接收(缺口集中在缓存命中列);② reasoning tokens 由 API 单独上报且**不计费**,token 列为五桶合计,与官方「三列」天然对不齐,**对账请以金额为准**;③ 「价格币种」设为人民币时按官方 CNY 价目直计入账,与人民币账单币种一致(CNY 计价账号推荐);设为 USD 时显示金额经固定汇率折算,与 CNY 直计存在结构性细差(两套价目比值非均匀);
430
432
  - 预算与超支提示**仅提醒,不阻止调用**。
431
433
  - **Plan/API 双轨计费**(issue #64):订阅制渠道(MiniMax / Codex 手动标记等)的调用金额只记「等值」,预算/今日费用/概览卡片等金额展示仅统计按量计费(API)部分;
@@ -2,6 +2,21 @@
2
2
 
3
3
  ## English
4
4
 
5
+ ### Conversation cost views
6
+
7
+ The conversation **Cost details** view defaults to the treemap and offers four layouts over the same complete cost totals:
8
+
9
+ - **Categories:** a donut and compact cost bars group file reading, local search, web search, file changes, commands, agent coordination, compaction, model responses and other tools across all agents. Classification uses recorded tool names only. A model step spanning different activities remains one mixed-tools item and is counted once.
10
+ - **Treemap:** frames show activities and the smaller rectangles show named tools, with the five highest-cost tool combinations retained per activity. Switch to **By agent** to see each agent's own costs divided into activities. Areas follow costs; headings zoom in, and selecting a tile opens its calls in a detail dialog. No steps are hidden behind an undifferentiated step-count remainder.
11
+ - **Ownership:** an expandable tree keeps the actual parent/subagent chain. The tree uses the full panel width. Each row shows cost, steps, calls, share of its parent and share of the conversation; clicking a name opens its calls. Agent totals include descendants; categories underneath contain only the agent's own calls.
12
+ - **Step heatmap:** each fixed-size cell represents one billed step, including zero-cost and unpriced steps. Hue identifies activity; shade indicates relative cost. Scroll through large histories, filter by activity or agent, sort by time or cost, or jump to an index. Selecting a cell opens its token counts, unit prices, charges and recorded inputs, response and tools in a dialog. The viewport reads bounded metadata pages and renders only visible cells.
13
+
14
+ Tool categories attribute the model-call cost of the associated step; they do not invent a separate execution price for a file read or command. Native search charges remain separate recorded billing events. Shares always use the whole conversation's selected cost basis.
15
+
16
+ The host prepares recently viewed conversations in the background at startup and refreshes them after completed turns. Conversation entry buttons also prefetch usage totals and fee categories. Calculated fees and price-independent usage metadata survive restarts; saved results appear first while changed logs refresh silently. View switches, sorting and paging share one calculation, and categories can display before call totals finish loading. Changes to price rules, plan ownership or subagent inclusion recalculate from the metadata cache; changed logs are reread. Caches are bounded and contain no message bodies, tool arguments, results or credentials.
17
+
18
+ The step-cost share distribution groups many small steps into four ranges: below 0.1%, 0.1–1%, 1–5% and at least 5% of conversation costs. Each range shows step count and cumulative cost. Zero-cost and unpriced usage stay separate. Step details default to a global highest-cost-first ranking, with a trajectory-order option. Twenty rows are shown initially and more expand in place. Clicking a step opens a detail dialog. Category and agent dialogs list their steps by cost and show the selected call beside the list. Only that call’s recorded content is loaded; the close button remains visible while scrolling, and Escape returns to the underlying view. The individual-call section uses a highest-cost ranking with bars scaled to its largest call, alongside each amount and share of the whole conversation; remaining calls are summarized as text.
19
+
5
20
  Open a conversation and click **Cost details** in the same row as turns, speed, tokens and cache-hit statistics below its input box. **Settings → Cost → Display** has separate switches to hide the header entry, composer entry and turn cost summaries; all remain visible by default. The header entry automatically hides at viewport widths of 640px or less. The composer entry follows its own switch. Both buttons use compact 12px text. Budget chips take only their content width and no longer create an extra row. Cost badge visibility remains independent. From 1.8.13, **Amount only below the composer (full split on hover)** in the same Display tab condenses the conversation cost line to its amounts. Hover retains cache hit rate, input/cache/output tokens and model amounts; header badges and Cost details stay available. The conversation entry opens its entire retained history, shows API and Plan equivalents separately, uses the sidebar cost basis by default, and puts component details before overview charts. Switching conversations closes the previous dialog. For all conversations, open **Settings → Cost → Cost statistics**; this entry starts with the last seven calendar days, including today.
6
21
 
7
22
  - **Periods:** Today, Last 7 days, Last 30 days, All retained, and custom inclusive dates. Dates follow the host timezone shown on the page.
@@ -26,7 +41,9 @@ API costs are **estimates from reported usage and configured rates**, not provid
26
41
 
27
42
  With **Include subagents in session cost** enabled, the conversation badge, selected-conversation statistics and details include all continuous subagent descendants. The detail view lists each agent's recorded costs and identifies the owning conversation for every call, turn and step. Expanding a child turn reads that child's input and tools. Ordinary forks are excluded and inherited history is not billed twice. Disabling the setting limits the selection to the main conversation.
28
43
 
29
- Call details are reconstructed on demand from the selected conversations' available usage logs and native-search journals. They use call timestamps and the currently configured historical price rules, including peak/off-peak and long-context tiers. If prices changed or logs are incomplete, the page shows the stored amount and reconstructed amount separately. Missing logs and missing prices do not mean zero cost.
44
+ Call details use the price version recorded for the call time, including peak/off-peak and long-context tiers. Editing rates, mappings or price currency affects subsequent calls. Older installations keep their existing ledger amounts and use the pre-upgrade price configuration as the baseline for available call logs; prices that were never recorded cannot be recovered. Missing logs and missing prices do not mean zero cost.
45
+
46
+ **Settings → Cost → Prices → Historical pricing** offers explicit recalculation at current rates. It requires confirmation and only changes session/day records whose complete usage matches the ledger. Each run keeps before/after amounts, original price versions, and a full `.before-reprice-<timestamp>.json` ledger backup alongside the ledger. The settings show past recalculations and their original amounts. Model-price mapping selectors support provider/model keyword searches without changing the selection.
30
47
 
31
48
  Cache hit rate is `cacheRead / (input + cacheRead + cacheWrite)`. Token composition is a token-count share, not a cost share. Reported reasoning tokens can overlap output and are shown separately; the configured reasoning rate determines any additional charge.
32
49
 
@@ -34,6 +51,19 @@ The statistics screen uses DSH's package-local asynchronous module loader. Since
34
51
 
35
52
  ## 简体中文
36
53
 
54
+ ### 对话费用视图
55
+
56
+ 对话中的「费用明细」提供四种视图,使用同一份完整费用:
57
+
58
+ - **归类占比**:圆环图配合费用条,把所有代理的读取文件、本地检索、网页搜索、文件修改、命令执行、代理协作、压缩、模型回复及其他工具分别汇总。只按已记录的工具名称分类;同一步涉及多种用途时归入「多类工具」,费用只计一次。
59
+ - **矩形分布**(默认):大框显示用途,小框显示具体工具;每类费用最高的五种工具组合单列,其余合并为其他工具。切到「按代理」后,每个代理的大框内展示它自身的用途分类。面积按金额分配,点击类别标题放大,点击小框弹出对应调用的详细信息,不再用「其余多少步」代替分类。
60
+ - **父子归属**:占满面板宽度,按实际的子代理父子关系展开,显示费用、步数、调用次数、占父级和占对话的比例,点击名称弹出对应调用。代理合计包含后代;其下面的费用类别只统计自身调用。
61
+ - **步骤热力图**:每格对应一个计费步骤,零费用和未定价步骤也保留。颜色区分类别,深浅表示相对费用;支持滚动、类别与代理筛选、金额或轨迹排序,以及按序号定位。点击格子弹出该步 Token、单价、金额及已记录的输入、回复与工具信息。只读取当前区域所需的精简元数据,避免同时渲染数千行表格。
62
+
63
+ 工具分类统计的是关联步骤的模型调用费用,不为读取文件、执行命令另造单价。原生搜索独立计费记录继续单独计算。占比始终以当前口径下的整段对话费用为分母。
64
+
65
+ 「单步费用占比分布」把小费用归到低于 0.1%、0.1%–1%、1%–5% 和不低于 5% 四个区间,显示步数及累计金额。零费用和未定价记录单列。逐步费用明细默认按整段对话的金额从高到低排列,也可切回轨迹顺序;先显示 20 行,更多原位展开。点击步骤打开详情弹窗;点击类别或代理时,弹窗按金额排列其步骤,并在旁边显示选中调用。只读取选中调用的正文,关闭按钮始终可见,按 Escape 返回原视图。逐次调用区域用高额调用排名代替圆环图,横条相对最高单笔金额缩放,同时显示金额和占整段对话的比例;其余调用仅作文字合计。
66
+
37
67
  从 1.8.13 起,可在**设置 → 费用 → 显示**开启“**输入区下方只显示金额(悬停可见完整分项)**”。费用行只显示金额,悬停保留命中率、输入/缓存/输出 Token 与模型金额。API 和 Plan 等值继续使用当前展示口径,标题栏徽章及“费用明细”入口保持原有行为;默认关闭。
38
68
 
39
69
  打开一个会话,点击**输入框下方与轮数、速度、Token 和缓存命中率同一行的「费用明细」**。在 **设置 → 费用 → 显示设置** 中,可分别隐藏标题栏入口、输入框下方入口和每轮回复后的费用行;默认均保留。视口不超过 640px 时,标题栏入口自动隐藏,输入框下方入口继续遵守自己的开关。两个明细按钮使用 12px 字号和紧凑间距;预算标签仅占内容所需宽度,不再独占整行。关闭费用徽章不影响明细入口。对话入口默认显示该对话保留的全部历史,API 与 Plan 等值分别列出,默认金额口径跟随侧栏的“含 Plan 总额”设置,费用构成放在趋势图之前。切换会话会关闭旧明细。全部会话统计的入口为 **设置 → 费用 → 计费统计**,默认显示包含今天的近 7 个自然日。
@@ -58,12 +88,38 @@ The statistics screen uses DSH's package-local asynchronous module loader. Since
58
88
 
59
89
  API 费用是按上报用量和配置单价计算的估算,不是厂商账单;Plan 费用是订阅用量的 API 等值,不代表额外扣款。外部用量快照仍在原概览中单列,这个页面统计 DSH 自身账本。
60
90
 
61
- 逐次明细仅在进入某个对话时读取其用量日志和搜索记录,按调用时间套用当前配置中的历史价格规则,包括峰谷价和长上下文价。修改过价格或日志不完整时,页面同时显示账本金额与可用明细金额。缺少日志、缺少价格都不会被解释为免费。
91
+ 逐次明细使用调用时的价格版本,包括峰谷价和长上下文价。修改单价、模型映射或价格币种只影响后续调用。旧版升级时保留已有账本金额,并以升级前的价格配置作为可用调用日志的初始基准;此前没有保存的单价无法追回。缺少日志、缺少价格都不会被解释为免费。
92
+
93
+ 在“设置 → 费用 → 价格 → 历史费用”中,可选择“按当前价格重算历史”。确认前会显示警告,仅重算日志完整且用量与账本一致的会话日期记录。每次重算都保留前后金额、原价格版本,并在账本旁保存完整的 `.before-reprice-<时间戳>.json` 备份;设置中可以查看重算记录与原金额。模型价格映射下拉支持提供商和模型关键词搜索,筛选不会改变原选择。
62
94
 
63
95
  缓存命中率为 `缓存读取 / (未缓存输入 + 缓存读取 + 缓存写入)`。Token 构成展示数量占比,不是费用占比。推理 Token 可能包含在输出中,因此单独列示,不再次加入总 Token;是否另收推理费取决于配置的单价。
64
96
 
65
97
  统计页使用 DSH 的异步模块加载器。从 **1.8.2** 起,主客户端与统计模块使用各自的 Remote 注册标识;两部分组合加载的流程已通过真实 **0.1.7-rc.2** 和 **0.2.0-rc.2** 客户端 registry/gateway 验证。没有该能力的旧宿主会显示升级提示,原有计费和设置继续可用。两个客户端文件分别遵守 256 KiB 大小限制。
66
98
 
99
+ 宿主启动后在后台准备最近查看的会话,回合结束后更新对应结果;会话入口也会预加载费用总览和分类图。计费结果和独立于价格的精简用量缓存都可跨重启保留,先显示已有数据,再后台更新。分类图不必等调用汇总读完,切换视图、排序和翻页共用计算结果。确认重算、套餐归属或子代理开关改变后可利用用量缓存刷新视图,日志改变后才重新读取。缓存有容量限制,只保存计费字段,不保存对话正文、工具参数、返回内容或凭据。
100
+
101
+ ## Plugin compatibility / 插件兼容
102
+
103
+ ### 中文
104
+
105
+ 按截图中的版本核对了以下行为:
106
+
107
+ - **dsh-codex-ui 1.1.38:**费用明细入口和会话金额继续使用 DSH 的插槽。统计栏变宽时优先保留金额,Token、缓存和 Plan 明细可缩短,悬停查看完整信息。账本仍在加载或没有当前会话记录时显示对应状态,不再短暂显示投影金额后消失。
108
+ - **dsh-agency-agents 1.0.19:**专家通过 DSH 的标准子代理接口运行。开启“本会话费用包含子代理”即可包含专家及其后代,父账本不再次入账。普通分叉和继承的历史轮次不重复收费。
109
+ - **billion-context:**原版 0.1.197 仍只统计上报给 DSH 的用量;本地配套兼容包 `0.1.197-cost-meter.1` 已接入内部压缩、重试和追加模型请求,费用页显示采集状态和缺失回执。原用量不重复收费,未上报的未知费用不估补,详见[逐次计费说明](billion-context-billing.md)。
110
+
111
+ 仅安装其他插件不能证明它影响费用;兼容验证使用本地模拟接口和固定版本的实际代码,没有发起付费模型请求。
112
+
113
+ 版本源码:[dsh-codex-ui](https://github.com/MichengAI/dsh-codex-ui/tree/4f82059f4df415320917b572811b0b6440179ac9)、[dsh-agency-agents](https://github.com/MichengAI/dsh-agency-agents/tree/576eeec833b34554bc89d11f70076e3e1b9eb9cd)、[billion-context](https://github.com/ranxianglei/billion-context/tree/3aeddc160864ca774e54817559d6984310e2a9ab)。
114
+
115
+ ### English
116
+
117
+ - **dsh-codex-ui 1.1.38:** the entries use DSH slots. Composer statistics preserve the session amount while trimming secondary details, which remain available on hover. Loading and missing-ledger states stay visible without flashing a projection amount first.
118
+ - **dsh-agency-agents 1.0.19:** experts use the standard DSH subagent interface. Enable subagent costs to include their descendants once. Ordinary forks and inherited turns are excluded from duplicate billing.
119
+ - **billion-context:** the original 0.1.197 build exposes only its reported DSH usage. The paired local `0.1.197-cost-meter.1` build records internal compression, retries and additional model requests without charging the original host usage twice. Coverage and missing receipts remain visible; see the [request billing guide](billion-context-billing.md).
120
+
121
+ Verification uses local synthetic endpoints and the pinned upstream code. No paid model request is made.
122
+
67
123
  ## Design references
68
124
 
69
125
  The organization of summary statistics, time ranges, conversation drill-down and on-demand details was informed by [dsh-context v0.62.0](https://github.com/bowenliang123/dsh-context/tree/v0.62.0), especially its [overview](https://github.com/bowenliang123/dsh-context/blob/v0.62.0/src/client/overview.ts) and [detail loading](https://github.com/bowenliang123/dsh-context/blob/v0.62.0/src/client/timelineSource.ts). This implementation uses dsh-cost-meter's existing ledger and pricing engine with its own layout.
@@ -0,0 +1,74 @@
1
+ # billion-context request billing / 逐次请求计费
2
+
3
+ ## English
4
+
5
+ The metering bridge supports **billion-context 0.1.181 or later** through a paired compatibility build. Release numbers are not an allowlist: the generator inspects the actual proxy and native transport contracts and automatically accepts unchanged interfaces, including later versions. Runtime hashes record provenance rather than block other releases. Original authorship and licenses are retained.
6
+
7
+ **0.1.180 and earlier:** an enabled plugin is detected through DSH's plugin manager, and a popup asks the user to upgrade to **0.1.181 or later**. Incompatible metering interfaces also produce a popup with **Community group** and **Open an issue** links. The group link opens this project's existing WeChat group section. Acknowledging a notice suppresses repeats for the same version and reason; a new problem can prompt again. A temporary transport failure alone is not classified as an interface change.
8
+
9
+ ### What it records
10
+
11
+ - Every consumed upstream request, including compression, HTTP retries and additional model rounds.
12
+ - Uncached input, cache reads, cache writes, output and reasoning usage across OpenAI Chat Completions, Responses, Anthropic Messages and Google GenerateContent, including streams.
13
+ - Actual upstream origin/model, request identity, attempt, completion status, owning DSH conversation and active turn/step.
14
+ - Zero usage, missing usage, partial responses and missing prices remain distinct. Charges are not guessed from savings percentages, balance movement or estimated context size.
15
+
16
+ After durable proxy records are confirmed, those individual requests replace the corresponding ordinary DSH usage charge. Producer sequences and ledger receipts are committed together. Main/subagent totals, daily/week/all statistics, turn details and step views share these records and historical price versions. Inherited fork history is not charged again.
17
+
18
+ Main requests retain the configured DSH provider price. Internal models use their actual upstream/model. The bridge observes existing responses, preserves the request body and upstream credentials, and removes the private correlation header before forwarding to a model endpoint.
19
+
20
+ Prebuilt archives for the five verified versions are available in the [v1.8.27 release assets](https://github.com/Han-1413141/dsh-cost-meter/releases/tag/v1.8.27).
21
+
22
+ ### Generate and install the matching archive
23
+
24
+ The generator automatically adapts supported interfaces without executing the original package. It does not rewrite the source archive. Build from the original package for the version being installed:
25
+
26
+ ```powershell
27
+ npm pack billion-context --ignore-scripts
28
+ node scripts/build-billion-context-compat.mjs <original-billion-context.tgz> <local-output-directory>
29
+ ```
30
+
31
+ The output version is `<upstream-version>-cost-meter.1` (for example, `0.1.197-cost-meter.1`). Install it alongside dsh-cost-meter 1.8.27 or later in the DSH profile already using billion-context, then fully restart the host. After updating the original plugin, generate and install a matching compatibility archive. A stock package without the metering bridge does not expose all internal calls merely because its version is newer.
32
+
33
+ The generator supports both observed native fetch implementations and optional summary helpers. Changed required contracts stop generation with feedback links. Runtime protocol mismatches or an unconnected bridge are surfaced in the popup; ordinary DSH billing remains available.
34
+
35
+ ### Storage and verification
36
+
37
+ Only billing metadata is saved under `<ledger>.billion-context`: no prompts, returned text, tool payloads, request headers or credentials. Restore persisted receipts together with a ledger backup. Producer and host must share local files; remote proxies and missing historical records are outside this bridge's coverage.
38
+
39
+ Actual npm releases **0.1.181, 0.1.185, 0.1.190, 0.1.196 and 0.1.197** were verified with their native interceptor, retry and summary implementations. Checks cover four protocols, cache buckets, API/Plan, concurrent agents, replay, restart, cancellation, incomplete usage and storage failures. Future-version acceptance and changed-contract rejection use separate synthetic fixtures. Browser checks cover upgrade and compatibility notices, feedback links and dismissal. No paid model calls are made.
40
+
41
+ ## 中文
42
+
43
+ ### 支持范围与自动兼容
44
+
45
+ 完整内部计费从 **billion-context 0.1.181** 起接入,需要配套计费兼容包。生成器检查代理请求、摘要重试和原生请求拦截的实际接口,**不再锁定 0.1.197 或固定文件校验值**。后续版本保留相同接口时自动通过检查并生成兼容包,原作者、许可证、原始版本及文件校验值继续保留。
46
+
47
+ 检测到启用中的 **0.1.180 及更早版本**时,弹窗提示升级到 **0.1.181 或更新版本**。计费接口变化或兼容桥未连接时也会显示相应提醒,提供:
48
+
49
+ - **加入交流群**:跳转到本项目现有的[微信交流群入口](../README.zh-CN.md#交流与反馈)。
50
+ - **提交 issue**:打开本项目的问题反馈模板。
51
+
52
+ 关闭后,同一版本、同一问题不会反复弹窗;出现新的兼容问题时重新提醒。临时超时或请求取消不被直接判为接口变化。反馈时请附 billion-context、费用插件和 DSH 的版本。
53
+
54
+ ### 统计内容
55
+
56
+ 逐次记录内部压缩、HTTP 重试和追加请求;支持 OpenAI Chat Completions、Responses、Anthropic Messages、Google GenerateContent 的 JSON 与流式回执。未缓存输入、缓存读写、输出和推理 Token 分开保存,保留实际上游、模型、重试次数、完成状态、会话和轮次/步骤。
57
+
58
+ 代理用量成功写入后,逐次记录替换对应的普通 DSH 用量,避免双计。调用序号和账本凭据原子保存,防止重启、重复读取和并发导入再次收费。会话金额、子代理、日/周/全部统计、单轮和步骤明细共用记录,分叉继承的历史不重复计费,并沿用保存的历史价格版本。
59
+
60
+ 主请求沿用 DSH 渠道配置价格;内部模型按实际上游和模型匹配。零用量、缺失用量、部分回执和未定价明确区分,不按节省比例、余额差或估算上下文补算费用。关联标识在转发模型端点前删除,不改变请求正文和上游凭据。
61
+
62
+ 五个已验证版本的预编译兼容包见 [v1.8.27 发布附件](https://github.com/Han-1413141/dsh-cost-meter/releases/tag/v1.8.27)。
63
+
64
+ ### 使用方法
65
+
66
+ 先取得所用版本的原始 npm 包,再运行上面的生成命令。生成结果按原始版本命名为 `<原版本>-cost-meter.1`,与费用插件 1.8.27 或更新版本一起安装到已使用 billion-context 的 DSH Profile,然后完全重启宿主。
67
+
68
+ **升级原插件后,需要为新版本生成并安装对应兼容包。**生成器会自动判断接口兼容性;仅升级原版包不能获得完整内部调用记录。必需接口变化时停止生成并给出反馈入口,运行期间的协议不匹配或未连接状态通过弹窗提示。
69
+
70
+ 计费数据保存在 `<ledger>.billion-context`,只含计费字段,不保存正文、工具内容、请求头或密钥。代理与宿主需要共享本地文件;远程代理及启用前缺失的内部记录无法通过此桥补齐。恢复账本时同时保留入账凭据。
71
+
72
+ ### 验证
73
+
74
+ 已用 **0.1.181、0.1.185、0.1.190、0.1.196、0.1.197** 的实际 npm 发布包验证原生拦截、摘要、重试、四种协议、API/Plan、并发子代理、历史回放、重启去重、取消、缺失回执和写入失败。未来版本自动接入与接口变化拒绝另用模拟代码验证;浏览器验证升级提醒、兼容提醒、群与 issue 链接及关闭去重。测试没有调用付费模型。
@@ -0,0 +1,66 @@
1
+ # OpenDesign billing and quota / 计费与额度
2
+
3
+ ## English
4
+
5
+ This release addresses [#274](https://github.com/Han-1413141/dsh-cost-meter/issues/274), requested by @playgithub. It adds an OpenDesign price channel and read-only workspace quota queries; it is included in version 1.8.27. It does not install OpenDesign, create an account or change a model route.
6
+
7
+ ### Conversation costs
8
+
9
+ - The offline catalog contains 35 token-priced models checked on **2026-10-15**, from the [official public API](https://amr-api.open-design.ai/api/v1/public/model-prices). Prices are **USD per 1M tokens**, with cache read/write rates and long-context tiers where provided. The long tier applies to the entire request only above its input threshold, including cached input.
10
+ - Provider IDs `opendesign`, `open-design`, `open-design-api` and `amr-link.open-design.ai`, including DSH's `llm-` prefix, use this separate catalog. A custom price under the original alias takes priority. Other provider IDs can use the existing explicit price mapping and plan-assignment controls.
11
+ - OpenDesign prices never serve as fallback prices for another provider. Unknown OpenDesign models stay unpriced; the plugin does not borrow a direct-vendor price.
12
+ - **Settings → Cost → Prices → Sync official prices** also refreshes the public OpenDesign catalog. A used/enabled OpenDesign channel refreshes at startup and hourly. No key or model request is needed. User-edited prices and removed models stay intact. Saved price versions preserve existing details when rates change; recalculation is explicit and retains the original amounts. A historical price version that was never captured cannot be reconstructed.
13
+
14
+ OpenDesign uses shared subscription allowances and can fall back to its wallet; see its [model-credit rules](https://open-design.ai/model-credits/). Calls default to **Plan-equivalent cost**, which is not a subscription payment or a cash bill. Set wallet-funded calls to **API** in the billing-classification controls, or assign individual models explicitly. DSH's standard usage response does not identify each request's funding source, account-specific discount, image charge or automatic top-up. Those amounts are not invented from the list price or balance movement.
15
+
16
+ ### Quota queries
17
+
18
+ 1. Open **Settings → Cost → Quotas**, find **OpenDesign**, and expand its settings.
19
+ 2. Enter the exact **workspace ID** from your OpenDesign Cloud workspace.
20
+ 3. Configure a **Control Key** in the credential editor, or supply `OPENDESIGN_CONTROL_KEY` / `VELA_CONTROL_KEY` to the DSH host. An inference key from the Cloud API Keys page is a different credential and cannot be used for this query. The existing OpenDesign/Vela login keeps control credentials in its own profile; the plugin does not read or rewrite that profile automatically.
21
+ 4. Enable the card and refresh. Select its location to also show it in the sidebar or quota strip.
22
+
23
+ The host issues only these authenticated GET requests to the fixed official HTTPS origin:
24
+
25
+ ```text
26
+ https://amr-api.open-design.ai/api/v1/workspaces/{workspaceId}/billing/coding-plan-usage
27
+ https://amr-api.open-design.ai/api/v1/workspaces/{workspaceId}/wallet/balance
28
+ ```
29
+
30
+ Quota and wallet responses must match the requested workspace. The wallet must identify its member; if the quota response provides a member identity, both must match. Credentials are never forwarded through a redirect. They use the existing DSH credential store and are excluded from the ledger and client snapshot.
31
+
32
+ Each returned allowance window has its own used percentage and reset time. Simultaneous windows are not added together or called unlimited. Wallet credit remains a separate USD-equivalent value, including a real zero. Invalid, unauthorized or missing responses show an error/unavailable state, never a fabricated zero allowance. The workspace setting is kept across restarts and invalidates the previous query when changed.
33
+
34
+ ### Evidence and limits
35
+
36
+ The public catalog was fetched without authentication. The authenticated adapter and bilingual settings were verified with synthetic responses, including large credit counts, zero balances, mismatched identities, authorization failure and price-refresh persistence. **No live account query or paid model request was made.** Production Control Key permissions and response availability still require a configured account.
37
+
38
+ Endpoint provenance: the official Cloud bundles `cloud-root-B21Emo2w.js` and `pricing-refund-policy-BDFJHl33.js` served on 2026-10-15; the [workspace-wallet contract](https://github.com/nexu-io/open-design/blob/7abd6fc2b11987c3940eb4ffc461478ff37c0b33/packages/contracts/src/api/collab.ts) and [Vela billing adapter](https://github.com/nexu-io/open-design/blob/7abd6fc2b11987c3940eb4ffc461478ff37c0b33/apps/daemon/src/integrations/vela-billing.ts) at the inspected commit. The [official guide](https://open-design.ai/zh/model-credits/) explicitly lists DSH as a supported API client; the issue has a usable integration request. Its short promotional wording alone does not establish advertising or spam.
39
+
40
+ ## 中文
41
+
42
+ 本版本实现了 @playgithub 在 [#274](https://github.com/Han-1413141/dsh-cost-meter/issues/274) 提出的接入需求,随 1.8.27 发布。不会安装 OpenDesign、注册账户或改变模型路由。
43
+
44
+ ### 会话计费
45
+
46
+ - 从[官方公开价表](https://amr-api.open-design.ai/api/v1/public/model-prices)加入 **35 个模型**,核对日期为 **2026-10-15**。单位为 **美元/百万 Token**,包含已公布的缓存读取、缓存写入和长上下文价格。超过输入阈值后,整次请求使用长档,输入阈值包含缓存输入。
47
+ - `opendesign`、`open-design`、`open-design-api`、`amr-link.open-design.ai` 及其 `llm-` 前缀使用独立目录;原渠道中手工配置的价格优先。其他自定义名称可通过既有价格映射和套餐归属入口关联。
48
+ - 未收录的 OpenDesign 模型标为未定价,不借用直连厂商价格;其他渠道也不会使用 OpenDesign 价作为兜底。
49
+ - **设置 → 费用 → 价格 → 同步官方价格**会同步公开目录。已使用或开启 OpenDesign 时,启动和每小时也会刷新;不需要密钥,不调用模型。自定义价格、取消挂载和已保存价格版本的历史明细保留。历史重算需要主动确认并保留原金额;未保存过的历史价格版本无法还原。
50
+
51
+ OpenDesign 的 API 与客户端共用套餐,套餐用尽后可以继续扣钱包,详见[官方额度规则](https://open-design.ai/zh/model-credits/)。因此默认计入 **Plan 等值费用**,不把额度当成现金支出。钱包付款可在计费分类中设为 **API**,也可逐模型配置。DSH 的标准用量回执没有逐次扣款来源、账户折扣、图片费用或自动充值金额,这些金额不会通过公开单价或余额变化猜算。
52
+
53
+ ### 额度查询
54
+
55
+ 1. 在 **设置 → 费用 → 额度**找到并展开 **OpenDesign**。
56
+ 2. 填入 OpenDesign Cloud 中对应的**工作区 ID**。
57
+ 3. 在凭据编辑器中配置 **Control Key**,或向 DSH 宿主提供 `OPENDESIGN_CONTROL_KEY` / `VELA_CONTROL_KEY`。Cloud API Keys 页生成的推理密钥与查询凭据不同,不能混用。已有 OpenDesign/Vela 登录将控制端凭据保存在其自身配置中,本插件不会自动读取或修改那个配置。
58
+ 4. 开启并刷新,可选择在侧栏或额度横条显示。
59
+
60
+ 查询只访问上文列出的固定官方 HTTPS GET 端点;核对工作区,钱包必须提供成员身份,额度响应提供成员身份时再核对二者一致。凭据由 DSH 凭据库管理,不回显、不写入账本,不跟随重定向。
61
+
62
+ 所有实际返回的窗口分别显示已用百分比和重置时间,不相加、不标成无限。钱包作为独立的美元等值额度显示,真实零余额保留。认证失败、缺失回执或身份不匹配显示不可用,不显示虚构的零额度。工作区配置跨重启保留,改变后清理原查询缓存。
63
+
64
+ 公开价表已经直接读取;认证查询与中英文设置使用模拟数据验证,覆盖大整数、零余额、串工作区/成员、认证失败、价格持久化等情况。**没有真实账户验证,没有调用付费模型。**真实账户的 Control Key 权限与服务端响应需要在配置后核对。
65
+
66
+ 官方明确支持 DSH,说明这条 issue 有可执行的接入需求;仅凭“便宜、可能流行”的一句话,不能认定为广告。
@@ -1,16 +1,22 @@
1
1
  # 2026-10 模型价格目录与渠道选择 / Model pricing and routes
2
2
 
3
- 核对日期 / Checked: 2026-10-03
3
+ 核对日期 / Checked: 2026-10-15
4
4
 
5
5
  ## 中文
6
6
 
7
- 本次针对 #224 补齐 GPT-6 Sol/Luna、GPT-6.1 Sol、Gemini 3.8 Flash、Claude Fable 5.1、Opus 5.5 等模型,并按公开价格页面扩充其他模型。内置第三方目录包含 271 个「厂商 / 模型」条目、179 个不同模型 ID(含官方别名和历史快照 ID);其中 269 条有可执行价格,2 条明确未核价。DeepSeek 主表单独保留。OpenRouter 仍在启动、手动同步及每小时从公开目录补充本渠道模型,静态目录的数量不是在线目录的上限。
7
+ 此前针对 #224 补齐 GPT-6 Sol/Luna、GPT-6.1 Sol、Gemini 3.8 Flash、Claude Fable 5.1、Opus 5.5 等模型,并按公开价格页面扩充其他模型。内置第三方目录包含 290 个「厂商 / 模型」条目、191 个不同模型 ID(含官方别名和历史快照 ID);其中 288 条有可执行价格,2 条明确未核价。DeepSeek 主表单独保留。OpenRouter 仍在启动、手动同步及每小时从公开目录补充本渠道模型,静态目录的数量不是在线目录的上限。
8
+
9
+ ### 10 月 15 日更新
10
+
11
+ 新增 19 条渠道价格、12 个不同模型 ID:Claude Haiku 5.5、Gemini 4 Argon / Contributor、Mistral Large 4、GPT-5.6 Cyber、GPT-Rosalind Research / Discovery,以及 Zen / Go 的新增端点。直连 Sonnet 5.5 缓存读为 $0.10,Zen 为 $0.20;GPT-6.1 Sol 则直连缓存读 $0.10,Zen $0.20,长上下文分别翻倍。
12
+
13
+ Haiku 5.5 按 100,000 输入 Token 分档,缓存读取和写入也计入阈值,超过后整次请求切换价档。Gemini 4 Argon 直连促销到 2026-11-30,之后公布价翻倍;官方没有标明切换时区,条目保留当前价和到期说明,不猜测切换时刻。Mistral Large 4 采用当前公开五折价,官方未给结束日。专项模型写入价格目录不代表账户取得调用权限。
8
14
 
9
15
  ### 先选渠道,再选模型
10
16
 
11
17
  - `openai`、`anthropic`、`google`、`xai`、`mistral`、`z-ai` 使用各自直接 API 的价格。已知厂商不会自动套用另一厂商的模型价
12
- - `opencode-zen` 是本次明确区分的 **Zen 按量渠道**,覆盖核对当天端点表全部 83 个模型
13
- - `opencode-go` 使用 **Go 订阅参考价**,覆盖全部 30 个模型;这些价格用于额度和等值费用估算,不代表每次请求额外扣款
18
+ - `opencode-zen` 是本次明确区分的 **Zen 按量渠道**,覆盖核对当天端点表全部 87 个模型(另外保留 4 个历史 ID)
19
+ - `opencode-go` 使用 **Go 订阅参考价**,覆盖全部 32 个模型(另外保留 3 个历史 ID);这些价格用于额度和等值费用估算,不代表每次请求额外扣款
14
20
  - 为兼容本项目历史宿主配置,`zen` / `opencode` 仍按 Go 别名处理;用户在原渠道手写的价格条目及显式映射优先。按量 Zen 请选择 `opencode-zen` 的价格条目,不要依靠历史别名猜测。这是价格渠道键,不会创建宿主推理 Provider;宿主仍使用历史名字时,可显式映射到 `opencode-zen:<模型 ID>`,并把该宿主模型的 Plan/API 分类指定为 API。模型级 Plan/API 覆盖仍优先于自动分类
15
21
  - 缺失渠道的旧宿主兼容推断只保留旧 Go 模型集合,并且要求该模型仍在 Go 渠道表中。新增目录条目不会仅因同名就把 API 消费变成订阅
16
22
  - `openrouter` 使用完整模型 ID 精确匹配。`:free` / `:online` 等变体、其他路由及本地模型不会借用其价格
@@ -38,9 +44,9 @@
38
44
 
39
45
  ## English
40
46
 
41
- The third-party catalog now contains 271 provider/model entries and 179 distinct model IDs, including official aliases and dated snapshots: 269 executable prices and 2 explicitly unpriced entries. The separate DeepSeek table remains intact. OpenRouter continues its existing public-directory refresh at startup, on manual sync and hourly.
47
+ The third-party catalog now contains 290 provider/model entries and 191 distinct model IDs, including official aliases and dated snapshots: 288 executable prices and 2 explicitly unpriced entries. The separate DeepSeek table remains intact. OpenRouter continues its existing public-directory refresh at startup, on manual sync and hourly.
42
48
 
43
- Use direct vendor IDs for their own API prices, `opencode-zen` for all 83 published Zen PAYG endpoints, and `opencode-go` for all 30 published Go subscription-reference endpoints. Historical host IDs `zen` / `opencode` retain their Go meaning; manually entered prices and explicit mappings win. These are pricing keys, not newly registered inference providers. If a PAYG host uses a historical name, explicitly map its model to `opencode-zen:<model ID>` and set that host model’s Plan/API class to API. A model-level Plan/API override remains authoritative. Catalog growth does not infer new subscription usage from a bare model name.
49
+ Use direct vendor IDs for their own API prices, `opencode-zen` for all 87 currently published Zen PAYG endpoints, and `opencode-go` for all 32 currently published Go subscription-reference endpoints. Historical host IDs `zen` / `opencode` retain their Go meaning; manually entered prices and explicit mappings win. These are pricing keys, not newly registered inference providers. If a PAYG host uses a historical name, explicitly map its model to `opencode-zen:<model ID>` and set that host model’s Plan/API class to API. A model-level Plan/API override remains authoritative. Catalog growth does not infer new subscription usage from a bare model name.
44
50
 
45
51
  Prices are USD per million tokens. Cache reads/writes and per-request context tiers are separate. OpenAI thresholds count complete input, including cached tokens; xAI's direct 200K boundary is inclusive while Zen's is exclusive. Claude generic cache writes use the published 5-minute tier; 1-hour TTL, Gemini cache storage charged per token-hour, modality-specific prices, tool fees and special processing tiers need separate accounting. Go's DeepSeek tiers use its UTC weekday schedule, not direct DeepSeek's Beijing holiday calendar.
46
52
 
@@ -54,9 +60,9 @@ The one-time upgrade preserves custom prices, supported TTL fields, explicit unp
54
60
  - [xAI API prices](https://docs.x.ai/developers/pricing)
55
61
  - [Mistral API prices](https://docs.mistral.ai/inference/pricing) and per-model alias pages
56
62
  - [Z.ai API prices](https://docs.z.ai/guides/overview/pricing)
57
- - [OpenCode Zen](https://opencode.ai/docs/zen), [OpenCode Go](https://opencode.ai/docs/go)
63
+ - [OpenCode Zen](https://opencode.ai/v2/docs/console/models/), [OpenCode Go](https://opencode.ai/v2/docs/console/go/)
58
64
  - [OpenRouter public model directory](https://openrouter.ai/api/v1/models)
59
65
 
60
66
  Every new source-backed row includes `sourceUrl` and `checkedAt`. [`provider-pricing.json`](provider-pricing.json) is generated from executable code. Run `node test/check-opencode-catalog.mjs` to compare the complete current Zen/Go public endpoint and price tables, including free rows, cache writes, context tiers and peak/off-peak rows. This read-only check uses no account credentials or paid inference calls.
61
67
 
62
- Captured primary endpoint/price rows are checked offline in the full regression suite: [`opencode-pricing-2026-10-03.json`](../test/fixtures/opencode-pricing-2026-10-03.json). The standalone checker can also reread the live primary pages.
68
+ Captured primary endpoint/price rows are checked offline in the full regression suite: [`opencode-pricing-2026-10-15.json`](../test/fixtures/opencode-pricing-2026-10-15.json). The standalone checker can also reread the live primary pages.