@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/src/pricing.ts CHANGED
@@ -35,8 +35,18 @@ export const PROVIDER_REVIEWED: Readonly<Record<string, string>> = Object.freeze
35
35
  * each model's own page, read 2026-10-10. Every existing row matched and
36
36
  * five models were added. Claude Haiku 5.5 waited for per-request pricing,
37
37
  * because it bills by prompt length, and was added with it on 2026-10-11.
38
+ *
39
+ * Re-read 2026-11-05 with the fast-mode, deprecations and prompt-caching
40
+ * pages. Every existing price matched. Two things were missing: fast mode,
41
+ * which bills Opus 5.5 at $8/$40 and Opus 5 and 4.8 at $10/$50 and which
42
+ * every response records in `usage.speed`, so fast calls had been priced at
43
+ * half their cost; and Claude Sonnet 4.5, deprecated but still served until
44
+ * 2026-11-30, which read as unpriced. Both are here now. The retired Opus
45
+ * 4.1, Opus 4, Sonnet 4 and Haiku 3.5 are on the pricing page too and are
46
+ * not priced here yet: a row needs a context window, which their own pages
47
+ * would give, and those were not read.
38
48
  */
39
- anthropic: '2026-10-10',
49
+ anthropic: '2026-11-05',
40
50
  /*
41
51
  * developers.openai.com/api/docs/pricing, read 2026-08-31.
42
52
  *
@@ -57,8 +67,16 @@ export const PROVIDER_REVIEWED: Readonly<Record<string, string>> = Object.freeze
57
67
  * gpt-6-sol, gpt-6-luna and gpt-5.6 sol, terra and luna) waited for
58
68
  * per-request pricing, since each doubles its rates for prompts over 272K
59
69
  * tokens, and was added with it the same day, from each model's own page.
70
+ *
71
+ * Re-read 2026-11-05: pricing.md, prompt-caching.md and every model page
72
+ * named below, in their Markdown form. Every existing price matched. New:
73
+ * GPT-6.1 Terra; a 12-hour cache write at 2.5x input on GPT-5.6 and later,
74
+ * which the usage object splits from the 30-minute kind and which was being
75
+ * priced as one, at half its cost; and sixteen earlier models that are still
76
+ * billed and still in logs (GPT-5.5, 5.4, 5.2, 5.1 and their mini, nano and
77
+ * pro siblings, GPT-5 pro, GPT-4.1, GPT-4o and o3), none of which was priced.
60
78
  */
61
- openai: '2026-10-11',
79
+ openai: '2026-11-05',
62
80
  /*
63
81
  * ai.google.dev/gemini-api/docs/pricing, docs/caching and the model pages,
64
82
  * read 2026-10-10. Every price matched; what changed is how caching starts
@@ -78,8 +96,14 @@ export const PROVIDER_REVIEWED: Readonly<Record<string, string>> = Object.freeze
78
96
  * and added nothing. Kimi K3, K2.7 Code (and its high-speed variant) and
79
97
  * K2.6 are priced now. `kimi-k2` was discontinued on 2026-05-25 by the
80
98
  * provider's own notice, so it stays priced and is no longer recommended.
99
+ *
100
+ * Re-read 2026-11-05 from the HTML page's compiled tables, the Markdown
101
+ * form now serving them empty. Every price matched; K3.1 Pro and its
102
+ * high-speed variant are added, K3 gains its 60% batch price, and the K2
103
+ * series, closed to new accounts and retiring in December, is no longer
104
+ * recommended.
81
105
  */
82
- moonshot: '2026-10-11',
106
+ moonshot: '2026-11-05',
83
107
  /*
84
108
  * api-docs.deepseek.com/quick_start/pricing read 2026-10-10, and the
85
109
  * 2026-09-10 announcement (api-docs.deepseek.com/news/news260910) read
@@ -87,8 +111,13 @@ export const PROVIDER_REVIEWED: Readonly<Record<string, string>> = Object.freeze
87
111
  * Sept 10, 2026." V4 Flash was retired that day and its id now bills at
88
112
  * the new deepseek-flash price, so the old price lives in its `history`.
89
113
  * V4 Pro matched the page unchanged.
114
+ *
115
+ * Re-read 2026-11-05: every price, the peak window (01:00-04:00 and
116
+ * 06:00-10:00 UTC, Monday to Friday, Chinese public holidays off-peak in
117
+ * full) and the cache-hit prices matched. The Flash version behind
118
+ * `deepseek-flash` is now named DeepSeek-V4.1-Flash-1017, at the same price.
90
119
  */
91
- deepseek: '2026-10-10',
120
+ deepseek: '2026-11-05',
92
121
  /*
93
122
  * docs.x.ai/developers/models, each model's page and the 2026-05-15
94
123
  * retirement notice, read 2026-10-11 in their Markdown form. Grok 4.7, 4.6,
@@ -96,8 +125,11 @@ export const PROVIDER_REVIEWED: Readonly<Record<string, string>> = Object.freeze
96
125
  * request pays once its prompt reaches 200k tokens, which per-request
97
126
  * pricing can now express. `grok-4` was retired on 2026-05-15 and its calls
98
127
  * have billed at Grok 4.3's prices since, so it carries both periods.
128
+ *
129
+ * Re-read 2026-11-05 (docs.x.ai/developers/models.md): every model, price,
130
+ * cached price, 200k threshold and context window matched. Nothing new.
99
131
  */
100
- xai: '2026-10-11',
132
+ xai: '2026-11-05',
101
133
  /*
102
134
  * `mistral.ai/pricing`, read 2026-08-28 — by a human, because the page
103
135
  * renders its table in the browser and serves a fetch only an FAQ example
@@ -118,8 +150,13 @@ export const PROVIDER_REVIEWED: Readonly<Record<string, string>> = Object.freeze
118
150
  * price as carrying the cache discount. This table said Mistral had no
119
151
  * prompt caching at all. docs.mistral.ai, where a minimum or a mechanism
120
152
  * would be, is not reachable from here, so neither is claimed.
153
+ *
154
+ * Re-read 2026-11-05 from the same three model cards' `data-prices` and
155
+ * mistral.ai/cloud/inference: Large 2512 at $0.50/$1.50, Medium 3.5 at
156
+ * $1.50/$7.50 and Small 2603 at $0.15/$0.60 matched, as did the 90% cached
157
+ * input discount. docs.mistral.ai is still not reachable from here.
121
158
  */
122
- mistral: '2026-10-11',
159
+ mistral: '2026-11-05',
123
160
  });
124
161
 
125
162
  /**
@@ -224,12 +261,27 @@ const GROK_LONG = (inputPerMTok: number, outputPerMTok: number): PricingTier =>
224
261
  const NO_PUBLISHED_CACHE_MINIMUM =
225
262
  'Caches automatically, but no minimum prefix length is published, so no caching advice is given for it.';
226
263
 
227
- /** OpenAI's GPT-5.6 and later: one cache entry, living at least 30 minutes. */
228
- const OPENAI_CACHE_TTL = Object.freeze({ writeMs: 30 * 60_000, longerMs: null });
264
+ /**
265
+ * OpenAI's GPT-5.6 and later: an entry lives at least 30 minutes by default,
266
+ * and the Responses API sells a 12-hour one (`prompt_cache_options.ttl`). The
267
+ * two write prices are the `cacheWrite5m` and `cacheWrite1h` multipliers: the
268
+ * catalogue's short and long write, whatever each provider's durations.
269
+ */
270
+ const OPENAI_CACHE_TTL = Object.freeze({ writeMs: 30 * 60_000, longerMs: 12 * 60 * 60_000 });
229
271
 
230
272
  const OPENAI_CURRENT_NOTE =
231
273
  'Priced per request by prompt length: over 272,000 input tokens, 2x input and cache and 1.5x output for'
232
- + ' the whole request. Cache writes cost 1.25x input and an entry lives at least 30 minutes.';
274
+ + ' the whole request. Cache writes cost 1.25x input for the default 30-minute entry and 2.5x for a'
275
+ + ' 12-hour one (Responses API).';
276
+
277
+ const OPENAI_EARLIER_NOTE =
278
+ 'Caching is automatic; a write costs what input costs. OpenAI says the minimum for models before GPT-5.6 varies by'
279
+ + ' request settings, so 1,024 here is the nearest published floor.';
280
+ const OPENAI_EARLIER_LONG_NOTE =
281
+ 'Priced per request by prompt length: over 272,000 input tokens, 2x input and 1.5x output for the whole request. '
282
+ + OPENAI_EARLIER_NOTE;
283
+ const OPENAI_EARLIER_NO_CACHE_NOTE = 'OpenAI publishes no cached-input price for this model, so caching is not priced.';
284
+ const OPENAI_DEPRECATED_SUFFIX = ' Deprecated by OpenAI: priced for the logs that hold it, never recommended.';
233
285
 
234
286
  const OPENAI_GPT5_NOTE =
235
287
  'Caching is automatic, with no cache_control to set. OpenAI says the minimum for models before GPT-5.6 varies by'
@@ -324,9 +376,18 @@ export const MODELS: ModelPricing[] = [
324
376
  contextWindow: 1_000_000,
325
377
  cacheMinTokens: 512,
326
378
  multipliers: { cacheRead: 0.05, cacheWrite5m: 1.25, cacheWrite1h: 2, batch: 0.5 },
379
+ /*
380
+ * Fast mode, read 2026-11-05 from platform.claude.com/docs/en/about-claude/
381
+ * pricing#fast-mode-pricing and build-with-claude/fast-mode: $8/$40 "across
382
+ * the full context window", with the caching multipliers "on top", which is
383
+ * how a tier's rate already feeds the cache prices here. The response's
384
+ * `usage.speed` says which speed ran.
385
+ */
386
+ tiers: [{ id: 'fast', when: { kind: 'speed', speed: 'fast' }, inputPerMTok: 8, outputPerMTok: 40 }],
327
387
  capability: 'large',
328
388
  tier: 'opus',
329
- notes: 'Cache hits cost 5% of the input price ($0.20), against 10% on Opus 5 and earlier.',
389
+ notes: 'Cache hits cost 5% of the input price ($0.20), against 10% on Opus 5 and earlier.'
390
+ + ' Fast mode (usage.speed "fast") bills $8/$40.',
330
391
  },
331
392
  {
332
393
  id: 'claude-opus-5',
@@ -336,9 +397,11 @@ export const MODELS: ModelPricing[] = [
336
397
  outputPerMTok: 25,
337
398
  contextWindow: 1_000_000,
338
399
  cacheMinTokens: 512,
400
+ // Fast mode in research preview, $10/$50; same sources as Opus 5.5's.
401
+ tiers: [{ id: 'fast', when: { kind: 'speed', speed: 'fast' }, inputPerMTok: 10, outputPerMTok: 50 }],
339
402
  capability: 'large',
340
403
  tier: 'opus',
341
- notes: '512-token cache minimum: caches prompts that would miss on Opus 4.6.',
404
+ notes: '512-token cache minimum: caches prompts that would miss on Opus 4.6. Fast mode bills $10/$50.',
342
405
  },
343
406
  {
344
407
  id: 'claude-opus-4-8',
@@ -348,8 +411,15 @@ export const MODELS: ModelPricing[] = [
348
411
  outputPerMTok: 25,
349
412
  contextWindow: 1_000_000,
350
413
  cacheMinTokens: 1024,
414
+ /*
415
+ * Fast mode in research preview, $10/$50; same sources as Opus 5.5's. It is
416
+ * deprecated on this model and removed on 2026-11-30, after which no
417
+ * response records it, so the tier only ever prices calls that ran fast.
418
+ */
419
+ tiers: [{ id: 'fast', when: { kind: 'speed', speed: 'fast' }, inputPerMTok: 10, outputPerMTok: 50 }],
351
420
  capability: 'large',
352
421
  tier: 'opus',
422
+ notes: 'Fast mode bills $10/$50 until it is removed from this model on 2026-11-30.',
353
423
  },
354
424
  {
355
425
  id: 'claude-opus-4-7',
@@ -437,6 +507,29 @@ export const MODELS: ModelPricing[] = [
437
507
  capability: 'mid',
438
508
  tier: 'sonnet',
439
509
  },
510
+ {
511
+ /*
512
+ * Its own model page (platform.claude.com/docs/en/models/sonnet-4-5/
513
+ * overview), the pricing page, the prompt-caching page and the
514
+ * deprecations page, read 2026-11-05. $3/$15, writes $3.75 and $6, cache
515
+ * read $0.30, batch 50% off, 200K context, 1,024-token cache minimum.
516
+ * Deprecated on 2026-09-30 and retiring on 2026-11-30, so it is priced (it
517
+ * is in every log of the last year) and never recommended. It was missing
518
+ * here, so every Sonnet 4.5 call read as an unpriced model.
519
+ */
520
+ id: 'claude-sonnet-4-5',
521
+ aliases: ['claude-sonnet-4-5-20250929'],
522
+ provider: 'anthropic',
523
+ displayName: 'Claude Sonnet 4.5',
524
+ recommendable: false,
525
+ inputPerMTok: 3,
526
+ outputPerMTok: 15,
527
+ contextWindow: 200_000,
528
+ cacheMinTokens: 1024,
529
+ capability: 'mid',
530
+ tier: 'sonnet',
531
+ notes: 'Deprecated; retires 2026-11-30. Recommended replacement: Claude Sonnet 5.5.',
532
+ },
440
533
  {
441
534
  /*
442
535
  * The pricing page, the models overview and the prompt-caching page, read
@@ -515,8 +608,17 @@ export const MODELS: ModelPricing[] = [
515
608
  // - **Cache writes are billed**, at 1.25x the uncached input rate, and the
516
609
  // usage object reports them (`cache_write_tokens`). Reads are 10% of input,
517
610
  // 5% on GPT-6.1 Sol.
518
- // - **An entry lives at least 30 minutes** after its last write or read, and
519
- // there is no longer one to buy: `cacheTtl`.
611
+ // - **An entry lives at least 30 minutes** after its last write or read:
612
+ // `cacheTtl`. On 2026-10-11 there was no longer one to buy.
613
+ //
614
+ // Re-read 2026-11-05 (pricing.md, prompt-caching.md and the GPT-6.1 pages,
615
+ // in their Markdown form). Every price matched. Two things are new: GPT-6.1
616
+ // Terra, and a **12-hour cache write** in the Responses API at 2.5x input
617
+ // (`prompt_cache_options.ttl: "12h"`), reported in
618
+ // `input_tokens_details.cache_write_tokens_details` as `ttl_30m_tokens` and
619
+ // `ttl_12h_tokens`, "both fields returned, including when one is zero". A
620
+ // 12-hour write is the long write here; read as a 30-minute one, it was
621
+ // priced at half its cost.
520
622
  //
521
623
  // Caching is implicit by default (a breakpoint at the end of the latest
522
624
  // eligible message) from a 1,024-token minimum. Batch and Flex are half
@@ -533,7 +635,7 @@ export const MODELS: ModelPricing[] = [
533
635
  contextWindow: 1_050_000,
534
636
  cacheMinTokens: 1024,
535
637
  caching: 'automatic',
536
- multipliers: { cacheRead: 0.1, cacheWrite5m: 1.25, cacheWrite1h: 1.25, batch: 0.5 },
638
+ multipliers: { cacheRead: 0.1, cacheWrite5m: 1.25, cacheWrite1h: 2.5, batch: 0.5 },
537
639
  cacheTtl: OPENAI_CACHE_TTL,
538
640
  tiers: [
539
641
  {
@@ -556,7 +658,7 @@ export const MODELS: ModelPricing[] = [
556
658
  contextWindow: 1_050_000,
557
659
  cacheMinTokens: 1024,
558
660
  caching: 'automatic',
559
- multipliers: { cacheRead: 0.05, cacheWrite5m: 1.25, cacheWrite1h: 1.25, batch: 0.5 },
661
+ multipliers: { cacheRead: 0.05, cacheWrite5m: 1.25, cacheWrite1h: 2.5, batch: 0.5 },
560
662
  cacheTtl: OPENAI_CACHE_TTL,
561
663
  tiers: [
562
664
  {
@@ -570,6 +672,35 @@ export const MODELS: ModelPricing[] = [
570
672
  tier: 'opus',
571
673
  notes: OPENAI_CURRENT_NOTE,
572
674
  },
675
+ {
676
+ /*
677
+ * developers.openai.com/api/docs/models/gpt-6.1-terra.md, read 2026-11-05:
678
+ * $1/$5, cached input $0.05 ("5% of the uncached input token rate"), cache
679
+ * writes $1.25 for 30 minutes and $2.50 for 12 hours, the same 272K band,
680
+ * 1,050,000 context, 922,000 input and 128,000 output.
681
+ */
682
+ id: 'gpt-6.1-terra',
683
+ provider: 'openai',
684
+ displayName: 'GPT-6.1 Terra',
685
+ inputPerMTok: 1,
686
+ outputPerMTok: 5,
687
+ contextWindow: 1_050_000,
688
+ cacheMinTokens: 1024,
689
+ caching: 'automatic',
690
+ multipliers: { cacheRead: 0.05, cacheWrite5m: 1.25, cacheWrite1h: 2.5, batch: 0.5 },
691
+ cacheTtl: OPENAI_CACHE_TTL,
692
+ tiers: [
693
+ {
694
+ id: 'over-272k',
695
+ when: { kind: 'input-tokens-above', tokens: 272_000 },
696
+ inputPerMTok: 2,
697
+ outputPerMTok: 7.5,
698
+ },
699
+ ],
700
+ capability: 'mid',
701
+ tier: 'sonnet',
702
+ notes: OPENAI_CURRENT_NOTE,
703
+ },
573
704
  {
574
705
  id: 'gpt-6-sol',
575
706
  provider: 'openai',
@@ -579,7 +710,7 @@ export const MODELS: ModelPricing[] = [
579
710
  contextWindow: 1_050_000,
580
711
  cacheMinTokens: 1024,
581
712
  caching: 'automatic',
582
- multipliers: { cacheRead: 0.1, cacheWrite5m: 1.25, cacheWrite1h: 1.25, batch: 0.5 },
713
+ multipliers: { cacheRead: 0.1, cacheWrite5m: 1.25, cacheWrite1h: 2.5, batch: 0.5 },
583
714
  cacheTtl: OPENAI_CACHE_TTL,
584
715
  tiers: [
585
716
  {
@@ -602,7 +733,7 @@ export const MODELS: ModelPricing[] = [
602
733
  contextWindow: 1_050_000,
603
734
  cacheMinTokens: 1024,
604
735
  caching: 'automatic',
605
- multipliers: { cacheRead: 0.1, cacheWrite5m: 1.25, cacheWrite1h: 1.25, batch: 0.5 },
736
+ multipliers: { cacheRead: 0.1, cacheWrite5m: 1.25, cacheWrite1h: 2.5, batch: 0.5 },
606
737
  cacheTtl: OPENAI_CACHE_TTL,
607
738
  tiers: [
608
739
  {
@@ -625,7 +756,7 @@ export const MODELS: ModelPricing[] = [
625
756
  contextWindow: 1_050_000,
626
757
  cacheMinTokens: 1024,
627
758
  caching: 'automatic',
628
- multipliers: { cacheRead: 0.1, cacheWrite5m: 1.25, cacheWrite1h: 1.25, batch: 0.5 },
759
+ multipliers: { cacheRead: 0.1, cacheWrite5m: 1.25, cacheWrite1h: 2.5, batch: 0.5 },
629
760
  cacheTtl: OPENAI_CACHE_TTL,
630
761
  tiers: [
631
762
  {
@@ -648,7 +779,7 @@ export const MODELS: ModelPricing[] = [
648
779
  contextWindow: 1_050_000,
649
780
  cacheMinTokens: 1024,
650
781
  caching: 'automatic',
651
- multipliers: { cacheRead: 0.1, cacheWrite5m: 1.25, cacheWrite1h: 1.25, batch: 0.5 },
782
+ multipliers: { cacheRead: 0.1, cacheWrite5m: 1.25, cacheWrite1h: 2.5, batch: 0.5 },
652
783
  cacheTtl: OPENAI_CACHE_TTL,
653
784
  tiers: [
654
785
  {
@@ -671,7 +802,7 @@ export const MODELS: ModelPricing[] = [
671
802
  contextWindow: 1_050_000,
672
803
  cacheMinTokens: 1024,
673
804
  caching: 'automatic',
674
- multipliers: { cacheRead: 0.1, cacheWrite5m: 1.25, cacheWrite1h: 1.25, batch: 0.5 },
805
+ multipliers: { cacheRead: 0.1, cacheWrite5m: 1.25, cacheWrite1h: 2.5, batch: 0.5 },
675
806
  cacheTtl: OPENAI_CACHE_TTL,
676
807
  tiers: [
677
808
  {
@@ -733,6 +864,304 @@ export const MODELS: ModelPricing[] = [
733
864
  notes: OPENAI_GPT5_NOTE,
734
865
  },
735
866
 
867
+ // ------------------------------------------------------------------------
868
+ // OpenAI's earlier models, still billed and still in logs.
869
+ //
870
+ // developers.openai.com/api/docs/pricing.md (Standard and Batch tables) and
871
+ // each model's own page (models/<id>.md), read 2026-11-05 in their Markdown
872
+ // form. None was priced here, so every call to gpt-4o, gpt-4.1, o3 or a
873
+ // GPT-5.x before 5.6 read as an unpriced model. Prices, cached-input prices
874
+ // and context windows are each page's own; the dated snapshot ids are the
875
+ // ones each page lists, except gpt-4o-2024-05-13, which is shut down and
876
+ // priced differently from the current gpt-4o. A cached read costs what the
877
+ // page says (10% of input on GPT-5.x, 25% on GPT-4.1 and o3, 50% on GPT-4o);
878
+ // a write costs what input costs, as on GPT-5. The pro models publish no
879
+ // cached price and are not cached. Models whose page says "Status:
880
+ // Deprecated" are priced and never recommended. GPT-5.5, GPT-5.5 pro, GPT-5.4
881
+ // and GPT-5.4 pro bill a prompt over 272K at 2x input and 1.5x output.
882
+ // ------------------------------------------------------------------------
883
+ {
884
+ id: 'gpt-5.5',
885
+ aliases: ['gpt-5.5-2026-04-23'],
886
+ provider: 'openai',
887
+ displayName: 'GPT-5.5',
888
+ inputPerMTok: 5,
889
+ outputPerMTok: 30,
890
+ contextWindow: 1_050_000,
891
+ cacheMinTokens: 1024,
892
+ caching: 'automatic',
893
+ multipliers: { cacheRead: 0.1, cacheWrite5m: 1, cacheWrite1h: 1, batch: 0.5 },
894
+ tiers: [
895
+ {
896
+ id: 'over-272k',
897
+ when: { kind: 'input-tokens-above', tokens: 272_000 },
898
+ inputPerMTok: 10,
899
+ outputPerMTok: 45,
900
+ },
901
+ ],
902
+ capability: 'frontier',
903
+ tier: 'frontier',
904
+ notes: OPENAI_EARLIER_LONG_NOTE,
905
+ },
906
+ {
907
+ id: 'gpt-5.5-pro',
908
+ aliases: ['gpt-5.5-pro-2026-04-23'],
909
+ provider: 'openai',
910
+ displayName: 'GPT-5.5 pro',
911
+ inputPerMTok: 30,
912
+ outputPerMTok: 180,
913
+ contextWindow: 1_050_000,
914
+ cacheMinTokens: 0,
915
+ caching: 'none',
916
+ multipliers: { batch: 0.5 },
917
+ tiers: [
918
+ {
919
+ id: 'over-272k',
920
+ when: { kind: 'input-tokens-above', tokens: 272_000 },
921
+ inputPerMTok: 60,
922
+ outputPerMTok: 270,
923
+ },
924
+ ],
925
+ capability: 'frontier',
926
+ tier: 'frontier',
927
+ notes: OPENAI_EARLIER_LONG_NOTE,
928
+ },
929
+ {
930
+ id: 'gpt-5.4',
931
+ aliases: ['gpt-5.4-2026-03-05'],
932
+ provider: 'openai',
933
+ displayName: 'GPT-5.4',
934
+ inputPerMTok: 2.5,
935
+ outputPerMTok: 15,
936
+ contextWindow: 1_050_000,
937
+ cacheMinTokens: 1024,
938
+ caching: 'automatic',
939
+ multipliers: { cacheRead: 0.1, cacheWrite5m: 1, cacheWrite1h: 1, batch: 0.5 },
940
+ tiers: [
941
+ {
942
+ id: 'over-272k',
943
+ when: { kind: 'input-tokens-above', tokens: 272_000 },
944
+ inputPerMTok: 5,
945
+ outputPerMTok: 22.5,
946
+ },
947
+ ],
948
+ capability: 'frontier',
949
+ tier: 'frontier',
950
+ notes: OPENAI_EARLIER_LONG_NOTE,
951
+ },
952
+ {
953
+ id: 'gpt-5.4-pro',
954
+ aliases: ['gpt-5.4-pro-2026-03-05'],
955
+ provider: 'openai',
956
+ displayName: 'GPT-5.4 pro',
957
+ inputPerMTok: 30,
958
+ outputPerMTok: 180,
959
+ contextWindow: 1_050_000,
960
+ cacheMinTokens: 0,
961
+ caching: 'none',
962
+ multipliers: { batch: 0.5 },
963
+ tiers: [
964
+ {
965
+ id: 'over-272k',
966
+ when: { kind: 'input-tokens-above', tokens: 272_000 },
967
+ inputPerMTok: 60,
968
+ outputPerMTok: 270,
969
+ },
970
+ ],
971
+ capability: 'frontier',
972
+ tier: 'frontier',
973
+ notes: OPENAI_EARLIER_LONG_NOTE,
974
+ },
975
+ {
976
+ id: 'gpt-5.4-mini',
977
+ aliases: ['gpt-5.4-mini-2026-03-17'],
978
+ provider: 'openai',
979
+ displayName: 'GPT-5.4 mini',
980
+ inputPerMTok: 0.75,
981
+ outputPerMTok: 4.5,
982
+ contextWindow: 400_000,
983
+ cacheMinTokens: 1024,
984
+ caching: 'automatic',
985
+ multipliers: { cacheRead: 0.1, cacheWrite5m: 1, cacheWrite1h: 1, batch: 0.5 },
986
+ capability: 'mid',
987
+ tier: 'sonnet',
988
+ notes: OPENAI_EARLIER_NOTE,
989
+ },
990
+ {
991
+ id: 'gpt-5.4-nano',
992
+ aliases: ['gpt-5.4-nano-2026-03-17'],
993
+ provider: 'openai',
994
+ displayName: 'GPT-5.4 nano',
995
+ recommendable: false,
996
+ inputPerMTok: 0.2,
997
+ outputPerMTok: 1.25,
998
+ contextWindow: 400_000,
999
+ cacheMinTokens: 1024,
1000
+ caching: 'automatic',
1001
+ multipliers: { cacheRead: 0.1, cacheWrite5m: 1, cacheWrite1h: 1, batch: 0.5 },
1002
+ capability: 'small',
1003
+ tier: 'haiku',
1004
+ notes: OPENAI_EARLIER_NOTE + OPENAI_DEPRECATED_SUFFIX,
1005
+ },
1006
+ {
1007
+ id: 'gpt-5.2',
1008
+ aliases: ['gpt-5.2-2025-12-11'],
1009
+ provider: 'openai',
1010
+ displayName: 'GPT-5.2',
1011
+ inputPerMTok: 1.75,
1012
+ outputPerMTok: 14,
1013
+ contextWindow: 400_000,
1014
+ cacheMinTokens: 1024,
1015
+ caching: 'automatic',
1016
+ multipliers: { cacheRead: 0.1, cacheWrite5m: 1, cacheWrite1h: 1, batch: 0.5 },
1017
+ capability: 'frontier',
1018
+ tier: 'frontier',
1019
+ notes: OPENAI_EARLIER_NOTE,
1020
+ },
1021
+ {
1022
+ id: 'gpt-5.2-pro',
1023
+ aliases: ['gpt-5.2-pro-2025-12-11'],
1024
+ provider: 'openai',
1025
+ displayName: 'GPT-5.2 pro',
1026
+ inputPerMTok: 21,
1027
+ outputPerMTok: 168,
1028
+ contextWindow: 400_000,
1029
+ cacheMinTokens: 0,
1030
+ caching: 'none',
1031
+ multipliers: { batch: 0.5 },
1032
+ capability: 'frontier',
1033
+ tier: 'frontier',
1034
+ notes: OPENAI_EARLIER_NO_CACHE_NOTE,
1035
+ },
1036
+ {
1037
+ id: 'gpt-5.1',
1038
+ aliases: ['gpt-5.1-2025-11-13'],
1039
+ provider: 'openai',
1040
+ displayName: 'GPT-5.1',
1041
+ recommendable: false,
1042
+ inputPerMTok: 1.25,
1043
+ outputPerMTok: 10,
1044
+ contextWindow: 400_000,
1045
+ cacheMinTokens: 1024,
1046
+ caching: 'automatic',
1047
+ multipliers: { cacheRead: 0.1, cacheWrite5m: 1, cacheWrite1h: 1, batch: 0.5 },
1048
+ capability: 'frontier',
1049
+ tier: 'frontier',
1050
+ notes: OPENAI_EARLIER_NOTE + OPENAI_DEPRECATED_SUFFIX,
1051
+ },
1052
+ {
1053
+ id: 'gpt-5-pro',
1054
+ aliases: ['gpt-5-pro-2025-10-06'],
1055
+ provider: 'openai',
1056
+ displayName: 'GPT-5 pro',
1057
+ recommendable: false,
1058
+ inputPerMTok: 15,
1059
+ outputPerMTok: 120,
1060
+ contextWindow: 400_000,
1061
+ cacheMinTokens: 0,
1062
+ caching: 'none',
1063
+ multipliers: { batch: 0.5 },
1064
+ capability: 'frontier',
1065
+ tier: 'frontier',
1066
+ notes: OPENAI_EARLIER_NO_CACHE_NOTE + OPENAI_DEPRECATED_SUFFIX,
1067
+ },
1068
+ {
1069
+ id: 'gpt-4.1',
1070
+ aliases: ['gpt-4.1-2025-04-14'],
1071
+ provider: 'openai',
1072
+ displayName: 'GPT-4.1',
1073
+ recommendable: false,
1074
+ inputPerMTok: 2,
1075
+ outputPerMTok: 8,
1076
+ contextWindow: 1_047_576,
1077
+ cacheMinTokens: 1024,
1078
+ caching: 'automatic',
1079
+ multipliers: { cacheRead: 0.25, cacheWrite5m: 1, cacheWrite1h: 1, batch: 0.5 },
1080
+ capability: 'large',
1081
+ tier: 'opus',
1082
+ notes: OPENAI_EARLIER_NOTE + OPENAI_DEPRECATED_SUFFIX,
1083
+ },
1084
+ {
1085
+ id: 'gpt-4.1-mini',
1086
+ aliases: ['gpt-4.1-mini-2025-04-14'],
1087
+ provider: 'openai',
1088
+ displayName: 'GPT-4.1 mini',
1089
+ recommendable: false,
1090
+ inputPerMTok: 0.4,
1091
+ outputPerMTok: 1.6,
1092
+ contextWindow: 1_047_576,
1093
+ cacheMinTokens: 1024,
1094
+ caching: 'automatic',
1095
+ multipliers: { cacheRead: 0.25, cacheWrite5m: 1, cacheWrite1h: 1, batch: 0.5 },
1096
+ capability: 'mid',
1097
+ tier: 'sonnet',
1098
+ notes: OPENAI_EARLIER_NOTE + OPENAI_DEPRECATED_SUFFIX,
1099
+ },
1100
+ {
1101
+ id: 'gpt-4o',
1102
+ aliases: ['gpt-4o-2024-11-20', 'gpt-4o-2024-08-06'],
1103
+ provider: 'openai',
1104
+ displayName: 'GPT-4o',
1105
+ recommendable: false,
1106
+ inputPerMTok: 2.5,
1107
+ outputPerMTok: 10,
1108
+ contextWindow: 128_000,
1109
+ cacheMinTokens: 1024,
1110
+ caching: 'automatic',
1111
+ multipliers: { cacheRead: 0.5, cacheWrite5m: 1, cacheWrite1h: 1, batch: 0.5 },
1112
+ capability: 'large',
1113
+ tier: 'opus',
1114
+ notes: OPENAI_EARLIER_NOTE + OPENAI_DEPRECATED_SUFFIX,
1115
+ },
1116
+ {
1117
+ id: 'gpt-4o-mini',
1118
+ aliases: ['gpt-4o-mini-2024-07-18'],
1119
+ provider: 'openai',
1120
+ displayName: 'GPT-4o mini',
1121
+ recommendable: false,
1122
+ inputPerMTok: 0.15,
1123
+ outputPerMTok: 0.6,
1124
+ contextWindow: 128_000,
1125
+ cacheMinTokens: 1024,
1126
+ caching: 'automatic',
1127
+ multipliers: { cacheRead: 0.5, cacheWrite5m: 1, cacheWrite1h: 1, batch: 0.5 },
1128
+ capability: 'small',
1129
+ tier: 'haiku',
1130
+ notes: OPENAI_EARLIER_NOTE + OPENAI_DEPRECATED_SUFFIX,
1131
+ },
1132
+ {
1133
+ id: 'o3',
1134
+ aliases: ['o3-2025-04-16'],
1135
+ provider: 'openai',
1136
+ displayName: 'o3',
1137
+ recommendable: false,
1138
+ inputPerMTok: 2,
1139
+ outputPerMTok: 8,
1140
+ contextWindow: 200_000,
1141
+ cacheMinTokens: 1024,
1142
+ caching: 'automatic',
1143
+ multipliers: { cacheRead: 0.25, cacheWrite5m: 1, cacheWrite1h: 1, batch: 0.5 },
1144
+ capability: 'frontier',
1145
+ tier: 'frontier',
1146
+ notes: OPENAI_EARLIER_NOTE + OPENAI_DEPRECATED_SUFFIX,
1147
+ },
1148
+ {
1149
+ id: 'o3-pro',
1150
+ aliases: ['o3-pro-2025-06-10'],
1151
+ provider: 'openai',
1152
+ displayName: 'o3-pro',
1153
+ recommendable: false,
1154
+ inputPerMTok: 20,
1155
+ outputPerMTok: 80,
1156
+ contextWindow: 200_000,
1157
+ cacheMinTokens: 0,
1158
+ caching: 'none',
1159
+ multipliers: { batch: 0.5 },
1160
+ capability: 'frontier',
1161
+ tier: 'frontier',
1162
+ notes: OPENAI_EARLIER_NO_CACHE_NOTE + OPENAI_DEPRECATED_SUFFIX,
1163
+ },
1164
+
736
1165
  // ------------------------------------------------------------------------
737
1166
  // Google
738
1167
  // ------------------------------------------------------------------------
@@ -891,7 +1320,55 @@ export const MODELS: ModelPricing[] = [
891
1320
  * $0.30. The K2 series bills no write, and reads at its own hit price. Batch
892
1321
  * is 60% of standard on K2.7 Code and K2.6 and not offered on K3 or the
893
1322
  * high-speed K2.7. No cache minimum is published for any of them.
1323
+ *
1324
+ * Re-read 2026-11-05. The Markdown form now ships the price tables empty
1325
+ * (`<tbody />`); the figures are in the HTML page's compiled table rows,
1326
+ * read there. Every existing price matched. Three changes: Kimi K3.1 Pro
1327
+ * and its high-speed variant are new; the batch page now lists K3 and K3.1
1328
+ * Pro at 60% ("billed at 60% of the standard price"), so K3 has a batch
1329
+ * price; and the K2 series is closed to accounts registered from 2026-11-01
1330
+ * and retires "by the end of December 2026", so it is no longer recommended.
894
1331
  */
1332
+ {
1333
+ /*
1334
+ * $2/$10, cached input $0.20, cache writes $2.00 for 5 minutes and $4.00
1335
+ * for an hour; batch 60%; 1,048,576 context, as every K3-series model.
1336
+ */
1337
+ id: 'kimi-k3.1-pro',
1338
+ provider: 'moonshot',
1339
+ displayName: 'Kimi K3.1 Pro',
1340
+ inputPerMTok: 2,
1341
+ outputPerMTok: 10,
1342
+ contextWindow: 1_048_576,
1343
+ cacheMinTokens: null,
1344
+ caching: 'automatic',
1345
+ multipliers: { cacheRead: 0.1, cacheWrite5m: 1, cacheWrite1h: 2, batch: 0.6 },
1346
+ capability: 'frontier',
1347
+ tier: 'frontier',
1348
+ notes:
1349
+ 'Cache writes are billed as their own line: 1x input for a 5-minute entry, 2x for an hour.'
1350
+ + ` ${NO_PUBLISHED_CACHE_MINIMUM}`,
1351
+ },
1352
+ {
1353
+ /*
1354
+ * $4/$20, cached input $0.20 (5% of its input), writes $4.00 and $8.00.
1355
+ * Not on the batch page's list, so no batch price.
1356
+ */
1357
+ id: 'kimi-k3.1-pro-highspeed',
1358
+ provider: 'moonshot',
1359
+ displayName: 'Kimi K3.1 Pro (high speed)',
1360
+ inputPerMTok: 4,
1361
+ outputPerMTok: 20,
1362
+ contextWindow: 1_048_576,
1363
+ cacheMinTokens: null,
1364
+ caching: 'automatic',
1365
+ multipliers: { cacheRead: 0.05, cacheWrite5m: 1, cacheWrite1h: 2, batch: null },
1366
+ capability: 'frontier',
1367
+ tier: 'frontier',
1368
+ notes:
1369
+ 'Cache writes are billed as their own line: 1x input for a 5-minute entry, 2x for an hour.'
1370
+ + ` No batch API for this model. ${NO_PUBLISHED_CACHE_MINIMUM}`,
1371
+ },
895
1372
  {
896
1373
  id: 'kimi-k3',
897
1374
  provider: 'moonshot',
@@ -901,17 +1378,19 @@ export const MODELS: ModelPricing[] = [
901
1378
  contextWindow: 1_048_576,
902
1379
  cacheMinTokens: null,
903
1380
  caching: 'automatic',
904
- multipliers: { cacheRead: 0.1, cacheWrite5m: 1, cacheWrite1h: 2, batch: null },
1381
+ multipliers: { cacheRead: 0.1, cacheWrite5m: 1, cacheWrite1h: 2, batch: 0.6 },
905
1382
  capability: 'frontier',
906
1383
  tier: 'frontier',
907
1384
  notes:
908
1385
  'Cache writes are billed as their own line: 1x input for a 5-minute entry, 2x for an hour.'
909
- + ` No batch API for this model. ${NO_PUBLISHED_CACHE_MINIMUM}`,
1386
+ + ` Batch at 60% since the batch page listed it (read 2026-11-05). ${NO_PUBLISHED_CACHE_MINIMUM}`,
910
1387
  },
911
1388
  {
912
1389
  id: 'kimi-k2.7-code',
913
1390
  provider: 'moonshot',
914
1391
  displayName: 'Kimi K2.7 Code',
1392
+ // Closed to accounts registered from 2026-11-01; the K2 series retires by the end of December 2026.
1393
+ recommendable: false,
915
1394
  inputPerMTok: 0.95,
916
1395
  outputPerMTok: 4,
917
1396
  contextWindow: 262_144,
@@ -927,6 +1406,8 @@ export const MODELS: ModelPricing[] = [
927
1406
  id: 'kimi-k2.7-code-highspeed',
928
1407
  provider: 'moonshot',
929
1408
  displayName: 'Kimi K2.7 Code (high speed)',
1409
+ // Closed to accounts registered from 2026-11-01; the K2 series retires by the end of December 2026.
1410
+ recommendable: false,
930
1411
  inputPerMTok: 1.9,
931
1412
  outputPerMTok: 8,
932
1413
  contextWindow: 262_144,
@@ -942,6 +1423,8 @@ export const MODELS: ModelPricing[] = [
942
1423
  id: 'kimi-k2.6',
943
1424
  provider: 'moonshot',
944
1425
  displayName: 'Kimi K2.6',
1426
+ // Closed to accounts registered from 2026-11-01; the K2 series retires by the end of December 2026.
1427
+ recommendable: false,
945
1428
  inputPerMTok: 0.95,
946
1429
  outputPerMTok: 4,
947
1430
  contextWindow: 262_144,
@@ -1579,6 +2062,8 @@ interface Rates {
1579
2062
  export interface PromptSize {
1580
2063
  inputTokens?: number;
1581
2064
  inputTokensAtMost?: number;
2065
+ /** The response's `usage.speed`, when the log kept it: `"fast"` or `"standard"`. */
2066
+ speed?: string;
1582
2067
  }
1583
2068
 
1584
2069
  const pricingMemo = new WeakMap<
@@ -1655,6 +2140,8 @@ function cache(model: ModelPricing): {
1655
2140
  * collapsing them is the oldest mistake in this repository.
1656
2141
  */
1657
2142
  function holds(when: TierCondition, on: Date, size: PromptSize): boolean | null {
2143
+ // Decided either way: a log that does not record a speed never asked for fast mode.
2144
+ if (when.kind === 'speed') return (size.speed ?? 'standard') === when.speed;
1658
2145
  if (when.kind === 'utc-hours') {
1659
2146
  const day = on.getUTCDay();
1660
2147
  if (when.weekdaysOnly && (day === 0 || day === 6)) return false;
@@ -1769,6 +2256,7 @@ export function effectivePricing(
1769
2256
 
1770
2257
  /** One condition as a sentence a reader can check against a provider's page. */
1771
2258
  function describe(when: TierCondition): string {
2259
+ if (when.kind === 'speed') return `${when.speed} mode (the response's usage.speed is "${when.speed}")`;
1772
2260
  if (when.kind === 'input-tokens-above') {
1773
2261
  return `prompts over ${when.tokens.toLocaleString('en-US')} input tokens`;
1774
2262
  }