dshgo-context-panel 0.1.0 → 0.1.2

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.
package/README.en.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  A standalone DSH plugin that shows context occupancy, breakdown, trends, tool/file activity, events, compaction history, and the live session fleet in both dsh-Go's native UI and DSH Web. Both routes share `lib/collect.js` and `contextData()`; the read-only `dsh-Go` reference repository is not modified.
4
4
 
5
+ ## Screenshots
6
+
7
+ Overview highlights context occupancy and remaining capacity; Trend shows model-call usage; More groups tools, files, events, compaction, and the session fleet.
8
+
9
+ ### Light theme
10
+
11
+ ![Go native light theme: Overview, Trend, and Fleet](https://raw.githubusercontent.com/LingMowen/dshgo-context-panel/26042c4bc65761c46356415844a92aa3dc8eeaba/preview/native-round-20261201-1796102785850/native-overview-trend-fleet-light.png)
12
+
13
+ ### Dark theme
14
+
15
+ ![Go native dark theme: Overview, Trend, and Fleet](https://raw.githubusercontent.com/LingMowen/dshgo-context-panel/26042c4bc65761c46356415844a92aa3dc8eeaba/preview/native-round-20261201-1796102785850/native-overview-trend-fleet-dark.png)
16
+
17
+ These screenshots use fixture data rendered offline by the actual Flutter `PluginView`, showing the current compact native layout. Physical-device and connected-host interactions remain unverified.
18
+
5
19
  ## Features
6
20
 
7
21
  - Composer strip: a compact status line such as `Context 63% · 632k/1M`, clipped to 24 Unicode code points.
@@ -37,9 +51,23 @@ The native entry appears in chat details and All features. The Web entry is the
37
51
  | `archiveEnabled` | `false` | must be explicitly `true` to write files |
38
52
  | `archivePath` | `''` | required absolute path when archive is enabled; no default location |
39
53
  | `promptPrefix` / `promptSuffix` | `''` | blank values register nothing; nonblank values stay literal |
54
+ | `pricingPeak` | `'auto'` | `'auto'`, `'peak'` or `'offpeak'`; auto picks the rate from each call's timestamp |
55
+ | `pricingCurrency` | `'USD'` | three-letter currency code; the shipped table is quoted in USD per 1M tokens |
56
+ | `pricingModels` | `{}` | price overrides `{ '<model prefix>': { cacheHit, cacheMiss, output } }`, each a number or `[offPeak, peak]` |
40
57
 
41
58
  Native sorting and granularity are session-scoped. Web query choices are request-scoped and cannot mutate native defaults or leak between chats.
42
59
 
60
+ ### Usage cost estimate
61
+
62
+ With the local archive enabled, **More → Fleet** groups observed calls by model and estimates cost: a 7-day total, four or five per-model rows, and the price source.
63
+
64
+ - The shipped table covers 10 vendors (DeepSeek, OpenAI, Anthropic, Google, Qwen/Alibaba, Mistral, Moonshot, MiniMax, xAI, Zhipu) with 167 rows, quoted in USD per 1M tokens.
65
+ - DeepSeek uses its published peak/off-peak pair: UTC 01:00–04:00 and 06:00–10:00 on weekdays are peak, every other hour is off-peak (half price). Other vendors have a single rate.
66
+ - Cached input is charged at `cacheHit`, the rest of the input at `cacheMiss`, and output separately; cached tokens above the input total are capped at the input.
67
+ - Models outside the table show as unpriced instead of being guessed; older records without a model id fall into an “Unknown model” row.
68
+ - The archive gains only a model id (clipped to 64 code points) plus numeric usage — never prompts, tool arguments or message text.
69
+ - Numbers are estimates, not a bill. The provider's invoice wins.
70
+
43
71
  ### Archive concurrency and recovery
44
72
 
45
73
  The archive uses an absolute path, an 8 MiB read bound, temporary-file + `rename` replacement, and a short `.lock` lease. A writer waits for other locks; if it sees a live lock or an abandoned lock it **never unlinks it automatically**. It preserves the lock and reports `ARCHIVE_BUSY` or `ARCHIVE_ABANDONED`. After all writers have stopped, an operator can remove the lock file and retry. This conservative recovery avoids a check-then-unlink race that could admit two writers.
@@ -50,6 +78,7 @@ The archive uses an absolute path, an 8 MiB read bound, temporary-file + `rename
50
78
  - Missing `contextBreakdown` buckets remain unknown; a computable pressure difference is shown separately as unclassified rather than falsely labelled free space.
51
79
  - File ranking keeps only recognized path summaries and line counts; displayed text is clipped by `maxCommandChars`.
52
80
  - Archive summaries are explicitly “observed calls”, not a full historical ledger; cache totals include only cache fields actually supplied by the source.
81
+ - The archive also keeps a model id (clipped to 64 code points) so costs can be grouped by model; it is an identifier, never message content.
53
82
 
54
83
  ## Layout
55
84
 
package/README.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  独立的 DSH 插件:在 dsh-Go 原生界面和 DSH Web 中展示当前会话的上下文占用、分区、趋势、工具/文件活动、事件、压缩历史和多会话编队。两条界面路线共用 `lib/collect.js` 与 `contextData()`,不修改只读参考仓库 `dsh-Go`。
4
4
 
5
+ ## 界面截图
6
+
7
+ 概览突出上下文占用与剩余容量;趋势展示调用用量;「更多」收纳工具、文件、事件、压缩和多会话编队。
8
+
9
+ ### 浅色主题
10
+
11
+ ![Go 原生浅色界面:概览、趋势与编队](https://raw.githubusercontent.com/LingMowen/dshgo-context-panel/26042c4bc65761c46356415844a92aa3dc8eeaba/preview/native-round-20261201-1796102785850/native-overview-trend-fleet-light.png)
12
+
13
+ ### 深色主题
14
+
15
+ ![Go 原生深色界面:概览、趋势与编队](https://raw.githubusercontent.com/LingMowen/dshgo-context-panel/26042c4bc65761c46356415844a92aa3dc8eeaba/preview/native-round-20261201-1796102785850/native-overview-trend-fleet-dark.png)
16
+
17
+ 截图由实际 Flutter `PluginView` 使用示例数据离线渲染,展示当前紧凑原生布局;实体手机与连接宿主的交互仍待验证。
18
+
5
19
  ## 能力
6
20
 
7
21
  - composer strip:短状态条,例如 `上下文 63% · 632k/1M`,最多 24 个 Unicode 码点。
@@ -37,9 +51,23 @@ dsh --profile web --port 6993 --no-open
37
51
  | `archiveEnabled` | `false` | 必须显式为 `true` 才落盘 |
38
52
  | `archivePath` | `''` | 归档启用时必须是绝对路径;没有默认落点 |
39
53
  | `promptPrefix` / `promptSuffix` | `''` | 空白不注册;非空按字面量注入 |
54
+ | `pricingPeak` | `'auto'` | `'auto'` / `'peak'` / `'offpeak'`;按调用时刻自动区分峰谷,或固定一档 |
55
+ | `pricingCurrency` | `'USD'` | 三位货币代码;内置价目本身以 USD / 1M tokens 计 |
56
+ | `pricingModels` | `{}` | 价目覆盖:`{ '<模型前缀>': { cacheHit, cacheMiss, output } }`,字段为数字或 `[谷时, 峰时]` |
40
57
 
41
58
  原生排序和粒度偏好按 session 隔离;Web 查询参数是请求级的,不会改写原生偏好,也不会泄漏到其他会话。
42
59
 
60
+ ### 用量计费估算
61
+
62
+ 开启本地归档后,「更多 → 编队」会按模型汇总并估算费用:7 天总额、按模型四至五行明细,以及价目来源说明。
63
+
64
+ - 内置价目覆盖 10 家厂商(DeepSeek、OpenAI、Anthropic、Google、Qwen/Alibaba、Mistral、Moonshot、MiniMax、xAI、Zhipu),共 167 条,单位是 USD / 1M tokens。
65
+ - DeepSeek 使用官方峰谷两档价:峰时为 UTC 01:00–04:00 与 06:00–10:00 的工作日,其余时段为谷时(半价)。其他厂商只有一档价。
66
+ - 缓存命中部分按 `cacheHit` 计价,其余输入按 `cacheMiss`,输出单独计价;缓存 token 多于输入时按输入封顶。
67
+ - 未收录模型标为「未计价」,不会猜价;没有模型标识的旧记录归入「未知模型」一行。
68
+ - 归档只多存一个模型标识(截断 64 码点)与数值用量,不含提示词、工具参数或对话正文。
69
+ - 结果是估算,不是账单;实际扣费以服务商账单为准。
70
+
43
71
  ### 归档并发恢复
44
72
 
45
73
  归档使用绝对路径、8 MiB 读取上限、临时文件 + `rename` 原子替换和短时 `.lock`。归档写者遇到其他锁会等待;遇到存活锁或检测到已废弃锁时**不会自动删除**,而是保留锁并报告 `ARCHIVE_BUSY` 或 `ARCHIVE_ABANDONED`。确认没有其他写者后,再由运维手工删除对应 `.lock` 并重试,避免检查后删除造成双写者。
@@ -50,6 +78,7 @@ dsh --profile web --port 6993 --no-open
50
78
  - `contextBreakdown` 缺失桶显示未知;可计算的压力差额单列为「未分类」,不能误报成空闲。
51
79
  - 文件排行只保留识别到的路径摘要和行数;显示文案按 `maxCommandChars` 裁剪。
52
80
  - 归档洞察写明「观察到的调用」,不是全历史账本;缓存值仅统计数据中实际提供的 cache 字段。
81
+ - 归档额外保留模型标识(截断 64 码点)用于按模型计价;它是标识,不是对话内容。
53
82
 
54
83
  ## 目录与职责
55
84
 
package/lib/archive.js CHANGED
@@ -5,12 +5,21 @@ import { createHash, randomUUID } from 'node:crypto'
5
5
  import { normalizeConfig } from './config.js'
6
6
  import { usagePoints } from './collect.js'
7
7
  import { acquireArchiveLock } from './archive-lock.js'
8
+ import { estimateCost, mergePrices } from './pricing.js'
9
+ import { PRICE_SOURCE } from './prices.js'
8
10
  const DAY = 86400000
9
11
  const MAX_BYTES = 8 * 1024 * 1024
12
+ const MODEL_CHARS = 64
10
13
  const hash = (text) => createHash('sha256').update(text).digest('hex')
11
14
  const numeric = (n) => Number.isSafeInteger(n) && n >= 0
15
+ // Model ids are the only text kept: clipped to 64 code points, never a payload.
16
+ const modelName = (value) => {
17
+ if (typeof value !== 'string') return undefined
18
+ const name = [...value.trim()].slice(0, MODEL_CHARS).join('')
19
+ return name.length > 0 ? name : undefined
20
+ }
12
21
  function valid(row) {
13
- return row && /^[a-f0-9]{64}$/.test(row.key) && /^[a-f0-9]{64}$/.test(row.session) && Number.isSafeInteger(row.at) && row.at > 0 && ['input', 'output', 'cacheRead'].every((k) => numeric(row[k])) && typeof row.committed === 'boolean'
22
+ return row && /^[a-f0-9]{64}$/.test(row.key) && /^[a-f0-9]{64}$/.test(row.session) && Number.isSafeInteger(row.at) && row.at > 0 && ['input', 'output', 'cacheRead'].every((k) => numeric(row[k])) && typeof row.committed === 'boolean' && (row.model === undefined || (typeof row.model === 'string' && row.model.length > 0 && [...row.model].length <= MODEL_CHARS))
14
23
  }
15
24
  async function load(path) {
16
25
  let file
@@ -27,7 +36,7 @@ async function load(path) {
27
36
  const value = JSON.parse(buffer.toString('utf8', 0, bytes))
28
37
  if (value?.version !== 1 || !Array.isArray(value.records) || value.records.length > 20000 || !value.records.every(valid)) throw new Error('invalid archive schema')
29
38
  // Copy only allowlisted fields, even from an externally edited archive.
30
- return value.records.map(({ key, session, at, input, output, cacheRead, committed }) => ({ key, session, at, input, output, cacheRead, committed }))
39
+ return value.records.map(({ key, session, at, input, output, cacheRead, committed, model }) => ({ key, session, at, input, output, cacheRead, committed, ...(modelName(model) ? { model: modelName(model) } : {}) }))
31
40
  } catch (e) { if (e.code === 'ENOENT') return []; throw e } finally { await file?.close() }
32
41
  }
33
42
  export function createArchive(options = {}, { now = Date.now } = {}) {
@@ -52,11 +61,13 @@ export function createArchive(options = {}, { now = Date.now } = {}) {
52
61
  prune(); dirty = true
53
62
  } catch (e) { fail(e, true) }
54
63
  })()
55
- function record(sessionId, event) {
64
+ function record(sessionId, event, model) {
56
65
  if (!enabled || fatal || typeof sessionId !== 'string' || !Number.isSafeInteger(event?.seq) || !['assistant/message', 'assistant/attempt'].includes(event.type)) return false
57
66
  const point = usagePoints({ snapshotEvents: () => [event] })[0]
58
67
  if (!point || !Number.isSafeInteger(point.at) || point.at > now() || point.at < now() - 30 * DAY) return false
59
68
  const row = { key: hash(`${sessionId}\0${event.seq}`), session: hash(sessionId), at: point.at, input: point.input, output: point.output, cacheRead: point.cacheRead, committed: point.committed }
69
+ const name = modelName(model)
70
+ if (name) row.model = name
60
71
  if (!valid(row) || records.has(row.key)) return false
61
72
  records.set(row.key, row); prune(); dirty = true; revision++
62
73
  return true
@@ -88,10 +99,48 @@ export function createArchive(options = {}, { now = Date.now } = {}) {
88
99
  }).catch((e) => fail(e))
89
100
  return serial
90
101
  }
102
+ const prices = mergePrices(config.pricingModels)
103
+ function costOf(rows) {
104
+ const byModel = new Map()
105
+ let total = 0
106
+ let priced = 0
107
+ let unpriced = 0
108
+ for (const row of rows) {
109
+ const estimate = estimateCost({ input: row.input, output: row.output, cacheRead: row.cacheRead }, row.model, { prices, peakMode: config.pricingPeak, at: row.at, currency: config.pricingCurrency })
110
+ const key = row.model ?? ''
111
+ let acc = byModel.get(key)
112
+ if (!acc) { acc = { model: row.model ?? null, vendor: estimate.vendor, calls: 0, input: 0, output: 0, cacheRead: 0, cost: 0, priced: estimate.priced }; byModel.set(key, acc) }
113
+ acc.calls += 1
114
+ acc.input += row.input
115
+ acc.output += row.output
116
+ acc.cacheRead += row.cacheRead
117
+ if (estimate.priced) { acc.cost += estimate.cost; total += estimate.cost; priced += 1 } else unpriced += 1
118
+ }
119
+ const models = [...byModel.values()]
120
+ .sort((a, b) => (Number(b.priced) - Number(a.priced)) || (b.cost - a.cost) || (b.input - a.input) || String(a.model ?? '').localeCompare(String(b.model ?? '')))
121
+ .slice(0, 8)
122
+ .map((row) => ({ ...row, cost: Number(row.cost.toFixed(6)) }))
123
+ return { total: Number(total.toFixed(6)), priced, unpriced, models }
124
+ }
91
125
  function insights() {
92
126
  prune()
93
- const aggregate = (days) => [...records.values()].filter((r) => r.at >= now() - days * DAY).reduce((a, r) => ({ calls: a.calls + 1, partial: a.partial + Number(!r.committed), input: a.input + r.input, output: a.output + r.output, cacheRead: a.cacheRead + r.cacheRead }), { calls: 0, partial: 0, input: 0, output: 0, cacheRead: 0 })
94
- return { enabled, error, records: records.size, limit: config.maxArchiveNodes, seven: aggregate(7), thirty: aggregate(30) }
127
+ const rows = [...records.values()]
128
+ const since = (days) => rows.filter((r) => r.at >= now() - days * DAY)
129
+ const aggregate = (list) => list.reduce((a, r) => ({ calls: a.calls + 1, partial: a.partial + Number(!r.committed), input: a.input + r.input, output: a.output + r.output, cacheRead: a.cacheRead + r.cacheRead }), { calls: 0, partial: 0, input: 0, output: 0, cacheRead: 0 })
130
+ const seven = since(7)
131
+ const thirty = since(30)
132
+ return {
133
+ enabled, error, records: records.size, limit: config.maxArchiveNodes,
134
+ seven: aggregate(seven), thirty: aggregate(thirty),
135
+ cost: {
136
+ currency: config.pricingCurrency,
137
+ peak: config.pricingPeak,
138
+ table: prices.length,
139
+ source: { official: PRICE_SOURCE.official, aggregate: PRICE_SOURCE.aggregate, checkedAt: PRICE_SOURCE.checkedAt, unit: PRICE_SOURCE.unit },
140
+ seven: costOf(seven),
141
+ thirty: costOf(thirty),
142
+ },
143
+ }
95
144
  }
96
145
  return { ready, record, flush, insights }
97
146
  }
package/lib/config.js CHANGED
@@ -12,6 +12,9 @@ export const DEFAULTS = Object.freeze({
12
12
  archivePath: '',
13
13
  promptPrefix: '',
14
14
  promptSuffix: '',
15
+ pricingPeak: 'auto',
16
+ pricingCurrency: 'USD',
17
+ pricingModels: Object.freeze({}),
15
18
  })
16
19
  const LIMITS = { maxNodes: [0, 20000], maxKeptTurns: [0, 60], maxRequestSteps: [0, 60], maxEvents: [0, 20], maxFileOps: [0, 12], maxArchiveNodes: [0, 20000], maxCommandChars: [16, 240], maxSessions: [1, 256] }
17
20
  export function normalizeConfig(options = {}) {
@@ -24,8 +27,33 @@ export function normalizeConfig(options = {}) {
24
27
  for (const key of ['archivePath', 'promptPrefix', 'promptSuffix']) {
25
28
  if (typeof options?.[key] === 'string') config[key] = options[key]
26
29
  }
30
+ if (['auto', 'peak', 'offpeak'].includes(options?.pricingPeak)) config.pricingPeak = options.pricingPeak
31
+ if (typeof options?.pricingCurrency === 'string' && /^[A-Z]{3}$/.test(options.pricingCurrency)) config.pricingCurrency = options.pricingCurrency
32
+ config.pricingModels = normalizePricingModels(options?.pricingModels)
27
33
  return Object.freeze(config)
28
34
  }
35
+
36
+ /**
37
+ * Keep only well-shaped price overrides: `{ '<model-prefix>': { cacheHit, cacheMiss, output } }`
38
+ * where each field is a non-negative number or a [offPeak, peak] pair. Anything
39
+ * else is dropped rather than turned into a wrong price.
40
+ */
41
+ export function normalizePricingModels(value) {
42
+ if (!value || typeof value !== 'object' || Array.isArray(value)) return Object.freeze({})
43
+ const rows = {}
44
+ for (const [rawKey, row] of Object.entries(value).slice(0, 200)) {
45
+ const key = String(rawKey).trim()
46
+ if (!key || key.length > 120 || !row || typeof row !== 'object' || Array.isArray(row)) continue
47
+ const patch = {}
48
+ for (const field of ['cacheHit', 'cacheMiss', 'output']) {
49
+ const candidate = row[field]
50
+ if (typeof candidate === 'number' && Number.isFinite(candidate) && candidate >= 0) patch[field] = candidate
51
+ else if (Array.isArray(candidate) && candidate.length === 2 && candidate.every((n) => typeof n === 'number' && Number.isFinite(n) && n >= 0)) patch[field] = [candidate[0], candidate[1]]
52
+ }
53
+ if (Object.keys(patch).length > 0) rows[key] = Object.freeze(patch)
54
+ }
55
+ return Object.freeze(rows)
56
+ }
29
57
  export function tail(rows, n) { return n <= 0 ? [] : rows.slice(-n) }
30
58
  export function clip(value, limit) {
31
59
  const chars = Array.from(String(value ?? ''))
package/lib/index.js CHANGED
@@ -21,7 +21,12 @@ export function apply(ctx, options = {}) {
21
21
  const compaction = trackCompaction(ctx, changed, config.maxSessions)
22
22
  ctx.on('session/event', (session, event) => {
23
23
  const id = typeof session === 'string' ? session : session?.id ?? session?.header?.id
24
- if (archive.record(id, event)) archive.flush().then(changed)
24
+ if (event?.type === 'assistant/message' || event?.type === 'assistant/attempt') {
25
+ // Only the model id leaves the process (hashed session, numeric usage) —
26
+ // pricing therefore needs the model name attached at record time.
27
+ const model = requestInfo(typeof session === 'object' ? session : undefined)?.name
28
+ if (archive.record(id, event, model)) archive.flush().then(changed)
29
+ }
25
30
  if (REFRESH_ON.has(event?.type)) changed()
26
31
  })
27
32
  ctx.effect(() => () => { compaction.dispose(); preferences.clear(); listeners.clear(); return archive.flush() })
package/lib/prices.js ADDED
@@ -0,0 +1,183 @@
1
+ // List prices in USD per 1M tokens. `cacheHit`/`cacheMiss`/`output` are
2
+ // scalars, or [offPeak, peak] pairs for vendors that publish peak pricing.
3
+ // DeepSeek rows come from https://api-docs.deepseek.com/quick_start/pricing
4
+ // (checked 2026-12-01); every other row comes from https://models.dev/api.json
5
+ // snapshotted the same day. Estimates only: verify against your own invoice, and
6
+ // override any row through the `pricingModels` option.
7
+ export const PRICE_SOURCE = Object.freeze({
8
+ official: 'https://api-docs.deepseek.com/quick_start/pricing',
9
+ aggregate: 'https://models.dev/api.json',
10
+ checkedAt: '2026-12-01',
11
+ currency: 'USD',
12
+ unit: 'per 1M tokens',
13
+ })
14
+
15
+ export const PRICES = Object.freeze([
16
+ {"key":"qwen-flash","vendor":"Alibaba","label":"Qwen Flash","cacheHit":0.01,"cacheMiss":0.05,"output":0.4,"source":"models.dev","context":1000000},
17
+ {"key":"qwen-flash-character","vendor":"Alibaba","label":"Qwen Flash Character","cacheHit":0.01,"cacheMiss":0.05,"output":0.4,"source":"models.dev","context":32768},
18
+ {"key":"qwen-max","vendor":"Alibaba","label":"Qwen Max","cacheHit":0.32,"cacheMiss":1.6,"output":6.4,"source":"models.dev","context":32768},
19
+ {"key":"qwen-mt-flash","vendor":"Alibaba","label":"Qwen-MT Flash","cacheHit":0,"cacheMiss":0.16,"output":0.49,"source":"models.dev","context":16384},
20
+ {"key":"qwen-mt-lite","vendor":"Alibaba","label":"Qwen-MT Lite","cacheHit":0,"cacheMiss":0.12,"output":0.36,"source":"models.dev","context":16384},
21
+ {"key":"qwen-mt-plus","vendor":"Alibaba","label":"Qwen-MT Plus","cacheHit":0,"cacheMiss":2.46,"output":7.37,"source":"models.dev","context":16384},
22
+ {"key":"qwen-plus","vendor":"Alibaba","label":"Qwen Plus","cacheHit":0.08,"cacheMiss":0.4,"output":1.2,"source":"models.dev","context":1000000},
23
+ {"key":"qwen-plus-character","vendor":"Alibaba","label":"Qwen Plus Character","cacheHit":0.1,"cacheMiss":0.5,"output":1.4,"source":"models.dev","context":131072},
24
+ {"key":"qwen-plus-character-ja","vendor":"Alibaba","label":"Qwen Plus Character (Japanese)","cacheHit":0.1,"cacheMiss":0.5,"output":1.4,"source":"models.dev","context":8192},
25
+ {"key":"qwen-vl-ocr","vendor":"Alibaba","label":"Qwen-VL OCR","cacheHit":0,"cacheMiss":0.07,"output":0.16,"source":"models.dev","context":38192},
26
+ {"key":"qwen3-coder-flash","vendor":"Alibaba","label":"Qwen3 Coder Flash","cacheHit":0.06,"cacheMiss":0.3,"output":1.5,"source":"models.dev","context":1000000},
27
+ {"key":"qwen3-vl-30b-a3b","vendor":"Alibaba","label":"Qwen3-VL 30B-A3B","cacheHit":0,"cacheMiss":0.2,"output":0.8,"source":"models.dev","context":131072},
28
+ {"key":"qwen3-vl-plus","vendor":"Alibaba","label":"Qwen3-VL Plus","cacheHit":0.04,"cacheMiss":0.2,"output":1.6,"source":"models.dev","context":262144},
29
+ {"key":"qwen3.5-122b-a10b","vendor":"Alibaba","label":"Qwen3.5 122B-A10B","cacheHit":0,"cacheMiss":0.4,"output":3.2,"source":"models.dev","context":262144},
30
+ {"key":"qwen3.5-27b","vendor":"Alibaba","label":"Qwen3.5 27B","cacheHit":0,"cacheMiss":0.3,"output":2.4,"source":"models.dev","context":262144},
31
+ {"key":"qwen3.5-35b-a3b","vendor":"Alibaba","label":"Qwen3.5 35B-A3B","cacheHit":0,"cacheMiss":0.25,"output":2,"source":"models.dev","context":262144},
32
+ {"key":"qwen3.5-397b-a17b","vendor":"Alibaba","label":"Qwen3.5 397B-A17B","cacheHit":0,"cacheMiss":0.6,"output":3.6,"source":"models.dev","context":262144},
33
+ {"key":"qwen3.5-flash","vendor":"Alibaba","label":"Qwen3.5 Flash","cacheHit":0.01,"cacheMiss":0.1,"output":0.4,"source":"models.dev","context":1000000},
34
+ {"key":"qwen3.5-plus","vendor":"Alibaba","label":"Qwen3.5 Plus","cacheHit":0,"cacheMiss":0.4,"output":2.4,"source":"models.dev","context":1000000},
35
+ {"key":"qwen3.6-27b","vendor":"Alibaba","label":"Qwen3.6 27B","cacheHit":0,"cacheMiss":0.6,"output":3.6,"source":"models.dev","context":262144},
36
+ {"key":"qwen3.6-35b-a3b","vendor":"Alibaba","label":"Qwen3.6 35B-A3B","cacheHit":0,"cacheMiss":0.375,"output":2.25,"source":"models.dev","context":262144},
37
+ {"key":"qwen3.6-flash","vendor":"Alibaba","label":"Qwen3.6 Flash","cacheHit":0.025,"cacheMiss":0.25,"output":1.5,"source":"models.dev","context":1000000},
38
+ {"key":"qwen3.6-plus","vendor":"Alibaba","label":"Qwen3.6 Plus","cacheHit":0.05,"cacheMiss":0.5,"output":3,"source":"models.dev","context":1000000},
39
+ {"key":"qwen3.7-flash","vendor":"Alibaba","label":"Qwen3.7 Flash","cacheHit":0.006,"cacheMiss":0.03,"output":0.13,"source":"models.dev","context":1000000},
40
+ {"key":"qwen3.7-max","vendor":"Alibaba","label":"Qwen3.7 Max","cacheHit":0.5,"cacheMiss":2.5,"output":7.5,"source":"models.dev","context":1000000},
41
+ {"key":"qwen3.7-plus","vendor":"Alibaba","label":"Qwen3.7 Plus","cacheHit":0.08,"cacheMiss":0.4,"output":1.6,"source":"models.dev","context":1000000},
42
+ {"key":"qwen3.8-flash","vendor":"Alibaba","label":"Qwen3.8 Flash","cacheHit":0.016,"cacheMiss":0.15,"output":0.47,"source":"models.dev","context":1000000},
43
+ {"key":"qwen3.8-max","vendor":"Alibaba","label":"Qwen3.8 Max","cacheHit":0.25,"cacheMiss":2,"output":6,"source":"models.dev","context":1000000},
44
+ {"key":"qwen4-max","vendor":"Alibaba","label":"Qwen4 Max","cacheHit":0.075,"cacheMiss":1.5,"output":4.5,"source":"models.dev","context":1000000},
45
+ {"key":"claude-fable-5","vendor":"Anthropic","label":"Claude Fable 5","cacheHit":1,"cacheMiss":10,"output":50,"source":"models.dev","context":1000000},
46
+ {"key":"claude-fable-5-1","vendor":"Anthropic","label":"Claude Fable 5.1","cacheHit":0.25,"cacheMiss":10,"output":50,"source":"models.dev","context":1000000},
47
+ {"key":"claude-fable-5-2","vendor":"Anthropic","label":"Claude Fable 5.2","cacheHit":0.2,"cacheMiss":8,"output":40,"source":"models.dev","context":1000000},
48
+ {"key":"claude-haiku-4-5","vendor":"Anthropic","label":"Claude Haiku 4.5 (latest)","cacheHit":0.1,"cacheMiss":1,"output":5,"source":"models.dev","context":200000},
49
+ {"key":"claude-haiku-5-5","vendor":"Anthropic","label":"Claude Haiku 5.5","cacheHit":0.01,"cacheMiss":0.1,"output":0.5,"source":"models.dev","context":1000000},
50
+ {"key":"claude-opus-4-5","vendor":"Anthropic","label":"Claude Opus 4.5 (latest)","cacheHit":0.5,"cacheMiss":5,"output":25,"source":"models.dev","context":200000},
51
+ {"key":"claude-opus-4-6","vendor":"Anthropic","label":"Claude Opus 4.6","cacheHit":0.5,"cacheMiss":5,"output":25,"source":"models.dev","context":1000000},
52
+ {"key":"claude-opus-4-7","vendor":"Anthropic","label":"Claude Opus 4.7","cacheHit":0.5,"cacheMiss":5,"output":25,"source":"models.dev","context":1000000},
53
+ {"key":"claude-opus-4-8","vendor":"Anthropic","label":"Claude Opus 4.8","cacheHit":0.5,"cacheMiss":5,"output":25,"source":"models.dev","context":1000000},
54
+ {"key":"claude-opus-5","vendor":"Anthropic","label":"Claude Opus 5","cacheHit":0.5,"cacheMiss":5,"output":25,"source":"models.dev","context":1000000},
55
+ {"key":"claude-opus-5-5","vendor":"Anthropic","label":"Claude Opus 5.5","cacheHit":0.2,"cacheMiss":4,"output":20,"source":"models.dev","context":1000000},
56
+ {"key":"claude-sonnet-4-6","vendor":"Anthropic","label":"Claude Sonnet 4.6","cacheHit":0.3,"cacheMiss":3,"output":15,"source":"models.dev","context":1000000},
57
+ {"key":"claude-sonnet-5","vendor":"Anthropic","label":"Claude Sonnet 5","cacheHit":0.2,"cacheMiss":2,"output":10,"source":"models.dev","context":1000000},
58
+ {"key":"claude-sonnet-5-5","vendor":"Anthropic","label":"Claude Sonnet 5.5","cacheHit":0.1,"cacheMiss":2,"output":10,"source":"models.dev","context":1000000},
59
+ {"key":"deepseek-flash","vendor":"DeepSeek","label":"DeepSeek V4.1 Flash 1017","cacheHit":[0.003,0.006],"cacheMiss":[0.15,0.3],"output":[0.6,1.2],"source":"official","context":1048576},
60
+ {"key":"deepseek-v4-flash","vendor":"DeepSeek","label":"DeepSeek V4 Flash","cacheHit":[0.003,0.006],"cacheMiss":[0.15,0.3],"output":[0.6,1.2],"source":"official","context":1048576},
61
+ {"key":"deepseek-v4-pro","vendor":"DeepSeek","label":"DeepSeek V4 Pro","cacheHit":[0.022,0.044],"cacheMiss":[0.66,1.32],"output":[1.98,3.96],"source":"official","context":1048576},
62
+ {"key":"gemini-2.5-flash","vendor":"Google","label":"Gemini 2.5 Flash","cacheHit":0.03,"cacheMiss":0.3,"output":2.5,"source":"models.dev","context":1048576},
63
+ {"key":"gemini-2.5-flash-lite","vendor":"Google","label":"Gemini 2.5 Flash-Lite","cacheHit":0.01,"cacheMiss":0.1,"output":0.4,"source":"models.dev","context":1048576},
64
+ {"key":"gemini-2.5-pro","vendor":"Google","label":"Gemini 2.5 Pro","cacheHit":0.125,"cacheMiss":1.25,"output":10,"source":"models.dev","context":1048576},
65
+ {"key":"gemini-3-flash-preview","vendor":"Google","label":"Gemini 3 Flash Preview","cacheHit":0.05,"cacheMiss":0.5,"output":3,"source":"models.dev","context":1048576},
66
+ {"key":"gemini-3.1-flash-lite","vendor":"Google","label":"Gemini 3.1 Flash Lite","cacheHit":0.025,"cacheMiss":0.25,"output":1.5,"source":"models.dev","context":1048576},
67
+ {"key":"gemini-3.1-flash-live-preview","vendor":"Google","label":"Gemini 3.1 Flash Live Preview","cacheHit":0,"cacheMiss":0.75,"output":4.5,"source":"models.dev","context":131072},
68
+ {"key":"gemini-3.1-pro-preview","vendor":"Google","label":"Gemini 3.1 Pro Preview","cacheHit":0.2,"cacheMiss":2,"output":12,"source":"models.dev","context":1048576},
69
+ {"key":"gemini-3.1-pro-preview-customtools","vendor":"Google","label":"Gemini 3.1 Pro Preview Custom Tools","cacheHit":0.2,"cacheMiss":2,"output":12,"source":"models.dev","context":1048576},
70
+ {"key":"gemini-3.5-flash","vendor":"Google","label":"Gemini 3.5 Flash","cacheHit":0.15,"cacheMiss":1.5,"output":9,"source":"models.dev","context":1048576},
71
+ {"key":"gemini-3.5-flash-lite","vendor":"Google","label":"Gemini 3.5 Flash Lite","cacheHit":0.03,"cacheMiss":0.3,"output":2.5,"source":"models.dev","context":1048576},
72
+ {"key":"gemini-3.5-live-translate-preview","vendor":"Google","label":"Gemini 3.5 Live Translate Preview","cacheHit":0,"cacheMiss":3.5,"output":21,"source":"models.dev","context":16384},
73
+ {"key":"gemini-3.6-flash","vendor":"Google","label":"Gemini 3.6 Flash","cacheHit":0.075,"cacheMiss":0.75,"output":3.75,"source":"models.dev","context":1048576},
74
+ {"key":"gemini-3.7-flash","vendor":"Google","label":"Gemini 3.7 Flash","cacheHit":0.075,"cacheMiss":0.75,"output":3.75,"source":"models.dev","context":1048576},
75
+ {"key":"gemini-3.8-flash","vendor":"Google","label":"Gemini 3.8 Flash","cacheHit":0.075,"cacheMiss":0.75,"output":3.75,"source":"models.dev","context":1048576},
76
+ {"key":"gemini-4-argon","vendor":"Google","label":"Gemini 4 Argon","cacheHit":0.1,"cacheMiss":2,"output":10,"source":"models.dev","context":1048576},
77
+ {"key":"gemini-4-carbon","vendor":"Google","label":"Gemini 4 Carbon","cacheHit":0.1,"cacheMiss":2,"output":10,"source":"models.dev","context":1048576},
78
+ {"key":"gemini-4-hydrogen","vendor":"Google","label":"Gemini 4 Hydrogen","cacheHit":0.075,"cacheMiss":1.5,"output":7.5,"source":"models.dev","context":1048576},
79
+ {"key":"gemini-4-neon","vendor":"Google","label":"Gemini 4 Neon","cacheHit":0.15,"cacheMiss":3,"output":15,"source":"models.dev","context":1048576},
80
+ {"key":"gemini-flash-latest","vendor":"Google","label":"Gemini Flash Latest","cacheHit":0.075,"cacheMiss":0.75,"output":3.75,"source":"models.dev","context":1048576},
81
+ {"key":"gemini-flash-lite-latest","vendor":"Google","label":"Gemini Flash-Lite Latest","cacheHit":0.03,"cacheMiss":0.3,"output":2.5,"source":"models.dev","context":1048576},
82
+ {"key":"gemini-pro-latest","vendor":"Google","label":"Gemini Pro Latest","cacheHit":0.2,"cacheMiss":2,"output":12,"source":"models.dev","context":1048576},
83
+ {"key":"gemma-4-26b-a4b-it","vendor":"Google","label":"Gemma 4 26B A4B IT","cacheHit":0,"cacheMiss":0,"output":0,"source":"models.dev","context":262144},
84
+ {"key":"gemma-4-31b-it","vendor":"Google","label":"Gemma 4 31B IT","cacheHit":0,"cacheMiss":0,"output":0,"source":"models.dev","context":262144},
85
+ {"key":"MiniMax-M2","vendor":"MiniMax","label":"MiniMax-M2","cacheHit":0,"cacheMiss":0.3,"output":1.2,"source":"models.dev","context":204800},
86
+ {"key":"MiniMax-M2.1","vendor":"MiniMax","label":"MiniMax-M2.1","cacheHit":0.03,"cacheMiss":0.3,"output":1.2,"source":"models.dev","context":204800},
87
+ {"key":"MiniMax-M2.5","vendor":"MiniMax","label":"MiniMax-M2.5","cacheHit":0.03,"cacheMiss":0.3,"output":1.2,"source":"models.dev","context":204800},
88
+ {"key":"MiniMax-M2.5-highspeed","vendor":"MiniMax","label":"MiniMax-M2.5-highspeed","cacheHit":0.03,"cacheMiss":0.6,"output":2.4,"source":"models.dev","context":204800},
89
+ {"key":"MiniMax-M2.7","vendor":"MiniMax","label":"MiniMax-M2.7","cacheHit":0.06,"cacheMiss":0.3,"output":1.2,"source":"models.dev","context":204800},
90
+ {"key":"MiniMax-M2.7-highspeed","vendor":"MiniMax","label":"MiniMax-M2.7-highspeed","cacheHit":0.06,"cacheMiss":0.6,"output":2.4,"source":"models.dev","context":204800},
91
+ {"key":"MiniMax-M3","vendor":"MiniMax","label":"MiniMax-M3","cacheHit":0.06,"cacheMiss":0.3,"output":1.2,"source":"models.dev","context":1000000},
92
+ {"key":"MiniMax-M3.1-Flash","vendor":"MiniMax","label":"MiniMax-M3.1-Flash","cacheHit":0.015,"cacheMiss":0.15,"output":0.6,"source":"models.dev","context":1000000},
93
+ {"key":"codestral-2508","vendor":"Mistral","label":"Codestral 25.08","cacheHit":0.03,"cacheMiss":0.3,"output":0.9,"source":"models.dev","context":256000},
94
+ {"key":"codestral-latest","vendor":"Mistral","label":"Codestral (latest)","cacheHit":0.03,"cacheMiss":0.3,"output":0.9,"source":"models.dev","context":256000},
95
+ {"key":"magistral-medium-latest","vendor":"Mistral","label":"Magistral Medium (latest)","cacheHit":0.15,"cacheMiss":1.5,"output":7.5,"source":"models.dev","context":262144},
96
+ {"key":"ministral-14b-2512","vendor":"Mistral","label":"Ministral 3 14B","cacheHit":0.02,"cacheMiss":0.2,"output":0.2,"source":"models.dev","context":262144},
97
+ {"key":"ministral-14b-latest","vendor":"Mistral","label":"Ministral 3 14B (latest)","cacheHit":0.02,"cacheMiss":0.2,"output":0.2,"source":"models.dev","context":262144},
98
+ {"key":"ministral-3b-2512","vendor":"Mistral","label":"Ministral 3 3B","cacheHit":0.01,"cacheMiss":0.1,"output":0.1,"source":"models.dev","context":131072},
99
+ {"key":"ministral-3b-latest","vendor":"Mistral","label":"Ministral 3 3B (latest)","cacheHit":0.01,"cacheMiss":0.1,"output":0.1,"source":"models.dev","context":131072},
100
+ {"key":"ministral-8b-2512","vendor":"Mistral","label":"Ministral 3 8B","cacheHit":0.015,"cacheMiss":0.15,"output":0.15,"source":"models.dev","context":262144},
101
+ {"key":"ministral-8b-latest","vendor":"Mistral","label":"Ministral 3 8B (latest)","cacheHit":0.015,"cacheMiss":0.15,"output":0.15,"source":"models.dev","context":262144},
102
+ {"key":"mistral-large-2512","vendor":"Mistral","label":"Mistral Large 3","cacheHit":0.05,"cacheMiss":0.5,"output":1.5,"source":"models.dev","context":262144},
103
+ {"key":"mistral-large-4","vendor":"Mistral","label":"Mistral Large 4","cacheHit":0.07,"cacheMiss":0.7,"output":2.1,"source":"models.dev","context":1048576},
104
+ {"key":"mistral-large-latest","vendor":"Mistral","label":"Mistral Large (latest)","cacheHit":0.07,"cacheMiss":0.7,"output":2.1,"source":"models.dev","context":1048576},
105
+ {"key":"mistral-medium-2604","vendor":"Mistral","label":"Mistral Medium 3.5","cacheHit":0.15,"cacheMiss":1.5,"output":7.5,"source":"models.dev","context":262144},
106
+ {"key":"mistral-medium-latest","vendor":"Mistral","label":"Mistral Medium (latest)","cacheHit":0.15,"cacheMiss":1.5,"output":7.5,"source":"models.dev","context":262144},
107
+ {"key":"mistral-small-2603","vendor":"Mistral","label":"Mistral Small 4","cacheHit":0.015,"cacheMiss":0.15,"output":0.6,"source":"models.dev","context":262144},
108
+ {"key":"mistral-small-latest","vendor":"Mistral","label":"Mistral Small (latest)","cacheHit":0.015,"cacheMiss":0.15,"output":0.6,"source":"models.dev","context":262144},
109
+ {"key":"voxtral-small-2507","vendor":"Mistral","label":"Voxtral Small","cacheHit":0,"cacheMiss":0.1,"output":0.3,"source":"models.dev","context":32768},
110
+ {"key":"voxtral-small-latest","vendor":"Mistral","label":"Voxtral Small (latest)","cacheHit":0,"cacheMiss":0.1,"output":0.3,"source":"models.dev","context":32768},
111
+ {"key":"zai-glm-5-3","vendor":"Mistral","label":"GLM-5.3","cacheHit":0.14,"cacheMiss":1.4,"output":4.4,"source":"models.dev","context":1048576},
112
+ {"key":"zai-glm-5-3-flash","vendor":"Mistral","label":"GLM-5.3-Flash","cacheHit":0.03,"cacheMiss":0.15,"output":0.5,"source":"models.dev","context":1048576},
113
+ {"key":"kimi-k2.6","vendor":"Moonshot","label":"Kimi K2.6","cacheHit":0.16,"cacheMiss":0.95,"output":4,"source":"models.dev","context":262144},
114
+ {"key":"kimi-k2.7-code","vendor":"Moonshot","label":"Kimi K2.7 Code","cacheHit":0.19,"cacheMiss":0.95,"output":4,"source":"models.dev","context":262144},
115
+ {"key":"kimi-k2.7-code-highspeed","vendor":"Moonshot","label":"Kimi K2.7 Code HighSpeed","cacheHit":0.38,"cacheMiss":1.9,"output":8,"source":"models.dev","context":262144},
116
+ {"key":"kimi-k3","vendor":"Moonshot","label":"Kimi K3","cacheHit":0.3,"cacheMiss":3,"output":15,"source":"models.dev","context":1048576},
117
+ {"key":"kimi-k3.1-pro","vendor":"Moonshot","label":"Kimi K3.1 Pro","cacheHit":0.2,"cacheMiss":2,"output":10,"source":"models.dev","context":1048576},
118
+ {"key":"kimi-k3.1-pro-highspeed","vendor":"Moonshot","label":"Kimi K3.1 Pro Highspeed","cacheHit":0.2,"cacheMiss":4,"output":20,"source":"models.dev","context":1048576},
119
+ {"key":"gpt-4.1","vendor":"OpenAI","label":"GPT-4.1","cacheHit":0.5,"cacheMiss":2,"output":8,"source":"models.dev","context":1047576},
120
+ {"key":"gpt-4.1-mini","vendor":"OpenAI","label":"GPT-4.1 mini","cacheHit":0.1,"cacheMiss":0.4,"output":1.6,"source":"models.dev","context":1047576},
121
+ {"key":"gpt-4o","vendor":"OpenAI","label":"GPT-4o","cacheHit":1.25,"cacheMiss":2.5,"output":10,"source":"models.dev","context":128000},
122
+ {"key":"gpt-4o-2024-08-06","vendor":"OpenAI","label":"GPT-4o (2024-08-06)","cacheHit":1.25,"cacheMiss":2.5,"output":10,"source":"models.dev","context":128000},
123
+ {"key":"gpt-4o-2024-11-20","vendor":"OpenAI","label":"GPT-4o (2024-11-20)","cacheHit":1.25,"cacheMiss":2.5,"output":10,"source":"models.dev","context":128000},
124
+ {"key":"gpt-4o-mini","vendor":"OpenAI","label":"GPT-4o mini","cacheHit":0.075,"cacheMiss":0.15,"output":0.6,"source":"models.dev","context":128000},
125
+ {"key":"gpt-5","vendor":"OpenAI","label":"GPT-5","cacheHit":0.125,"cacheMiss":1.25,"output":10,"source":"models.dev","context":400000},
126
+ {"key":"gpt-5-mini","vendor":"OpenAI","label":"GPT-5 Mini","cacheHit":0.025,"cacheMiss":0.25,"output":2,"source":"models.dev","context":400000},
127
+ {"key":"gpt-5-nano","vendor":"OpenAI","label":"GPT-5 Nano","cacheHit":0.005,"cacheMiss":0.05,"output":0.4,"source":"models.dev","context":400000},
128
+ {"key":"gpt-5-pro","vendor":"OpenAI","label":"GPT-5 Pro","cacheHit":0,"cacheMiss":15,"output":120,"source":"models.dev","context":400000},
129
+ {"key":"gpt-5.1","vendor":"OpenAI","label":"GPT-5.1","cacheHit":0.125,"cacheMiss":1.25,"output":10,"source":"models.dev","context":400000},
130
+ {"key":"gpt-5.2","vendor":"OpenAI","label":"GPT-5.2","cacheHit":0.175,"cacheMiss":1.75,"output":14,"source":"models.dev","context":400000},
131
+ {"key":"gpt-5.2-pro","vendor":"OpenAI","label":"GPT-5.2 Pro","cacheHit":0,"cacheMiss":21,"output":168,"source":"models.dev","context":400000},
132
+ {"key":"gpt-5.3-codex","vendor":"OpenAI","label":"GPT-5.3 Codex","cacheHit":0.175,"cacheMiss":1.75,"output":14,"source":"models.dev","context":400000},
133
+ {"key":"gpt-5.4","vendor":"OpenAI","label":"GPT-5.4","cacheHit":0.25,"cacheMiss":2.5,"output":15,"source":"models.dev","context":1050000},
134
+ {"key":"gpt-5.4-mini","vendor":"OpenAI","label":"GPT-5.4 mini","cacheHit":0.075,"cacheMiss":0.75,"output":4.5,"source":"models.dev","context":400000},
135
+ {"key":"gpt-5.4-nano","vendor":"OpenAI","label":"GPT-5.4 nano","cacheHit":0.02,"cacheMiss":0.2,"output":1.25,"source":"models.dev","context":400000},
136
+ {"key":"gpt-5.4-pro","vendor":"OpenAI","label":"GPT-5.4 Pro","cacheHit":0,"cacheMiss":30,"output":180,"source":"models.dev","context":1050000},
137
+ {"key":"gpt-5.5","vendor":"OpenAI","label":"GPT-5.5","cacheHit":0.5,"cacheMiss":5,"output":30,"source":"models.dev","context":1050000},
138
+ {"key":"gpt-5.5-pro","vendor":"OpenAI","label":"GPT-5.5 Pro","cacheHit":0,"cacheMiss":30,"output":180,"source":"models.dev","context":1050000},
139
+ {"key":"gpt-5.6","vendor":"OpenAI","label":"GPT-5.6","cacheHit":0.4,"cacheMiss":4,"output":20,"source":"models.dev","context":1050000},
140
+ {"key":"gpt-5.6-luna","vendor":"OpenAI","label":"GPT-5.6 Luna","cacheHit":0.02,"cacheMiss":0.2,"output":1.2,"source":"models.dev","context":1050000},
141
+ {"key":"gpt-5.6-sol","vendor":"OpenAI","label":"GPT-5.6 Sol","cacheHit":0.4,"cacheMiss":4,"output":20,"source":"models.dev","context":1050000},
142
+ {"key":"gpt-5.6-terra","vendor":"OpenAI","label":"GPT-5.6 Terra","cacheHit":0.2,"cacheMiss":2,"output":12,"source":"models.dev","context":1050000},
143
+ {"key":"gpt-6-astra","vendor":"OpenAI","label":"GPT-6 Astra","cacheHit":1,"cacheMiss":10,"output":50,"source":"models.dev","context":1050000},
144
+ {"key":"gpt-6-astra-healthcare","vendor":"OpenAI","label":"GPT-6 Astra Healthcare","cacheHit":1,"cacheMiss":10,"output":50,"source":"models.dev","context":1050000},
145
+ {"key":"gpt-6-luna","vendor":"OpenAI","label":"GPT-6 Luna","cacheHit":0.01,"cacheMiss":0.1,"output":0.5,"source":"models.dev","context":1050000},
146
+ {"key":"gpt-6-sol","vendor":"OpenAI","label":"GPT-6 Sol","cacheHit":0.2,"cacheMiss":2,"output":10,"source":"models.dev","context":1050000},
147
+ {"key":"gpt-6.1-sol","vendor":"OpenAI","label":"GPT-6.1 Sol","cacheHit":0.1,"cacheMiss":2,"output":10,"source":"models.dev","context":1050000},
148
+ {"key":"gpt-6.1-sol-healthcare","vendor":"OpenAI","label":"GPT-6.1 Sol Healthcare","cacheHit":0.1,"cacheMiss":2,"output":10,"source":"models.dev","context":1050000},
149
+ {"key":"gpt-6.1-terra","vendor":"OpenAI","label":"GPT-6.1 Terra","cacheHit":0.05,"cacheMiss":1,"output":5,"source":"models.dev","context":1050000},
150
+ {"key":"gpt-6.2-astra","vendor":"OpenAI","label":"GPT-6.2 Astra","cacheHit":0.4,"cacheMiss":8,"output":40,"source":"models.dev","context":1050000},
151
+ {"key":"gpt-6.2-astra-healthcare","vendor":"OpenAI","label":"GPT-6.2 Astra Healthcare","cacheHit":0.4,"cacheMiss":8,"output":40,"source":"models.dev","context":1050000},
152
+ {"key":"gpt-6.2-sol","vendor":"OpenAI","label":"GPT-6.2 Sol","cacheHit":0.1,"cacheMiss":2,"output":10,"source":"models.dev","context":1050000},
153
+ {"key":"gpt-6.2-sol-healthcare","vendor":"OpenAI","label":"GPT-6.2 Sol Healthcare","cacheHit":0.1,"cacheMiss":2,"output":10,"source":"models.dev","context":1050000},
154
+ {"key":"gpt-daybreak-blue-latest","vendor":"OpenAI","label":"Daybreak Blue","cacheHit":0.4,"cacheMiss":4,"output":20,"source":"models.dev","context":1050000},
155
+ {"key":"gpt-daybreak-red-latest","vendor":"OpenAI","label":"Daybreak Red","cacheHit":1.25,"cacheMiss":12.5,"output":75,"source":"models.dev","context":400000},
156
+ {"key":"o3","vendor":"OpenAI","label":"o3","cacheHit":0.5,"cacheMiss":2,"output":8,"source":"models.dev","context":200000},
157
+ {"key":"o3-pro","vendor":"OpenAI","label":"o3-pro","cacheHit":0,"cacheMiss":20,"output":80,"source":"models.dev","context":200000},
158
+ {"key":"grok-4.20-0309-non-reasoning","vendor":"xAI","label":"Grok 4.20 (Non-Reasoning)","cacheHit":0.2,"cacheMiss":1.25,"output":2.5,"source":"models.dev","context":1000000},
159
+ {"key":"grok-4.20-0309-reasoning","vendor":"xAI","label":"Grok 4.20 (Reasoning)","cacheHit":0.2,"cacheMiss":1.25,"output":2.5,"source":"models.dev","context":1000000},
160
+ {"key":"grok-4.20-multi-agent-0309","vendor":"xAI","label":"Grok 4.20 Multi-Agent","cacheHit":0.2,"cacheMiss":1.25,"output":2.5,"source":"models.dev","context":1000000},
161
+ {"key":"grok-4.3","vendor":"xAI","label":"Grok 4.3","cacheHit":0.2,"cacheMiss":1.25,"output":2.5,"source":"models.dev","context":1000000},
162
+ {"key":"grok-4.5","vendor":"xAI","label":"Grok 4.5","cacheHit":0.3,"cacheMiss":2,"output":6,"source":"models.dev","context":500000},
163
+ {"key":"grok-4.6","vendor":"xAI","label":"Grok 4.6","cacheHit":0.5,"cacheMiss":2,"output":6,"source":"models.dev","context":500000},
164
+ {"key":"grok-4.7","vendor":"xAI","label":"Grok 4.7","cacheHit":0.5,"cacheMiss":2,"output":6,"source":"models.dev","context":500000},
165
+ {"key":"glm-4.5","vendor":"Zhipu","label":"GLM-4.5","cacheHit":0.11,"cacheMiss":0.6,"output":2.2,"source":"models.dev","context":131072},
166
+ {"key":"glm-4.5-air","vendor":"Zhipu","label":"GLM-4.5-Air","cacheHit":0.0239,"cacheMiss":0.11952,"output":0.89637,"source":"models.dev","context":131072},
167
+ {"key":"glm-4.5-flash","vendor":"Zhipu","label":"GLM-4.5-Flash","cacheHit":0,"cacheMiss":0,"output":0,"source":"models.dev","context":131072},
168
+ {"key":"glm-4.5v","vendor":"Zhipu","label":"GLM-4.5V","cacheHit":0.05976,"cacheMiss":0.29879,"output":0.89637,"source":"models.dev","context":64000},
169
+ {"key":"glm-4.6","vendor":"Zhipu","label":"GLM-4.6","cacheHit":0.11,"cacheMiss":0.6,"output":2.2,"source":"models.dev","context":204800},
170
+ {"key":"glm-4.6v","vendor":"Zhipu","label":"GLM-4.6V","cacheHit":0.02988,"cacheMiss":0.1494,"output":0.44819,"source":"models.dev","context":128000},
171
+ {"key":"glm-4.6v-flash","vendor":"Zhipu","label":"GLM-4.6V-Flash","cacheHit":0,"cacheMiss":0,"output":0,"source":"models.dev","context":128000},
172
+ {"key":"glm-4.7","vendor":"Zhipu","label":"GLM-4.7","cacheHit":0.08964,"cacheMiss":0.44819,"output":2.09153,"source":"models.dev","context":204800},
173
+ {"key":"glm-4.7-flash","vendor":"Zhipu","label":"GLM-4.7-Flash","cacheHit":0,"cacheMiss":0,"output":0,"source":"models.dev","context":200000},
174
+ {"key":"glm-4.7-flashx","vendor":"Zhipu","label":"GLM-4.7-FlashX","cacheHit":0.01494,"cacheMiss":0.0747,"output":0.44819,"source":"models.dev","context":200000},
175
+ {"key":"glm-5","vendor":"Zhipu","label":"GLM-5","cacheHit":0.1494,"cacheMiss":0.59758,"output":2.68911,"source":"models.dev","context":204800},
176
+ {"key":"glm-5.1","vendor":"Zhipu","label":"GLM-5.1","cacheHit":0.19421,"cacheMiss":0.89637,"output":3.58548,"source":"models.dev","context":200000},
177
+ {"key":"glm-5.2","vendor":"Zhipu","label":"GLM-5.2","cacheHit":0.29879,"cacheMiss":1.19516,"output":4.18306,"source":"models.dev","context":1000000},
178
+ {"key":"glm-5.3","vendor":"Zhipu","label":"GLM-5.3","cacheHit":0.29879,"cacheMiss":1.19516,"output":4.18306,"source":"models.dev","context":1000000},
179
+ {"key":"glm-5.3-flash","vendor":"Zhipu","label":"GLM-5.3-Flash","cacheHit":0.03436,"cacheMiss":0.11952,"output":0.41831,"source":"models.dev","context":1000000},
180
+ {"key":"glm-5.3-flashx","vendor":"Zhipu","label":"GLM-5.3-FlashX","cacheHit":0.08516,"cacheMiss":0.29879,"output":1.04577,"source":"models.dev","context":1000000},
181
+ {"key":"glm-5.3-flashx-legal","vendor":"Zhipu","label":"GLM-5.3-FlashX-Legal","cacheHit":0.08534,"cacheMiss":0.29943,"output":1.04801,"source":"models.dev","context":1000000},
182
+ {"key":"glm-5v-turbo","vendor":"Zhipu","label":"GLM-5V-Turbo","cacheHit":0.17927,"cacheMiss":0.74698,"output":3.28669,"source":"models.dev","context":200000},
183
+ ])
package/lib/pricing.js ADDED
@@ -0,0 +1,105 @@
1
+ // Billing estimates from published list prices. Pure functions, no I/O: the
2
+ // archive only stores token counters, so a missing price row must stay visible
3
+ // as "unpriced" instead of becoming a made-up number.
4
+ import { PRICES, PRICE_SOURCE } from './prices.js'
5
+
6
+ const BOUNDARY = new Set(['-', '.', '/', ':', '_', ' ', '+'])
7
+ const FIELDS = ['cacheHit', 'cacheMiss', 'output']
8
+
9
+ /**
10
+ * DeepSeek publishes peak pricing for UTC 01:00-04:00 and 06:00-10:00 on
11
+ * weekdays. Chinese public holidays are excluded by the vendor but cannot be
12
+ * tracked here, so the estimate may charge peak rates on a holiday.
13
+ * @param {number} at epoch milliseconds
14
+ * @returns {boolean}
15
+ */
16
+ export function isPeak(at = Date.now()) {
17
+ const date = new Date(at)
18
+ const day = date.getUTCDay()
19
+ if (day === 0 || day === 6) return false
20
+ const hour = date.getUTCHours()
21
+ return (hour >= 1 && hour < 4) || (hour >= 6 && hour < 10)
22
+ }
23
+
24
+ /**
25
+ * Longest prefix match that ends on a model-id boundary, so `gpt-4.1` never
26
+ * swallows `gpt-4.1-mini-x` unless that row exists on its own.
27
+ * @param {string | null | undefined} model
28
+ * @param {ReadonlyArray<object>} prices
29
+ * @returns {object | null}
30
+ */
31
+ export function findPrice(model, prices = PRICES) {
32
+ const id = typeof model === 'string' ? model.trim().toLowerCase() : ''
33
+ if (!id) return null
34
+ let best = null
35
+ for (const entry of prices) {
36
+ const key = typeof entry?.key === 'string' ? entry.key.trim().toLowerCase() : ''
37
+ if (!key || !id.startsWith(key)) continue
38
+ const next = id.charAt(key.length)
39
+ if (next && !BOUNDARY.has(next)) continue
40
+ if (!best || key.length > best.key.trim().length) best = entry
41
+ }
42
+ return best
43
+ }
44
+
45
+ const pick = (value, peak) => {
46
+ if (Array.isArray(value)) {
47
+ const candidate = Number.isFinite(value[peak ? 1 : 0]) ? value[peak ? 1 : 0] : value[0]
48
+ return Number.isFinite(candidate) ? candidate : 0
49
+ }
50
+ return Number.isFinite(value) ? value : 0
51
+ }
52
+
53
+ /** Flatten a row's scalar-or-pair prices for one billing window. */
54
+ export function resolvePrice(entry, peak) {
55
+ return { cacheHit: pick(entry?.cacheHit, peak), cacheMiss: pick(entry?.cacheMiss, peak), output: pick(entry?.output, peak) }
56
+ }
57
+
58
+ function counters(usage) {
59
+ const read = (key) => (Number.isFinite(usage?.[key]) && usage[key] >= 0 ? usage[key] : null)
60
+ const input = read('input')
61
+ const output = read('output')
62
+ const cacheRead = read('cacheRead') ?? 0
63
+ return input === null || output === null ? null : { input, output, cacheRead: Math.min(cacheRead, input) }
64
+ }
65
+
66
+ /**
67
+ * @param {{ input: number, output: number, cacheRead?: number }} usage token counters
68
+ * @param {string | null | undefined} model model id reported by the host
69
+ * @param {{ prices?: ReadonlyArray<object>, at?: number, peakMode?: 'auto'|'peak'|'offpeak', currency?: string }} [options]
70
+ * @returns {{ model: string | null, matched: string | null, vendor: string | null, currency: string, peak: boolean, cost: number | null, priced: boolean }}
71
+ */
72
+ export function estimateCost(usage, model, options = {}) {
73
+ const prices = options.prices ?? PRICES
74
+ const currency = options.currency ?? PRICE_SOURCE.currency
75
+ const base = { model: typeof model === 'string' ? model : null, matched: null, vendor: null, currency, peak: false, cost: null, priced: false }
76
+ const counts = counters(usage)
77
+ const entry = findPrice(model, prices)
78
+ if (!counts || !entry) return base
79
+ const peak = options.peakMode === 'peak' ? true : options.peakMode === 'offpeak' ? false : isPeak(options.at ?? Date.now())
80
+ const price = resolvePrice(entry, peak)
81
+ const cacheHit = Math.min(counts.cacheRead, counts.input)
82
+ const cacheMiss = Math.max(0, counts.input - cacheHit)
83
+ const cost = (cacheHit * price.cacheHit + cacheMiss * price.cacheMiss + counts.output * price.output) / 1e6
84
+ return { model: base.model, matched: entry.key, vendor: entry.vendor ?? null, currency, peak, cost, priced: true }
85
+ }
86
+
87
+ /** Overlay user-configured rows on the shipped table; only labelled fields win. */
88
+ export function mergePrices(overrides = {}, prices = PRICES) {
89
+ const rows = prices.map((row) => ({ ...row }))
90
+ for (const [rawKey, value] of Object.entries(overrides ?? {})) {
91
+ const key = String(rawKey).trim()
92
+ if (!key || !value || typeof value !== 'object') continue
93
+ const patch = {}
94
+ for (const field of FIELDS) {
95
+ const candidate = value[field]
96
+ if (Number.isFinite(candidate) && candidate >= 0) patch[field] = candidate
97
+ else if (Array.isArray(candidate) && candidate.length === 2 && candidate.every((n) => Number.isFinite(n) && n >= 0)) patch[field] = [candidate[0], candidate[1]]
98
+ }
99
+ if (Object.keys(patch).length === 0) continue
100
+ const at = rows.findIndex((row) => String(row.key ?? '').toLowerCase() === key.toLowerCase())
101
+ if (at >= 0) rows[at] = { ...rows[at], ...patch, source: 'override' }
102
+ else rows.push({ key, vendor: 'Custom', label: key, cacheHit: 0, cacheMiss: 0, output: 0, ...patch, source: 'override', context: null })
103
+ }
104
+ return Object.freeze(rows.map((row) => Object.freeze(row)))
105
+ }
package/lib/view.js CHANGED
@@ -132,6 +132,39 @@ export function contextData({
132
132
  : insights.error ? (en ? 'Archive error: ' : '归档错误:') + text(insights.error)
133
133
  : (en ? 'Retained ' : '保留 ') + insights.records + '/' + insights.limit + (en ? ' records · observed calls only' : ' 条 · 仅统计启用后观察到的调用')
134
134
 
135
+ const money = (value) => {
136
+ const currency = text(insights?.cost?.currency ?? limits.pricingCurrency)
137
+ if (typeof value !== 'number' || !Number.isFinite(value)) return '—'
138
+ if (value === 0) return '0 ' + currency
139
+ if (value < 0.01) return '<0.01 ' + currency
140
+ return value.toFixed(2) + ' ' + currency
141
+ }
142
+ const costTotal = (bucket, en) => {
143
+ if (!insights?.enabled) return en ? 'Cost needs the local archive (archiveEnabled)' : '计费需要开启本地归档(archiveEnabled)'
144
+ if (!bucket || (bucket.priced === 0 && bucket.unpriced === 0)) return en ? 'No calls in the last 7 days' : '最近 7 天没有可计价的调用'
145
+ const head = (en ? 'Last 7 days ≈ ' : '最近 7 天约 ') + (bucket.priced > 0 ? money(bucket.total) : (en ? 'unpriced' : '未计价'))
146
+ const tail = bucket.unpriced > 0 ? (en ? ` · ${bucket.unpriced} unpriced` : ` · ${bucket.unpriced} 次未计价`) : ''
147
+ return head + tail
148
+ }
149
+ const costItems = (en) =>
150
+ (insights?.cost?.thirty?.models ?? []).slice(0, 5).map((row) => ({
151
+ title: text(row.model ?? (en ? 'Unknown model' : '未知模型')),
152
+ subtitle: (en ? 'in ' : '入 ') + compact(row.input) + (en ? ' · out ' : ' · 出 ') + compact(row.output) + ' · ' + row.calls + (en ? ' calls' : ' 次'),
153
+ trailing: row.priced ? money(row.cost) : (en ? 'unpriced' : '未计价'),
154
+ icon: 'model',
155
+ ...(row.priced ? {} : { tone: 'muted' }),
156
+ }))
157
+ const costNote = (en) => {
158
+ const source = insights?.cost?.source
159
+ if (!source) return ''
160
+ const peak = insights?.cost?.peak
161
+ const mode = peak === 'peak' ? (en ? 'peak rate' : '按峰时价') : peak === 'offpeak' ? (en ? 'off-peak rate' : '按谷时价') : (en ? 'peak/off-peak by call time' : '按调用时刻自动区分峰谷')
162
+ const label = en
163
+ ? `Prices per 1M tokens (${source.official} + ${source.aggregate}, checked ${source.checkedAt}), ${mode}. Estimate only — not a bill.`
164
+ : `价目为每 1M tokens(${source.official} 与 ${source.aggregate},${source.checkedAt} 核对),${mode}。此处仅为估算,不是账单。`
165
+ return text(label)
166
+ }
167
+
135
168
  const win = contextWindow ?? pressure?.contextWindow ?? null
136
169
  const tokens = pressure === null ? null : pressure.pressureTokens
137
170
  const r = ratio(tokens, win)
@@ -440,6 +473,9 @@ export function contextData({
440
473
  insightsZh: stats(insights?.seven, 7, false) + '\n' + stats(insights?.thirty, 30, false),
441
474
  insightsEn: stats(insights?.seven, 7, true) + '\n' + stats(insights?.thirty, 30, true),
442
475
  archiveStatusZh: archiveStatus(false), archiveStatusEn: archiveStatus(true),
476
+ costTotalZh: costTotal(insights?.cost?.seven, false), costTotalEn: costTotal(insights?.cost?.seven, true),
477
+ costItemsZh: costItems(false), costItemsEn: costItems(true),
478
+ costNoteZh: costNote(false), costNoteEn: costNote(true),
443
479
  count: fleetList.length,
444
480
  itemsZh: fleetItems(false),
445
481
  itemsEn: fleetItems(true),
@@ -621,6 +657,9 @@ function v2View(caps) {
621
657
  note(en ? 'data.tabs.fleet.note.en' : 'data.tabs.fleet.note.zh'),
622
658
  note(en ? 'data.tabs.fleet.archiveStatusEn' : 'data.tabs.fleet.archiveStatusZh'),
623
659
  note(en ? 'data.tabs.fleet.insightsEn' : 'data.tabs.fleet.insightsZh'),
660
+ { type: 'text', text: { $: en ? 'data.tabs.fleet.costTotalEn' : 'data.tabs.fleet.costTotalZh' } },
661
+ { type: 'list', items: { $: en ? 'data.tabs.fleet.costItemsEn' : 'data.tabs.fleet.costItemsZh' } },
662
+ note(en ? 'data.tabs.fleet.costNoteEn' : 'data.tabs.fleet.costNoteZh'),
624
663
  ]
625
664
 
626
665
  return {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dshgo-context-panel",
3
- "version": "0.1.0",
4
- "description": "Native context monitor for DSH Go: usage trends, tools, files, compaction and bounded local insights.",
3
+ "version": "0.1.2",
4
+ "description": "Native context monitor for DSH Go: usage trends, tools, files, compaction, bounded local insights and per-model cost estimates.",
5
5
  "homepage": "https://github.com/LingMowen/dshgo-context-panel",
6
6
  "repository": {
7
7
  "type": "git",
package/web/client.js CHANGED
@@ -633,6 +633,10 @@
633
633
  h('p', { style: S.itemSub }, text(en ? fleet.caption && fleet.caption.en : fleet.caption && fleet.caption.zh)),
634
634
  h('p', { style: S.itemSub }, text(en ? fleet.archiveStatusEn : fleet.archiveStatusZh)),
635
635
  h('p', { style: S.itemSub }, text(en ? fleet.insightsEn : fleet.insightsZh)),
636
+ h('p', { style: S.itemSub }, h('strong', null, t('计费估算', 'Cost estimate'))),
637
+ h('p', { style: S.itemSub }, text(en ? fleet.costTotalEn : fleet.costTotalZh)),
638
+ h(Items, { items: (en ? fleet.costItemsEn : fleet.costItemsZh) || [] }),
639
+ h('p', { style: S.itemSub }, text(en ? fleet.costNoteEn : fleet.costNoteZh)),
636
640
  )
637
641
  }
638
642
  },