@trazum/core 2.6.0 → 2.7.1

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 (48) hide show
  1. package/dist/billing.d.ts.map +1 -1
  2. package/dist/billing.js +2 -1
  3. package/dist/billing.js.map +1 -1
  4. package/dist/claude-code.d.ts +2 -0
  5. package/dist/claude-code.d.ts.map +1 -1
  6. package/dist/claude-code.js +6 -0
  7. package/dist/claude-code.js.map +1 -1
  8. package/dist/gateway.d.ts +8 -0
  9. package/dist/gateway.d.ts.map +1 -1
  10. package/dist/gateway.js +55 -12
  11. package/dist/gateway.js.map +1 -1
  12. package/dist/gemini-cli.d.ts +65 -0
  13. package/dist/gemini-cli.d.ts.map +1 -0
  14. package/dist/gemini-cli.js +162 -0
  15. package/dist/gemini-cli.js.map +1 -0
  16. package/dist/harnesses.d.ts +2 -2
  17. package/dist/harnesses.d.ts.map +1 -1
  18. package/dist/harnesses.js +1 -0
  19. package/dist/harnesses.js.map +1 -1
  20. package/dist/index.d.ts +5 -2
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +5 -1
  23. package/dist/index.js.map +1 -1
  24. package/dist/pricing.d.ts +2 -0
  25. package/dist/pricing.d.ts.map +1 -1
  26. package/dist/pricing.js +504 -22
  27. package/dist/pricing.js.map +1 -1
  28. package/dist/slim-line.d.ts +37 -0
  29. package/dist/slim-line.d.ts.map +1 -0
  30. package/dist/slim-line.js +68 -0
  31. package/dist/slim-line.js.map +1 -0
  32. package/dist/types.d.ts +16 -0
  33. package/dist/types.d.ts.map +1 -1
  34. package/dist/usage.d.ts +48 -0
  35. package/dist/usage.d.ts.map +1 -1
  36. package/dist/usage.js +129 -7
  37. package/dist/usage.js.map +1 -1
  38. package/package.json +2 -2
  39. package/src/billing.ts +2 -1
  40. package/src/claude-code.ts +8 -0
  41. package/src/gateway.ts +61 -11
  42. package/src/gemini-cli.ts +187 -0
  43. package/src/harnesses.ts +3 -2
  44. package/src/index.ts +10 -0
  45. package/src/pricing.ts +510 -22
  46. package/src/slim-line.ts +66 -0
  47. package/src/types.ts +14 -1
  48. package/src/usage.ts +174 -7
package/dist/pricing.js CHANGED
@@ -33,8 +33,18 @@ export const PROVIDER_REVIEWED = Object.freeze({
33
33
  * each model's own page, read 2026-10-10. Every existing row matched and
34
34
  * five models were added. Claude Haiku 5.5 waited for per-request pricing,
35
35
  * because it bills by prompt length, and was added with it on 2026-10-11.
36
+ *
37
+ * Re-read 2026-11-05 with the fast-mode, deprecations and prompt-caching
38
+ * pages. Every existing price matched. Two things were missing: fast mode,
39
+ * which bills Opus 5.5 at $8/$40 and Opus 5 and 4.8 at $10/$50 and which
40
+ * every response records in `usage.speed`, so fast calls had been priced at
41
+ * half their cost; and Claude Sonnet 4.5, deprecated but still served until
42
+ * 2026-11-30, which read as unpriced. Both are here now. The retired Opus
43
+ * 4.1, Opus 4, Sonnet 4 and Haiku 3.5 are on the pricing page too and are
44
+ * not priced here yet: a row needs a context window, which their own pages
45
+ * would give, and those were not read.
36
46
  */
37
- anthropic: '2026-10-10',
47
+ anthropic: '2026-11-05',
38
48
  /*
39
49
  * developers.openai.com/api/docs/pricing, read 2026-08-31.
40
50
  *
@@ -55,8 +65,16 @@ export const PROVIDER_REVIEWED = Object.freeze({
55
65
  * gpt-6-sol, gpt-6-luna and gpt-5.6 sol, terra and luna) waited for
56
66
  * per-request pricing, since each doubles its rates for prompts over 272K
57
67
  * tokens, and was added with it the same day, from each model's own page.
68
+ *
69
+ * Re-read 2026-11-05: pricing.md, prompt-caching.md and every model page
70
+ * named below, in their Markdown form. Every existing price matched. New:
71
+ * GPT-6.1 Terra; a 12-hour cache write at 2.5x input on GPT-5.6 and later,
72
+ * which the usage object splits from the 30-minute kind and which was being
73
+ * priced as one, at half its cost; and sixteen earlier models that are still
74
+ * billed and still in logs (GPT-5.5, 5.4, 5.2, 5.1 and their mini, nano and
75
+ * pro siblings, GPT-5 pro, GPT-4.1, GPT-4o and o3), none of which was priced.
58
76
  */
59
- openai: '2026-10-11',
77
+ openai: '2026-11-05',
60
78
  /*
61
79
  * ai.google.dev/gemini-api/docs/pricing, docs/caching and the model pages,
62
80
  * read 2026-10-10. Every price matched; what changed is how caching starts
@@ -76,8 +94,14 @@ export const PROVIDER_REVIEWED = Object.freeze({
76
94
  * and added nothing. Kimi K3, K2.7 Code (and its high-speed variant) and
77
95
  * K2.6 are priced now. `kimi-k2` was discontinued on 2026-05-25 by the
78
96
  * provider's own notice, so it stays priced and is no longer recommended.
97
+ *
98
+ * Re-read 2026-11-05 from the HTML page's compiled tables, the Markdown
99
+ * form now serving them empty. Every price matched; K3.1 Pro and its
100
+ * high-speed variant are added, K3 gains its 60% batch price, and the K2
101
+ * series, closed to new accounts and retiring in December, is no longer
102
+ * recommended.
79
103
  */
80
- moonshot: '2026-10-11',
104
+ moonshot: '2026-11-05',
81
105
  /*
82
106
  * api-docs.deepseek.com/quick_start/pricing read 2026-10-10, and the
83
107
  * 2026-09-10 announcement (api-docs.deepseek.com/news/news260910) read
@@ -85,8 +109,13 @@ export const PROVIDER_REVIEWED = Object.freeze({
85
109
  * Sept 10, 2026." V4 Flash was retired that day and its id now bills at
86
110
  * the new deepseek-flash price, so the old price lives in its `history`.
87
111
  * V4 Pro matched the page unchanged.
112
+ *
113
+ * Re-read 2026-11-05: every price, the peak window (01:00-04:00 and
114
+ * 06:00-10:00 UTC, Monday to Friday, Chinese public holidays off-peak in
115
+ * full) and the cache-hit prices matched. The Flash version behind
116
+ * `deepseek-flash` is now named DeepSeek-V4.1-Flash-1017, at the same price.
88
117
  */
89
- deepseek: '2026-10-10',
118
+ deepseek: '2026-11-05',
90
119
  /*
91
120
  * docs.x.ai/developers/models, each model's page and the 2026-05-15
92
121
  * retirement notice, read 2026-10-11 in their Markdown form. Grok 4.7, 4.6,
@@ -94,8 +123,11 @@ export const PROVIDER_REVIEWED = Object.freeze({
94
123
  * request pays once its prompt reaches 200k tokens, which per-request
95
124
  * pricing can now express. `grok-4` was retired on 2026-05-15 and its calls
96
125
  * have billed at Grok 4.3's prices since, so it carries both periods.
126
+ *
127
+ * Re-read 2026-11-05 (docs.x.ai/developers/models.md): every model, price,
128
+ * cached price, 200k threshold and context window matched. Nothing new.
97
129
  */
98
- xai: '2026-10-11',
130
+ xai: '2026-11-05',
99
131
  /*
100
132
  * `mistral.ai/pricing`, read 2026-08-28 — by a human, because the page
101
133
  * renders its table in the browser and serves a fetch only an FAQ example
@@ -116,8 +148,13 @@ export const PROVIDER_REVIEWED = Object.freeze({
116
148
  * price as carrying the cache discount. This table said Mistral had no
117
149
  * prompt caching at all. docs.mistral.ai, where a minimum or a mechanism
118
150
  * would be, is not reachable from here, so neither is claimed.
151
+ *
152
+ * Re-read 2026-11-05 from the same three model cards' `data-prices` and
153
+ * mistral.ai/cloud/inference: Large 2512 at $0.50/$1.50, Medium 3.5 at
154
+ * $1.50/$7.50 and Small 2603 at $0.15/$0.60 matched, as did the 90% cached
155
+ * input discount. docs.mistral.ai is still not reachable from here.
119
156
  */
120
- mistral: '2026-10-11',
157
+ mistral: '2026-11-05',
121
158
  });
122
159
  /**
123
160
  * The catalogue's age is its oldest provider's, because a reader asking how
@@ -204,10 +241,22 @@ const GROK_LONG = (inputPerMTok, outputPerMTok) => ({
204
241
  * carrying this sentence, so a forgotten minimum cannot pass as a deliberate one.
205
242
  */
206
243
  const NO_PUBLISHED_CACHE_MINIMUM = 'Caches automatically, but no minimum prefix length is published, so no caching advice is given for it.';
207
- /** OpenAI's GPT-5.6 and later: one cache entry, living at least 30 minutes. */
208
- const OPENAI_CACHE_TTL = Object.freeze({ writeMs: 30 * 60_000, longerMs: null });
244
+ /**
245
+ * OpenAI's GPT-5.6 and later: an entry lives at least 30 minutes by default,
246
+ * and the Responses API sells a 12-hour one (`prompt_cache_options.ttl`). The
247
+ * two write prices are the `cacheWrite5m` and `cacheWrite1h` multipliers: the
248
+ * catalogue's short and long write, whatever each provider's durations.
249
+ */
250
+ const OPENAI_CACHE_TTL = Object.freeze({ writeMs: 30 * 60_000, longerMs: 12 * 60 * 60_000 });
209
251
  const OPENAI_CURRENT_NOTE = 'Priced per request by prompt length: over 272,000 input tokens, 2x input and cache and 1.5x output for'
210
- + ' the whole request. Cache writes cost 1.25x input and an entry lives at least 30 minutes.';
252
+ + ' the whole request. Cache writes cost 1.25x input for the default 30-minute entry and 2.5x for a'
253
+ + ' 12-hour one (Responses API).';
254
+ const OPENAI_EARLIER_NOTE = 'Caching is automatic; a write costs what input costs. OpenAI says the minimum for models before GPT-5.6 varies by'
255
+ + ' request settings, so 1,024 here is the nearest published floor.';
256
+ const OPENAI_EARLIER_LONG_NOTE = 'Priced per request by prompt length: over 272,000 input tokens, 2x input and 1.5x output for the whole request. '
257
+ + OPENAI_EARLIER_NOTE;
258
+ const OPENAI_EARLIER_NO_CACHE_NOTE = 'OpenAI publishes no cached-input price for this model, so caching is not priced.';
259
+ const OPENAI_DEPRECATED_SUFFIX = ' Deprecated by OpenAI: priced for the logs that hold it, never recommended.';
211
260
  const OPENAI_GPT5_NOTE = 'Caching is automatic, with no cache_control to set. OpenAI says the minimum for models before GPT-5.6 varies by'
212
261
  + ' request settings, so 1,024 here is the nearest published floor. The 2025-08-07 snapshot shuts down on'
213
262
  + ' 2026-12-11; OpenAI names the gpt-5.6 models as replacements.';
@@ -295,9 +344,18 @@ export const MODELS = [
295
344
  contextWindow: 1_000_000,
296
345
  cacheMinTokens: 512,
297
346
  multipliers: { cacheRead: 0.05, cacheWrite5m: 1.25, cacheWrite1h: 2, batch: 0.5 },
347
+ /*
348
+ * Fast mode, read 2026-11-05 from platform.claude.com/docs/en/about-claude/
349
+ * pricing#fast-mode-pricing and build-with-claude/fast-mode: $8/$40 "across
350
+ * the full context window", with the caching multipliers "on top", which is
351
+ * how a tier's rate already feeds the cache prices here. The response's
352
+ * `usage.speed` says which speed ran.
353
+ */
354
+ tiers: [{ id: 'fast', when: { kind: 'speed', speed: 'fast' }, inputPerMTok: 8, outputPerMTok: 40 }],
298
355
  capability: 'large',
299
356
  tier: 'opus',
300
- notes: 'Cache hits cost 5% of the input price ($0.20), against 10% on Opus 5 and earlier.',
357
+ notes: 'Cache hits cost 5% of the input price ($0.20), against 10% on Opus 5 and earlier.'
358
+ + ' Fast mode (usage.speed "fast") bills $8/$40.',
301
359
  },
302
360
  {
303
361
  id: 'claude-opus-5',
@@ -307,9 +365,11 @@ export const MODELS = [
307
365
  outputPerMTok: 25,
308
366
  contextWindow: 1_000_000,
309
367
  cacheMinTokens: 512,
368
+ // Fast mode in research preview, $10/$50; same sources as Opus 5.5's.
369
+ tiers: [{ id: 'fast', when: { kind: 'speed', speed: 'fast' }, inputPerMTok: 10, outputPerMTok: 50 }],
310
370
  capability: 'large',
311
371
  tier: 'opus',
312
- notes: '512-token cache minimum: caches prompts that would miss on Opus 4.6.',
372
+ notes: '512-token cache minimum: caches prompts that would miss on Opus 4.6. Fast mode bills $10/$50.',
313
373
  },
314
374
  {
315
375
  id: 'claude-opus-4-8',
@@ -319,8 +379,15 @@ export const MODELS = [
319
379
  outputPerMTok: 25,
320
380
  contextWindow: 1_000_000,
321
381
  cacheMinTokens: 1024,
382
+ /*
383
+ * Fast mode in research preview, $10/$50; same sources as Opus 5.5's. It is
384
+ * deprecated on this model and removed on 2026-11-30, after which no
385
+ * response records it, so the tier only ever prices calls that ran fast.
386
+ */
387
+ tiers: [{ id: 'fast', when: { kind: 'speed', speed: 'fast' }, inputPerMTok: 10, outputPerMTok: 50 }],
322
388
  capability: 'large',
323
389
  tier: 'opus',
390
+ notes: 'Fast mode bills $10/$50 until it is removed from this model on 2026-11-30.',
324
391
  },
325
392
  {
326
393
  id: 'claude-opus-4-7',
@@ -407,6 +474,29 @@ export const MODELS = [
407
474
  capability: 'mid',
408
475
  tier: 'sonnet',
409
476
  },
477
+ {
478
+ /*
479
+ * Its own model page (platform.claude.com/docs/en/models/sonnet-4-5/
480
+ * overview), the pricing page, the prompt-caching page and the
481
+ * deprecations page, read 2026-11-05. $3/$15, writes $3.75 and $6, cache
482
+ * read $0.30, batch 50% off, 200K context, 1,024-token cache minimum.
483
+ * Deprecated on 2026-09-30 and retiring on 2026-11-30, so it is priced (it
484
+ * is in every log of the last year) and never recommended. It was missing
485
+ * here, so every Sonnet 4.5 call read as an unpriced model.
486
+ */
487
+ id: 'claude-sonnet-4-5',
488
+ aliases: ['claude-sonnet-4-5-20250929'],
489
+ provider: 'anthropic',
490
+ displayName: 'Claude Sonnet 4.5',
491
+ recommendable: false,
492
+ inputPerMTok: 3,
493
+ outputPerMTok: 15,
494
+ contextWindow: 200_000,
495
+ cacheMinTokens: 1024,
496
+ capability: 'mid',
497
+ tier: 'sonnet',
498
+ notes: 'Deprecated; retires 2026-11-30. Recommended replacement: Claude Sonnet 5.5.',
499
+ },
410
500
  {
411
501
  /*
412
502
  * The pricing page, the models overview and the prompt-caching page, read
@@ -483,8 +573,17 @@ export const MODELS = [
483
573
  // - **Cache writes are billed**, at 1.25x the uncached input rate, and the
484
574
  // usage object reports them (`cache_write_tokens`). Reads are 10% of input,
485
575
  // 5% on GPT-6.1 Sol.
486
- // - **An entry lives at least 30 minutes** after its last write or read, and
487
- // there is no longer one to buy: `cacheTtl`.
576
+ // - **An entry lives at least 30 minutes** after its last write or read:
577
+ // `cacheTtl`. On 2026-10-11 there was no longer one to buy.
578
+ //
579
+ // Re-read 2026-11-05 (pricing.md, prompt-caching.md and the GPT-6.1 pages,
580
+ // in their Markdown form). Every price matched. Two things are new: GPT-6.1
581
+ // Terra, and a **12-hour cache write** in the Responses API at 2.5x input
582
+ // (`prompt_cache_options.ttl: "12h"`), reported in
583
+ // `input_tokens_details.cache_write_tokens_details` as `ttl_30m_tokens` and
584
+ // `ttl_12h_tokens`, "both fields returned, including when one is zero". A
585
+ // 12-hour write is the long write here; read as a 30-minute one, it was
586
+ // priced at half its cost.
488
587
  //
489
588
  // Caching is implicit by default (a breakpoint at the end of the latest
490
589
  // eligible message) from a 1,024-token minimum. Batch and Flex are half
@@ -501,7 +600,7 @@ export const MODELS = [
501
600
  contextWindow: 1_050_000,
502
601
  cacheMinTokens: 1024,
503
602
  caching: 'automatic',
504
- multipliers: { cacheRead: 0.1, cacheWrite5m: 1.25, cacheWrite1h: 1.25, batch: 0.5 },
603
+ multipliers: { cacheRead: 0.1, cacheWrite5m: 1.25, cacheWrite1h: 2.5, batch: 0.5 },
505
604
  cacheTtl: OPENAI_CACHE_TTL,
506
605
  tiers: [
507
606
  {
@@ -524,7 +623,7 @@ export const MODELS = [
524
623
  contextWindow: 1_050_000,
525
624
  cacheMinTokens: 1024,
526
625
  caching: 'automatic',
527
- multipliers: { cacheRead: 0.05, cacheWrite5m: 1.25, cacheWrite1h: 1.25, batch: 0.5 },
626
+ multipliers: { cacheRead: 0.05, cacheWrite5m: 1.25, cacheWrite1h: 2.5, batch: 0.5 },
528
627
  cacheTtl: OPENAI_CACHE_TTL,
529
628
  tiers: [
530
629
  {
@@ -538,6 +637,35 @@ export const MODELS = [
538
637
  tier: 'opus',
539
638
  notes: OPENAI_CURRENT_NOTE,
540
639
  },
640
+ {
641
+ /*
642
+ * developers.openai.com/api/docs/models/gpt-6.1-terra.md, read 2026-11-05:
643
+ * $1/$5, cached input $0.05 ("5% of the uncached input token rate"), cache
644
+ * writes $1.25 for 30 minutes and $2.50 for 12 hours, the same 272K band,
645
+ * 1,050,000 context, 922,000 input and 128,000 output.
646
+ */
647
+ id: 'gpt-6.1-terra',
648
+ provider: 'openai',
649
+ displayName: 'GPT-6.1 Terra',
650
+ inputPerMTok: 1,
651
+ outputPerMTok: 5,
652
+ contextWindow: 1_050_000,
653
+ cacheMinTokens: 1024,
654
+ caching: 'automatic',
655
+ multipliers: { cacheRead: 0.05, cacheWrite5m: 1.25, cacheWrite1h: 2.5, batch: 0.5 },
656
+ cacheTtl: OPENAI_CACHE_TTL,
657
+ tiers: [
658
+ {
659
+ id: 'over-272k',
660
+ when: { kind: 'input-tokens-above', tokens: 272_000 },
661
+ inputPerMTok: 2,
662
+ outputPerMTok: 7.5,
663
+ },
664
+ ],
665
+ capability: 'mid',
666
+ tier: 'sonnet',
667
+ notes: OPENAI_CURRENT_NOTE,
668
+ },
541
669
  {
542
670
  id: 'gpt-6-sol',
543
671
  provider: 'openai',
@@ -547,7 +675,7 @@ export const MODELS = [
547
675
  contextWindow: 1_050_000,
548
676
  cacheMinTokens: 1024,
549
677
  caching: 'automatic',
550
- multipliers: { cacheRead: 0.1, cacheWrite5m: 1.25, cacheWrite1h: 1.25, batch: 0.5 },
678
+ multipliers: { cacheRead: 0.1, cacheWrite5m: 1.25, cacheWrite1h: 2.5, batch: 0.5 },
551
679
  cacheTtl: OPENAI_CACHE_TTL,
552
680
  tiers: [
553
681
  {
@@ -570,7 +698,7 @@ export const MODELS = [
570
698
  contextWindow: 1_050_000,
571
699
  cacheMinTokens: 1024,
572
700
  caching: 'automatic',
573
- multipliers: { cacheRead: 0.1, cacheWrite5m: 1.25, cacheWrite1h: 1.25, batch: 0.5 },
701
+ multipliers: { cacheRead: 0.1, cacheWrite5m: 1.25, cacheWrite1h: 2.5, batch: 0.5 },
574
702
  cacheTtl: OPENAI_CACHE_TTL,
575
703
  tiers: [
576
704
  {
@@ -593,7 +721,7 @@ export const MODELS = [
593
721
  contextWindow: 1_050_000,
594
722
  cacheMinTokens: 1024,
595
723
  caching: 'automatic',
596
- multipliers: { cacheRead: 0.1, cacheWrite5m: 1.25, cacheWrite1h: 1.25, batch: 0.5 },
724
+ multipliers: { cacheRead: 0.1, cacheWrite5m: 1.25, cacheWrite1h: 2.5, batch: 0.5 },
597
725
  cacheTtl: OPENAI_CACHE_TTL,
598
726
  tiers: [
599
727
  {
@@ -616,7 +744,7 @@ export const MODELS = [
616
744
  contextWindow: 1_050_000,
617
745
  cacheMinTokens: 1024,
618
746
  caching: 'automatic',
619
- multipliers: { cacheRead: 0.1, cacheWrite5m: 1.25, cacheWrite1h: 1.25, batch: 0.5 },
747
+ multipliers: { cacheRead: 0.1, cacheWrite5m: 1.25, cacheWrite1h: 2.5, batch: 0.5 },
620
748
  cacheTtl: OPENAI_CACHE_TTL,
621
749
  tiers: [
622
750
  {
@@ -639,7 +767,7 @@ export const MODELS = [
639
767
  contextWindow: 1_050_000,
640
768
  cacheMinTokens: 1024,
641
769
  caching: 'automatic',
642
- multipliers: { cacheRead: 0.1, cacheWrite5m: 1.25, cacheWrite1h: 1.25, batch: 0.5 },
770
+ multipliers: { cacheRead: 0.1, cacheWrite5m: 1.25, cacheWrite1h: 2.5, batch: 0.5 },
643
771
  cacheTtl: OPENAI_CACHE_TTL,
644
772
  tiers: [
645
773
  {
@@ -700,6 +828,303 @@ export const MODELS = [
700
828
  notes: OPENAI_GPT5_NOTE,
701
829
  },
702
830
  // ------------------------------------------------------------------------
831
+ // OpenAI's earlier models, still billed and still in logs.
832
+ //
833
+ // developers.openai.com/api/docs/pricing.md (Standard and Batch tables) and
834
+ // each model's own page (models/<id>.md), read 2026-11-05 in their Markdown
835
+ // form. None was priced here, so every call to gpt-4o, gpt-4.1, o3 or a
836
+ // GPT-5.x before 5.6 read as an unpriced model. Prices, cached-input prices
837
+ // and context windows are each page's own; the dated snapshot ids are the
838
+ // ones each page lists, except gpt-4o-2024-05-13, which is shut down and
839
+ // priced differently from the current gpt-4o. A cached read costs what the
840
+ // page says (10% of input on GPT-5.x, 25% on GPT-4.1 and o3, 50% on GPT-4o);
841
+ // a write costs what input costs, as on GPT-5. The pro models publish no
842
+ // cached price and are not cached. Models whose page says "Status:
843
+ // Deprecated" are priced and never recommended. GPT-5.5, GPT-5.5 pro, GPT-5.4
844
+ // and GPT-5.4 pro bill a prompt over 272K at 2x input and 1.5x output.
845
+ // ------------------------------------------------------------------------
846
+ {
847
+ id: 'gpt-5.5',
848
+ aliases: ['gpt-5.5-2026-04-23'],
849
+ provider: 'openai',
850
+ displayName: 'GPT-5.5',
851
+ inputPerMTok: 5,
852
+ outputPerMTok: 30,
853
+ contextWindow: 1_050_000,
854
+ cacheMinTokens: 1024,
855
+ caching: 'automatic',
856
+ multipliers: { cacheRead: 0.1, cacheWrite5m: 1, cacheWrite1h: 1, batch: 0.5 },
857
+ tiers: [
858
+ {
859
+ id: 'over-272k',
860
+ when: { kind: 'input-tokens-above', tokens: 272_000 },
861
+ inputPerMTok: 10,
862
+ outputPerMTok: 45,
863
+ },
864
+ ],
865
+ capability: 'frontier',
866
+ tier: 'frontier',
867
+ notes: OPENAI_EARLIER_LONG_NOTE,
868
+ },
869
+ {
870
+ id: 'gpt-5.5-pro',
871
+ aliases: ['gpt-5.5-pro-2026-04-23'],
872
+ provider: 'openai',
873
+ displayName: 'GPT-5.5 pro',
874
+ inputPerMTok: 30,
875
+ outputPerMTok: 180,
876
+ contextWindow: 1_050_000,
877
+ cacheMinTokens: 0,
878
+ caching: 'none',
879
+ multipliers: { batch: 0.5 },
880
+ tiers: [
881
+ {
882
+ id: 'over-272k',
883
+ when: { kind: 'input-tokens-above', tokens: 272_000 },
884
+ inputPerMTok: 60,
885
+ outputPerMTok: 270,
886
+ },
887
+ ],
888
+ capability: 'frontier',
889
+ tier: 'frontier',
890
+ notes: OPENAI_EARLIER_LONG_NOTE,
891
+ },
892
+ {
893
+ id: 'gpt-5.4',
894
+ aliases: ['gpt-5.4-2026-03-05'],
895
+ provider: 'openai',
896
+ displayName: 'GPT-5.4',
897
+ inputPerMTok: 2.5,
898
+ outputPerMTok: 15,
899
+ contextWindow: 1_050_000,
900
+ cacheMinTokens: 1024,
901
+ caching: 'automatic',
902
+ multipliers: { cacheRead: 0.1, cacheWrite5m: 1, cacheWrite1h: 1, batch: 0.5 },
903
+ tiers: [
904
+ {
905
+ id: 'over-272k',
906
+ when: { kind: 'input-tokens-above', tokens: 272_000 },
907
+ inputPerMTok: 5,
908
+ outputPerMTok: 22.5,
909
+ },
910
+ ],
911
+ capability: 'frontier',
912
+ tier: 'frontier',
913
+ notes: OPENAI_EARLIER_LONG_NOTE,
914
+ },
915
+ {
916
+ id: 'gpt-5.4-pro',
917
+ aliases: ['gpt-5.4-pro-2026-03-05'],
918
+ provider: 'openai',
919
+ displayName: 'GPT-5.4 pro',
920
+ inputPerMTok: 30,
921
+ outputPerMTok: 180,
922
+ contextWindow: 1_050_000,
923
+ cacheMinTokens: 0,
924
+ caching: 'none',
925
+ multipliers: { batch: 0.5 },
926
+ tiers: [
927
+ {
928
+ id: 'over-272k',
929
+ when: { kind: 'input-tokens-above', tokens: 272_000 },
930
+ inputPerMTok: 60,
931
+ outputPerMTok: 270,
932
+ },
933
+ ],
934
+ capability: 'frontier',
935
+ tier: 'frontier',
936
+ notes: OPENAI_EARLIER_LONG_NOTE,
937
+ },
938
+ {
939
+ id: 'gpt-5.4-mini',
940
+ aliases: ['gpt-5.4-mini-2026-03-17'],
941
+ provider: 'openai',
942
+ displayName: 'GPT-5.4 mini',
943
+ inputPerMTok: 0.75,
944
+ outputPerMTok: 4.5,
945
+ contextWindow: 400_000,
946
+ cacheMinTokens: 1024,
947
+ caching: 'automatic',
948
+ multipliers: { cacheRead: 0.1, cacheWrite5m: 1, cacheWrite1h: 1, batch: 0.5 },
949
+ capability: 'mid',
950
+ tier: 'sonnet',
951
+ notes: OPENAI_EARLIER_NOTE,
952
+ },
953
+ {
954
+ id: 'gpt-5.4-nano',
955
+ aliases: ['gpt-5.4-nano-2026-03-17'],
956
+ provider: 'openai',
957
+ displayName: 'GPT-5.4 nano',
958
+ recommendable: false,
959
+ inputPerMTok: 0.2,
960
+ outputPerMTok: 1.25,
961
+ contextWindow: 400_000,
962
+ cacheMinTokens: 1024,
963
+ caching: 'automatic',
964
+ multipliers: { cacheRead: 0.1, cacheWrite5m: 1, cacheWrite1h: 1, batch: 0.5 },
965
+ capability: 'small',
966
+ tier: 'haiku',
967
+ notes: OPENAI_EARLIER_NOTE + OPENAI_DEPRECATED_SUFFIX,
968
+ },
969
+ {
970
+ id: 'gpt-5.2',
971
+ aliases: ['gpt-5.2-2025-12-11'],
972
+ provider: 'openai',
973
+ displayName: 'GPT-5.2',
974
+ inputPerMTok: 1.75,
975
+ outputPerMTok: 14,
976
+ contextWindow: 400_000,
977
+ cacheMinTokens: 1024,
978
+ caching: 'automatic',
979
+ multipliers: { cacheRead: 0.1, cacheWrite5m: 1, cacheWrite1h: 1, batch: 0.5 },
980
+ capability: 'frontier',
981
+ tier: 'frontier',
982
+ notes: OPENAI_EARLIER_NOTE,
983
+ },
984
+ {
985
+ id: 'gpt-5.2-pro',
986
+ aliases: ['gpt-5.2-pro-2025-12-11'],
987
+ provider: 'openai',
988
+ displayName: 'GPT-5.2 pro',
989
+ inputPerMTok: 21,
990
+ outputPerMTok: 168,
991
+ contextWindow: 400_000,
992
+ cacheMinTokens: 0,
993
+ caching: 'none',
994
+ multipliers: { batch: 0.5 },
995
+ capability: 'frontier',
996
+ tier: 'frontier',
997
+ notes: OPENAI_EARLIER_NO_CACHE_NOTE,
998
+ },
999
+ {
1000
+ id: 'gpt-5.1',
1001
+ aliases: ['gpt-5.1-2025-11-13'],
1002
+ provider: 'openai',
1003
+ displayName: 'GPT-5.1',
1004
+ recommendable: false,
1005
+ inputPerMTok: 1.25,
1006
+ outputPerMTok: 10,
1007
+ contextWindow: 400_000,
1008
+ cacheMinTokens: 1024,
1009
+ caching: 'automatic',
1010
+ multipliers: { cacheRead: 0.1, cacheWrite5m: 1, cacheWrite1h: 1, batch: 0.5 },
1011
+ capability: 'frontier',
1012
+ tier: 'frontier',
1013
+ notes: OPENAI_EARLIER_NOTE + OPENAI_DEPRECATED_SUFFIX,
1014
+ },
1015
+ {
1016
+ id: 'gpt-5-pro',
1017
+ aliases: ['gpt-5-pro-2025-10-06'],
1018
+ provider: 'openai',
1019
+ displayName: 'GPT-5 pro',
1020
+ recommendable: false,
1021
+ inputPerMTok: 15,
1022
+ outputPerMTok: 120,
1023
+ contextWindow: 400_000,
1024
+ cacheMinTokens: 0,
1025
+ caching: 'none',
1026
+ multipliers: { batch: 0.5 },
1027
+ capability: 'frontier',
1028
+ tier: 'frontier',
1029
+ notes: OPENAI_EARLIER_NO_CACHE_NOTE + OPENAI_DEPRECATED_SUFFIX,
1030
+ },
1031
+ {
1032
+ id: 'gpt-4.1',
1033
+ aliases: ['gpt-4.1-2025-04-14'],
1034
+ provider: 'openai',
1035
+ displayName: 'GPT-4.1',
1036
+ recommendable: false,
1037
+ inputPerMTok: 2,
1038
+ outputPerMTok: 8,
1039
+ contextWindow: 1_047_576,
1040
+ cacheMinTokens: 1024,
1041
+ caching: 'automatic',
1042
+ multipliers: { cacheRead: 0.25, cacheWrite5m: 1, cacheWrite1h: 1, batch: 0.5 },
1043
+ capability: 'large',
1044
+ tier: 'opus',
1045
+ notes: OPENAI_EARLIER_NOTE + OPENAI_DEPRECATED_SUFFIX,
1046
+ },
1047
+ {
1048
+ id: 'gpt-4.1-mini',
1049
+ aliases: ['gpt-4.1-mini-2025-04-14'],
1050
+ provider: 'openai',
1051
+ displayName: 'GPT-4.1 mini',
1052
+ recommendable: false,
1053
+ inputPerMTok: 0.4,
1054
+ outputPerMTok: 1.6,
1055
+ contextWindow: 1_047_576,
1056
+ cacheMinTokens: 1024,
1057
+ caching: 'automatic',
1058
+ multipliers: { cacheRead: 0.25, cacheWrite5m: 1, cacheWrite1h: 1, batch: 0.5 },
1059
+ capability: 'mid',
1060
+ tier: 'sonnet',
1061
+ notes: OPENAI_EARLIER_NOTE + OPENAI_DEPRECATED_SUFFIX,
1062
+ },
1063
+ {
1064
+ id: 'gpt-4o',
1065
+ aliases: ['gpt-4o-2024-11-20', 'gpt-4o-2024-08-06'],
1066
+ provider: 'openai',
1067
+ displayName: 'GPT-4o',
1068
+ recommendable: false,
1069
+ inputPerMTok: 2.5,
1070
+ outputPerMTok: 10,
1071
+ contextWindow: 128_000,
1072
+ cacheMinTokens: 1024,
1073
+ caching: 'automatic',
1074
+ multipliers: { cacheRead: 0.5, cacheWrite5m: 1, cacheWrite1h: 1, batch: 0.5 },
1075
+ capability: 'large',
1076
+ tier: 'opus',
1077
+ notes: OPENAI_EARLIER_NOTE + OPENAI_DEPRECATED_SUFFIX,
1078
+ },
1079
+ {
1080
+ id: 'gpt-4o-mini',
1081
+ aliases: ['gpt-4o-mini-2024-07-18'],
1082
+ provider: 'openai',
1083
+ displayName: 'GPT-4o mini',
1084
+ recommendable: false,
1085
+ inputPerMTok: 0.15,
1086
+ outputPerMTok: 0.6,
1087
+ contextWindow: 128_000,
1088
+ cacheMinTokens: 1024,
1089
+ caching: 'automatic',
1090
+ multipliers: { cacheRead: 0.5, cacheWrite5m: 1, cacheWrite1h: 1, batch: 0.5 },
1091
+ capability: 'small',
1092
+ tier: 'haiku',
1093
+ notes: OPENAI_EARLIER_NOTE + OPENAI_DEPRECATED_SUFFIX,
1094
+ },
1095
+ {
1096
+ id: 'o3',
1097
+ aliases: ['o3-2025-04-16'],
1098
+ provider: 'openai',
1099
+ displayName: 'o3',
1100
+ recommendable: false,
1101
+ inputPerMTok: 2,
1102
+ outputPerMTok: 8,
1103
+ contextWindow: 200_000,
1104
+ cacheMinTokens: 1024,
1105
+ caching: 'automatic',
1106
+ multipliers: { cacheRead: 0.25, cacheWrite5m: 1, cacheWrite1h: 1, batch: 0.5 },
1107
+ capability: 'frontier',
1108
+ tier: 'frontier',
1109
+ notes: OPENAI_EARLIER_NOTE + OPENAI_DEPRECATED_SUFFIX,
1110
+ },
1111
+ {
1112
+ id: 'o3-pro',
1113
+ aliases: ['o3-pro-2025-06-10'],
1114
+ provider: 'openai',
1115
+ displayName: 'o3-pro',
1116
+ recommendable: false,
1117
+ inputPerMTok: 20,
1118
+ outputPerMTok: 80,
1119
+ contextWindow: 200_000,
1120
+ cacheMinTokens: 0,
1121
+ caching: 'none',
1122
+ multipliers: { batch: 0.5 },
1123
+ capability: 'frontier',
1124
+ tier: 'frontier',
1125
+ notes: OPENAI_EARLIER_NO_CACHE_NOTE + OPENAI_DEPRECATED_SUFFIX,
1126
+ },
1127
+ // ------------------------------------------------------------------------
703
1128
  // Google
704
1129
  // ------------------------------------------------------------------------
705
1130
  {
@@ -849,7 +1274,53 @@ export const MODELS = [
849
1274
  * $0.30. The K2 series bills no write, and reads at its own hit price. Batch
850
1275
  * is 60% of standard on K2.7 Code and K2.6 and not offered on K3 or the
851
1276
  * high-speed K2.7. No cache minimum is published for any of them.
1277
+ *
1278
+ * Re-read 2026-11-05. The Markdown form now ships the price tables empty
1279
+ * (`<tbody />`); the figures are in the HTML page's compiled table rows,
1280
+ * read there. Every existing price matched. Three changes: Kimi K3.1 Pro
1281
+ * and its high-speed variant are new; the batch page now lists K3 and K3.1
1282
+ * Pro at 60% ("billed at 60% of the standard price"), so K3 has a batch
1283
+ * price; and the K2 series is closed to accounts registered from 2026-11-01
1284
+ * and retires "by the end of December 2026", so it is no longer recommended.
852
1285
  */
1286
+ {
1287
+ /*
1288
+ * $2/$10, cached input $0.20, cache writes $2.00 for 5 minutes and $4.00
1289
+ * for an hour; batch 60%; 1,048,576 context, as every K3-series model.
1290
+ */
1291
+ id: 'kimi-k3.1-pro',
1292
+ provider: 'moonshot',
1293
+ displayName: 'Kimi K3.1 Pro',
1294
+ inputPerMTok: 2,
1295
+ outputPerMTok: 10,
1296
+ contextWindow: 1_048_576,
1297
+ cacheMinTokens: null,
1298
+ caching: 'automatic',
1299
+ multipliers: { cacheRead: 0.1, cacheWrite5m: 1, cacheWrite1h: 2, batch: 0.6 },
1300
+ capability: 'frontier',
1301
+ tier: 'frontier',
1302
+ notes: 'Cache writes are billed as their own line: 1x input for a 5-minute entry, 2x for an hour.'
1303
+ + ` ${NO_PUBLISHED_CACHE_MINIMUM}`,
1304
+ },
1305
+ {
1306
+ /*
1307
+ * $4/$20, cached input $0.20 (5% of its input), writes $4.00 and $8.00.
1308
+ * Not on the batch page's list, so no batch price.
1309
+ */
1310
+ id: 'kimi-k3.1-pro-highspeed',
1311
+ provider: 'moonshot',
1312
+ displayName: 'Kimi K3.1 Pro (high speed)',
1313
+ inputPerMTok: 4,
1314
+ outputPerMTok: 20,
1315
+ contextWindow: 1_048_576,
1316
+ cacheMinTokens: null,
1317
+ caching: 'automatic',
1318
+ multipliers: { cacheRead: 0.05, cacheWrite5m: 1, cacheWrite1h: 2, batch: null },
1319
+ capability: 'frontier',
1320
+ tier: 'frontier',
1321
+ notes: 'Cache writes are billed as their own line: 1x input for a 5-minute entry, 2x for an hour.'
1322
+ + ` No batch API for this model. ${NO_PUBLISHED_CACHE_MINIMUM}`,
1323
+ },
853
1324
  {
854
1325
  id: 'kimi-k3',
855
1326
  provider: 'moonshot',
@@ -859,16 +1330,18 @@ export const MODELS = [
859
1330
  contextWindow: 1_048_576,
860
1331
  cacheMinTokens: null,
861
1332
  caching: 'automatic',
862
- multipliers: { cacheRead: 0.1, cacheWrite5m: 1, cacheWrite1h: 2, batch: null },
1333
+ multipliers: { cacheRead: 0.1, cacheWrite5m: 1, cacheWrite1h: 2, batch: 0.6 },
863
1334
  capability: 'frontier',
864
1335
  tier: 'frontier',
865
1336
  notes: 'Cache writes are billed as their own line: 1x input for a 5-minute entry, 2x for an hour.'
866
- + ` No batch API for this model. ${NO_PUBLISHED_CACHE_MINIMUM}`,
1337
+ + ` Batch at 60% since the batch page listed it (read 2026-11-05). ${NO_PUBLISHED_CACHE_MINIMUM}`,
867
1338
  },
868
1339
  {
869
1340
  id: 'kimi-k2.7-code',
870
1341
  provider: 'moonshot',
871
1342
  displayName: 'Kimi K2.7 Code',
1343
+ // Closed to accounts registered from 2026-11-01; the K2 series retires by the end of December 2026.
1344
+ recommendable: false,
872
1345
  inputPerMTok: 0.95,
873
1346
  outputPerMTok: 4,
874
1347
  contextWindow: 262_144,
@@ -884,6 +1357,8 @@ export const MODELS = [
884
1357
  id: 'kimi-k2.7-code-highspeed',
885
1358
  provider: 'moonshot',
886
1359
  displayName: 'Kimi K2.7 Code (high speed)',
1360
+ // Closed to accounts registered from 2026-11-01; the K2 series retires by the end of December 2026.
1361
+ recommendable: false,
887
1362
  inputPerMTok: 1.9,
888
1363
  outputPerMTok: 8,
889
1364
  contextWindow: 262_144,
@@ -899,6 +1374,8 @@ export const MODELS = [
899
1374
  id: 'kimi-k2.6',
900
1375
  provider: 'moonshot',
901
1376
  displayName: 'Kimi K2.6',
1377
+ // Closed to accounts registered from 2026-11-01; the K2 series retires by the end of December 2026.
1378
+ recommendable: false,
902
1379
  inputPerMTok: 0.95,
903
1380
  outputPerMTok: 4,
904
1381
  contextWindow: 262_144,
@@ -1494,6 +1971,9 @@ function cache(model) {
1494
1971
  * collapsing them is the oldest mistake in this repository.
1495
1972
  */
1496
1973
  function holds(when, on, size) {
1974
+ // Decided either way: a log that does not record a speed never asked for fast mode.
1975
+ if (when.kind === 'speed')
1976
+ return (size.speed ?? 'standard') === when.speed;
1497
1977
  if (when.kind === 'utc-hours') {
1498
1978
  const day = on.getUTCDay();
1499
1979
  if (when.weekdaysOnly && (day === 0 || day === 6))
@@ -1599,6 +2079,8 @@ export function effectivePricing(model, on = new Date(), context = {}) {
1599
2079
  }
1600
2080
  /** One condition as a sentence a reader can check against a provider's page. */
1601
2081
  function describe(when) {
2082
+ if (when.kind === 'speed')
2083
+ return `${when.speed} mode (the response's usage.speed is "${when.speed}")`;
1602
2084
  if (when.kind === 'input-tokens-above') {
1603
2085
  return `prompts over ${when.tokens.toLocaleString('en-US')} input tokens`;
1604
2086
  }