@trazum/core 2.7.1 → 2.7.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/dist/billing.d.ts.map +1 -1
- package/dist/billing.js +5 -2
- package/dist/billing.js.map +1 -1
- package/dist/gateway.d.ts +8 -0
- package/dist/gateway.d.ts.map +1 -1
- package/dist/gateway.js +14 -1
- package/dist/gateway.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/pricing.d.ts +22 -1
- package/dist/pricing.d.ts.map +1 -1
- package/dist/pricing.js +460 -9
- package/dist/pricing.js.map +1 -1
- package/dist/types.d.ts +37 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/usage.d.ts +8 -0
- package/dist/usage.d.ts.map +1 -1
- package/dist/usage.js +9 -0
- package/dist/usage.js.map +1 -1
- package/package.json +1 -1
- package/src/billing.ts +5 -2
- package/src/gateway.ts +21 -2
- package/src/index.ts +1 -0
- package/src/pricing.ts +475 -10
- package/src/types.ts +39 -0
- package/src/usage.ts +17 -0
package/dist/pricing.js
CHANGED
|
@@ -39,10 +39,12 @@ export const PROVIDER_REVIEWED = Object.freeze({
|
|
|
39
39
|
* which bills Opus 5.5 at $8/$40 and Opus 5 and 4.8 at $10/$50 and which
|
|
40
40
|
* every response records in `usage.speed`, so fast calls had been priced at
|
|
41
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.
|
|
43
|
-
* 4.1, Opus 4, Sonnet 4 and Haiku 3.5
|
|
44
|
-
*
|
|
45
|
-
*
|
|
42
|
+
* 2026-11-30, which read as unpriced. Both are here now. So are the
|
|
43
|
+
* retired Opus 4.1, Opus 4, Sonnet 4 and Haiku 3.5, still on the pricing
|
|
44
|
+
* page and in every log from before their retirement: their own model pages
|
|
45
|
+
* are gone, and the context-windows page gives each the 200k window every
|
|
46
|
+
* Claude model outside its 1M list has. Claude Sonnet 3.7 and Haiku 3 are
|
|
47
|
+
* retired and absent from the pricing page, so they stay unpriced.
|
|
46
48
|
*/
|
|
47
49
|
anthropic: '2026-11-05',
|
|
48
50
|
/*
|
|
@@ -248,6 +250,17 @@ const NO_PUBLISHED_CACHE_MINIMUM = 'Caches automatically, but no minimum prefix
|
|
|
248
250
|
* catalogue's short and long write, whatever each provider's durations.
|
|
249
251
|
*/
|
|
250
252
|
const OPENAI_CACHE_TTL = Object.freeze({ writeMs: 30 * 60_000, longerMs: 12 * 60 * 60_000 });
|
|
253
|
+
/**
|
|
254
|
+
* OpenAI's service-tier tables, read from developers.openai.com/api/docs/pricing.md
|
|
255
|
+
* on 2026-11-05: the Flex, Fast and Ultrafast tables beside the Standard one,
|
|
256
|
+
* each model's row as printed, and its "Long context" columns where the table
|
|
257
|
+
* publishes them ("Short context: <=272K input tokens. Long context: >272K").
|
|
258
|
+
* A row whose long columns read "-" gets no long band here: GPT-5.5 and 5.4 in
|
|
259
|
+
* Fast, GPT-5.5 pro in Flex. See `ModelPricing.serviceTiers`.
|
|
260
|
+
*/
|
|
261
|
+
const openAiLongBand = (inputPerMTok, outputPerMTok) => [
|
|
262
|
+
{ id: 'over-272k', when: { kind: 'input-tokens-above', tokens: 272_000 }, inputPerMTok, outputPerMTok },
|
|
263
|
+
];
|
|
251
264
|
const OPENAI_CURRENT_NOTE = 'Priced per request by prompt length: over 272,000 input tokens, 2x input and cache and 1.5x output for'
|
|
252
265
|
+ ' the whole request. Cache writes cost 1.25x input for the default 30-minute entry and 2.5x for a'
|
|
253
266
|
+ ' 12-hour one (Responses API).';
|
|
@@ -257,6 +270,9 @@ const OPENAI_EARLIER_LONG_NOTE = 'Priced per request by prompt length: over 272,
|
|
|
257
270
|
+ OPENAI_EARLIER_NOTE;
|
|
258
271
|
const OPENAI_EARLIER_NO_CACHE_NOTE = 'OpenAI publishes no cached-input price for this model, so caching is not priced.';
|
|
259
272
|
const OPENAI_DEPRECATED_SUFFIX = ' Deprecated by OpenAI: priced for the logs that hold it, never recommended.';
|
|
273
|
+
const OPENAI_SHUT_DOWN_SUFFIX = ' Shut down by OpenAI: priced for the logs that hold it, never recommended.';
|
|
274
|
+
const OPENAI_CODEX_NOTE = 'Caching is automatic; a write costs what input costs. Responses API only, and no batch. OpenAI says the minimum for'
|
|
275
|
+
+ ' models before GPT-5.6 varies by request settings, so 1,024 here is the nearest published floor.';
|
|
260
276
|
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'
|
|
261
277
|
+ ' request settings, so 1,024 here is the nearest published floor. The 2025-08-07 snapshot shuts down on'
|
|
262
278
|
+ ' 2026-12-11; OpenAI names the gpt-5.6 models as replacements.';
|
|
@@ -432,6 +448,51 @@ export const MODELS = [
|
|
|
432
448
|
tier: 'opus',
|
|
433
449
|
notes: '200K context window and a 64K output cap.',
|
|
434
450
|
},
|
|
451
|
+
{
|
|
452
|
+
/*
|
|
453
|
+
* Retired on the Claude API on 2026-08-05 (the deprecations page, read
|
|
454
|
+
* 2026-11-05) and still served on Claude Models on Google Cloud (Google
|
|
455
|
+
* managed) and on Bedrock. Priced because a year of logs carries it and,
|
|
456
|
+
* unpriced, every one of those calls read as a gap. The pricing page, read
|
|
457
|
+
* the same day: $15/$75, writes $18.75 and $30, cache hits $1.50, batch
|
|
458
|
+
* $7.50/$37.50, which are the default multipliers. Its model page is gone;
|
|
459
|
+
* the context-windows page gives every Claude model outside its 1M list a
|
|
460
|
+
* 200k window, and the prompt-caching page a 1,024-token cache minimum.
|
|
461
|
+
* The dated id is the one the deprecations page names and what a log
|
|
462
|
+
* carries; no shorter alias is on any page read, so none is declared.
|
|
463
|
+
*/
|
|
464
|
+
id: 'claude-opus-4-1-20250805',
|
|
465
|
+
provider: 'anthropic',
|
|
466
|
+
displayName: 'Claude Opus 4.1',
|
|
467
|
+
recommendable: false,
|
|
468
|
+
inputPerMTok: 15,
|
|
469
|
+
outputPerMTok: 75,
|
|
470
|
+
contextWindow: 200_000,
|
|
471
|
+
cacheMinTokens: 1024,
|
|
472
|
+
capability: 'large',
|
|
473
|
+
tier: 'opus',
|
|
474
|
+
notes: 'Retired on the Claude API on 2026-08-05; still served on Google Cloud (Google managed) and Bedrock.'
|
|
475
|
+
+ ' Anthropic names Claude Opus 4.8 as the replacement.',
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
/*
|
|
479
|
+
* Retired on the Claude API on 2026-06-15; still served on Claude Models
|
|
480
|
+
* on Google Cloud (Google managed). The same pages and the same figures as
|
|
481
|
+
* Opus 4.1 above: $15/$75, 200k context, a 1,024-token cache minimum.
|
|
482
|
+
*/
|
|
483
|
+
id: 'claude-opus-4-20250514',
|
|
484
|
+
provider: 'anthropic',
|
|
485
|
+
displayName: 'Claude Opus 4',
|
|
486
|
+
recommendable: false,
|
|
487
|
+
inputPerMTok: 15,
|
|
488
|
+
outputPerMTok: 75,
|
|
489
|
+
contextWindow: 200_000,
|
|
490
|
+
cacheMinTokens: 1024,
|
|
491
|
+
capability: 'large',
|
|
492
|
+
tier: 'opus',
|
|
493
|
+
notes: 'Retired on the Claude API on 2026-06-15; still served on Google Cloud (Google managed).'
|
|
494
|
+
+ ' Anthropic names Claude Opus 4.8 as the replacement.',
|
|
495
|
+
},
|
|
435
496
|
{
|
|
436
497
|
/*
|
|
437
498
|
* The pricing page and the Sonnet 5.5 model page, read 2026-10-10. The
|
|
@@ -497,6 +558,29 @@ export const MODELS = [
|
|
|
497
558
|
tier: 'sonnet',
|
|
498
559
|
notes: 'Deprecated; retires 2026-11-30. Recommended replacement: Claude Sonnet 5.5.',
|
|
499
560
|
},
|
|
561
|
+
{
|
|
562
|
+
/*
|
|
563
|
+
* Retired on the Claude API on 2026-06-15 (the deprecations page, read
|
|
564
|
+
* 2026-11-05); still served on Claude Models on Google Cloud (Google
|
|
565
|
+
* managed) and on Bedrock. The pricing page, read the same day: $3/$15,
|
|
566
|
+
* writes $3.75 and $6, cache hits $0.30, batch $1.50/$7.50. 200k context
|
|
567
|
+
* from the context-windows page, a 1,024-token cache minimum from the
|
|
568
|
+
* prompt-caching page. The pricing page publishes one rate for it and no
|
|
569
|
+
* long-context band, so every call is priced at that rate.
|
|
570
|
+
*/
|
|
571
|
+
id: 'claude-sonnet-4-20250514',
|
|
572
|
+
provider: 'anthropic',
|
|
573
|
+
displayName: 'Claude Sonnet 4',
|
|
574
|
+
recommendable: false,
|
|
575
|
+
inputPerMTok: 3,
|
|
576
|
+
outputPerMTok: 15,
|
|
577
|
+
contextWindow: 200_000,
|
|
578
|
+
cacheMinTokens: 1024,
|
|
579
|
+
capability: 'mid',
|
|
580
|
+
tier: 'sonnet',
|
|
581
|
+
notes: 'Retired on the Claude API on 2026-06-15; still served on Google Cloud (Google managed) and Bedrock.'
|
|
582
|
+
+ ' Anthropic names Claude Sonnet 5.5 as the replacement.',
|
|
583
|
+
},
|
|
500
584
|
{
|
|
501
585
|
/*
|
|
502
586
|
* The pricing page, the models overview and the prompt-caching page, read
|
|
@@ -551,6 +635,28 @@ export const MODELS = [
|
|
|
551
635
|
tier: 'haiku',
|
|
552
636
|
notes: '200K context window and a 64K output cap, smaller than the rest.',
|
|
553
637
|
},
|
|
638
|
+
{
|
|
639
|
+
/*
|
|
640
|
+
* Retired on the Claude API on 2026-02-19 (the deprecations page, read
|
|
641
|
+
* 2026-11-05); still served on Claude Models on Google Cloud (Google
|
|
642
|
+
* managed). The pricing page, read the same day: $0.80/$4, writes $1 and
|
|
643
|
+
* $1.60, cache hits $0.08, batch $0.40/$2, the default multipliers. 200k
|
|
644
|
+
* context from the context-windows page, and the prompt-caching page's
|
|
645
|
+
* 2,048-token cache minimum.
|
|
646
|
+
*/
|
|
647
|
+
id: 'claude-3-5-haiku-20241022',
|
|
648
|
+
provider: 'anthropic',
|
|
649
|
+
displayName: 'Claude Haiku 3.5',
|
|
650
|
+
recommendable: false,
|
|
651
|
+
inputPerMTok: 0.8,
|
|
652
|
+
outputPerMTok: 4,
|
|
653
|
+
contextWindow: 200_000,
|
|
654
|
+
cacheMinTokens: 2048,
|
|
655
|
+
capability: 'small',
|
|
656
|
+
tier: 'haiku',
|
|
657
|
+
notes: 'Retired on the Claude API on 2026-02-19; still served on Google Cloud (Google managed).'
|
|
658
|
+
+ ' Anthropic names Claude Haiku 4.5 as the replacement.',
|
|
659
|
+
},
|
|
554
660
|
// ------------------------------------------------------------------------
|
|
555
661
|
// OpenAI
|
|
556
662
|
//
|
|
@@ -610,6 +716,11 @@ export const MODELS = [
|
|
|
610
716
|
outputPerMTok: 75,
|
|
611
717
|
},
|
|
612
718
|
],
|
|
719
|
+
serviceTiers: {
|
|
720
|
+
flex: { inputPerMTok: 5, outputPerMTok: 25, tiers: openAiLongBand(10, 37.5) },
|
|
721
|
+
fast: { inputPerMTok: 20, outputPerMTok: 100, tiers: openAiLongBand(40, 150) },
|
|
722
|
+
ultrafast: { inputPerMTok: 60, outputPerMTok: 300, tiers: openAiLongBand(120, 450) },
|
|
723
|
+
},
|
|
613
724
|
capability: 'frontier',
|
|
614
725
|
tier: 'frontier',
|
|
615
726
|
notes: OPENAI_CURRENT_NOTE,
|
|
@@ -633,6 +744,11 @@ export const MODELS = [
|
|
|
633
744
|
outputPerMTok: 15,
|
|
634
745
|
},
|
|
635
746
|
],
|
|
747
|
+
serviceTiers: {
|
|
748
|
+
flex: { inputPerMTok: 1, outputPerMTok: 5, tiers: openAiLongBand(2, 7.5) },
|
|
749
|
+
fast: { inputPerMTok: 4, outputPerMTok: 20, tiers: openAiLongBand(8, 30) },
|
|
750
|
+
ultrafast: { inputPerMTok: 12, outputPerMTok: 60, tiers: openAiLongBand(24, 90) },
|
|
751
|
+
},
|
|
636
752
|
capability: 'large',
|
|
637
753
|
tier: 'opus',
|
|
638
754
|
notes: OPENAI_CURRENT_NOTE,
|
|
@@ -662,6 +778,10 @@ export const MODELS = [
|
|
|
662
778
|
outputPerMTok: 7.5,
|
|
663
779
|
},
|
|
664
780
|
],
|
|
781
|
+
serviceTiers: {
|
|
782
|
+
flex: { inputPerMTok: 0.5, outputPerMTok: 2.5, tiers: openAiLongBand(1, 3.75) },
|
|
783
|
+
fast: { inputPerMTok: 2, outputPerMTok: 10, tiers: openAiLongBand(4, 15) },
|
|
784
|
+
},
|
|
665
785
|
capability: 'mid',
|
|
666
786
|
tier: 'sonnet',
|
|
667
787
|
notes: OPENAI_CURRENT_NOTE,
|
|
@@ -685,6 +805,10 @@ export const MODELS = [
|
|
|
685
805
|
outputPerMTok: 15,
|
|
686
806
|
},
|
|
687
807
|
],
|
|
808
|
+
serviceTiers: {
|
|
809
|
+
flex: { inputPerMTok: 1, outputPerMTok: 5, tiers: openAiLongBand(2, 7.5) },
|
|
810
|
+
fast: { inputPerMTok: 4, outputPerMTok: 20, tiers: openAiLongBand(8, 30) },
|
|
811
|
+
},
|
|
688
812
|
capability: 'large',
|
|
689
813
|
tier: 'opus',
|
|
690
814
|
notes: OPENAI_CURRENT_NOTE,
|
|
@@ -708,12 +832,30 @@ export const MODELS = [
|
|
|
708
832
|
outputPerMTok: 0.75,
|
|
709
833
|
},
|
|
710
834
|
],
|
|
835
|
+
serviceTiers: {
|
|
836
|
+
flex: { inputPerMTok: 0.05, outputPerMTok: 0.25, tiers: openAiLongBand(0.1, 0.375) },
|
|
837
|
+
fast: { inputPerMTok: 0.2, outputPerMTok: 1, tiers: openAiLongBand(0.4, 1.5) },
|
|
838
|
+
},
|
|
711
839
|
capability: 'small',
|
|
712
840
|
tier: 'haiku',
|
|
713
841
|
notes: OPENAI_CURRENT_NOTE,
|
|
714
842
|
},
|
|
715
843
|
{
|
|
844
|
+
/*
|
|
845
|
+
* Its model page, read 2026-11-05: "The `gpt-5.6` alias routes requests
|
|
846
|
+
* to GPT-5.6 Sol", so a log that names the alias is this model; and
|
|
847
|
+
* "$4 per million input tokens and $20 per million output tokens, a 20%
|
|
848
|
+
* reduction in input pricing and a 33% reduction in output pricing ...
|
|
849
|
+
* promotional pricing is available until November 30, 2026". The price
|
|
850
|
+
* after the promotion is not published as a figure, and deriving one
|
|
851
|
+
* from two rounded percentages would be a price nobody quoted, so the row
|
|
852
|
+
* carries what the page charges today. When the page changes,
|
|
853
|
+
* `scripts/price-drift.mjs` reports it on the next weekly run; until a
|
|
854
|
+
* person reads the new figure, a call after 2026-11-30 may be priced low,
|
|
855
|
+
* and the note says so to anyone reading the row.
|
|
856
|
+
*/
|
|
716
857
|
id: 'gpt-5.6-sol',
|
|
858
|
+
aliases: ['gpt-5.6'],
|
|
717
859
|
provider: 'openai',
|
|
718
860
|
displayName: 'GPT-5.6 Sol',
|
|
719
861
|
inputPerMTok: 4,
|
|
@@ -731,9 +873,14 @@ export const MODELS = [
|
|
|
731
873
|
outputPerMTok: 30,
|
|
732
874
|
},
|
|
733
875
|
],
|
|
876
|
+
serviceTiers: {
|
|
877
|
+
flex: { inputPerMTok: 2, outputPerMTok: 10, tiers: openAiLongBand(4, 15) },
|
|
878
|
+
fast: { inputPerMTok: 8, outputPerMTok: 40, tiers: openAiLongBand(16, 60) },
|
|
879
|
+
},
|
|
734
880
|
capability: 'large',
|
|
735
881
|
tier: 'opus',
|
|
736
|
-
notes: OPENAI_CURRENT_NOTE
|
|
882
|
+
notes: OPENAI_CURRENT_NOTE
|
|
883
|
+
+ ' $4/$20 is promotional until 2026-11-30, and OpenAI has not published the price after it as a figure.',
|
|
737
884
|
},
|
|
738
885
|
{
|
|
739
886
|
id: 'gpt-5.6-terra',
|
|
@@ -754,6 +901,10 @@ export const MODELS = [
|
|
|
754
901
|
outputPerMTok: 18,
|
|
755
902
|
},
|
|
756
903
|
],
|
|
904
|
+
serviceTiers: {
|
|
905
|
+
flex: { inputPerMTok: 1, outputPerMTok: 6, tiers: openAiLongBand(2, 9) },
|
|
906
|
+
fast: { inputPerMTok: 4, outputPerMTok: 24, tiers: openAiLongBand(8, 36) },
|
|
907
|
+
},
|
|
757
908
|
capability: 'mid',
|
|
758
909
|
tier: 'sonnet',
|
|
759
910
|
notes: OPENAI_CURRENT_NOTE,
|
|
@@ -777,55 +928,109 @@ export const MODELS = [
|
|
|
777
928
|
outputPerMTok: 1.8,
|
|
778
929
|
},
|
|
779
930
|
],
|
|
931
|
+
serviceTiers: {
|
|
932
|
+
flex: { inputPerMTok: 0.1, outputPerMTok: 0.6, tiers: openAiLongBand(0.2, 0.9) },
|
|
933
|
+
fast: { inputPerMTok: 0.4, outputPerMTok: 2.4, tiers: openAiLongBand(0.8, 3.6) },
|
|
934
|
+
},
|
|
780
935
|
capability: 'small',
|
|
781
936
|
tier: 'haiku',
|
|
782
937
|
notes: OPENAI_CURRENT_NOTE,
|
|
783
938
|
},
|
|
939
|
+
{
|
|
940
|
+
/*
|
|
941
|
+
* The pricing page's "Cyber models" table and the model's own page
|
|
942
|
+
* (developers.openai.com/api/docs/models/gpt-5.6-cyber.md), read
|
|
943
|
+
* 2026-11-05: $12.50/$75, cached input $1.25, the 30-minute write $15.625
|
|
944
|
+
* and the 12-hour one $31.25, the same 0.1x, 1.25x and 2.5x as the rest of
|
|
945
|
+
* GPT-5.6. A 400,000-token context window with at most 272,000 input
|
|
946
|
+
* tokens, so the long-prompt band the model page mentions can never be
|
|
947
|
+
* reached and none is modelled; the pricing page lists none either. The
|
|
948
|
+
* Batch endpoint is "Not supported", so there is no batch price.
|
|
949
|
+
*
|
|
950
|
+
* Found by `scripts/price-drift.mjs` on its first run, as a model on the
|
|
951
|
+
* pricing page that read as unpriced. It needs Daybreak programme
|
|
952
|
+
* approval, so it is priced for the logs of people who have it and never
|
|
953
|
+
* recommended to anyone else.
|
|
954
|
+
*/
|
|
955
|
+
id: 'gpt-5.6-cyber',
|
|
956
|
+
provider: 'openai',
|
|
957
|
+
displayName: 'GPT-5.6 Cyber',
|
|
958
|
+
recommendable: false,
|
|
959
|
+
inputPerMTok: 12.5,
|
|
960
|
+
outputPerMTok: 75,
|
|
961
|
+
contextWindow: 400_000,
|
|
962
|
+
cacheMinTokens: 1024,
|
|
963
|
+
caching: 'automatic',
|
|
964
|
+
multipliers: { cacheRead: 0.1, cacheWrite5m: 1.25, cacheWrite1h: 2.5, batch: null },
|
|
965
|
+
cacheTtl: OPENAI_CACHE_TTL,
|
|
966
|
+
capability: 'large',
|
|
967
|
+
tier: 'opus',
|
|
968
|
+
notes: 'Needs approval through the Daybreak programme. At most 272,000 input tokens, Responses API only, no batch.'
|
|
969
|
+
+ ' Cache writes cost 1.25x input for the default 30-minute entry and 2.5x for a 12-hour one.',
|
|
970
|
+
},
|
|
784
971
|
// ------------------------------------------------------------------------
|
|
972
|
+
// GPT-5, mini and nano. Each model page, read 2026-11-05, opens with
|
|
973
|
+
// "Status: Deprecated", and the catalogue still offered all three as
|
|
974
|
+
// cheaper alternatives, nano as the cheapest OpenAI model there is. Priced
|
|
975
|
+
// for the logs that hold them; never recommended.
|
|
785
976
|
{
|
|
786
977
|
id: 'gpt-5',
|
|
787
978
|
aliases: ['gpt-5-2025-08-07'],
|
|
788
979
|
provider: 'openai',
|
|
789
980
|
displayName: 'GPT-5',
|
|
981
|
+
recommendable: false,
|
|
790
982
|
inputPerMTok: 1.25,
|
|
791
983
|
outputPerMTok: 10,
|
|
792
984
|
contextWindow: 400_000,
|
|
793
985
|
cacheMinTokens: 1024,
|
|
794
986
|
caching: 'automatic',
|
|
795
987
|
multipliers: { cacheRead: 0.1, cacheWrite5m: 1, cacheWrite1h: 1, batch: 0.5 },
|
|
988
|
+
serviceTiers: {
|
|
989
|
+
flex: { inputPerMTok: 0.625, outputPerMTok: 5 },
|
|
990
|
+
fast: { inputPerMTok: 2.5, outputPerMTok: 20 },
|
|
991
|
+
},
|
|
796
992
|
capability: 'frontier',
|
|
797
993
|
tier: 'frontier',
|
|
798
|
-
notes: OPENAI_GPT5_NOTE,
|
|
994
|
+
notes: OPENAI_GPT5_NOTE + OPENAI_DEPRECATED_SUFFIX,
|
|
799
995
|
},
|
|
800
996
|
{
|
|
801
997
|
id: 'gpt-5-mini',
|
|
802
998
|
aliases: ['gpt-5-mini-2025-08-07'],
|
|
803
999
|
provider: 'openai',
|
|
804
1000
|
displayName: 'GPT-5 mini',
|
|
1001
|
+
recommendable: false,
|
|
805
1002
|
inputPerMTok: 0.25,
|
|
806
1003
|
outputPerMTok: 2,
|
|
807
1004
|
contextWindow: 400_000,
|
|
808
1005
|
cacheMinTokens: 1024,
|
|
809
1006
|
caching: 'automatic',
|
|
810
1007
|
multipliers: { cacheRead: 0.1, cacheWrite5m: 1, cacheWrite1h: 1, batch: 0.5 },
|
|
1008
|
+
serviceTiers: {
|
|
1009
|
+
flex: { inputPerMTok: 0.125, outputPerMTok: 1 },
|
|
1010
|
+
fast: { inputPerMTok: 0.45, outputPerMTok: 3.6 },
|
|
1011
|
+
},
|
|
811
1012
|
capability: 'mid',
|
|
812
1013
|
tier: 'sonnet',
|
|
813
|
-
notes: OPENAI_GPT5_NOTE,
|
|
1014
|
+
notes: OPENAI_GPT5_NOTE + OPENAI_DEPRECATED_SUFFIX,
|
|
814
1015
|
},
|
|
815
1016
|
{
|
|
816
1017
|
id: 'gpt-5-nano',
|
|
817
1018
|
aliases: ['gpt-5-nano-2025-08-07'],
|
|
818
1019
|
provider: 'openai',
|
|
819
1020
|
displayName: 'GPT-5 nano',
|
|
1021
|
+
recommendable: false,
|
|
820
1022
|
inputPerMTok: 0.05,
|
|
821
1023
|
outputPerMTok: 0.4,
|
|
822
1024
|
contextWindow: 400_000,
|
|
823
1025
|
cacheMinTokens: 1024,
|
|
824
1026
|
caching: 'automatic',
|
|
825
1027
|
multipliers: { cacheRead: 0.1, cacheWrite5m: 1, cacheWrite1h: 1, batch: 0.5 },
|
|
1028
|
+
serviceTiers: {
|
|
1029
|
+
flex: { inputPerMTok: 0.025, outputPerMTok: 0.2 },
|
|
1030
|
+
},
|
|
826
1031
|
capability: 'small',
|
|
827
1032
|
tier: 'haiku',
|
|
828
|
-
notes: OPENAI_GPT5_NOTE,
|
|
1033
|
+
notes: OPENAI_GPT5_NOTE + OPENAI_DEPRECATED_SUFFIX,
|
|
829
1034
|
},
|
|
830
1035
|
// ------------------------------------------------------------------------
|
|
831
1036
|
// OpenAI's earlier models, still billed and still in logs.
|
|
@@ -862,6 +1067,10 @@ export const MODELS = [
|
|
|
862
1067
|
outputPerMTok: 45,
|
|
863
1068
|
},
|
|
864
1069
|
],
|
|
1070
|
+
serviceTiers: {
|
|
1071
|
+
flex: { inputPerMTok: 2.5, outputPerMTok: 15, tiers: openAiLongBand(5, 22.5) },
|
|
1072
|
+
fast: { inputPerMTok: 12.5, outputPerMTok: 75 },
|
|
1073
|
+
},
|
|
865
1074
|
capability: 'frontier',
|
|
866
1075
|
tier: 'frontier',
|
|
867
1076
|
notes: OPENAI_EARLIER_LONG_NOTE,
|
|
@@ -885,6 +1094,9 @@ export const MODELS = [
|
|
|
885
1094
|
outputPerMTok: 270,
|
|
886
1095
|
},
|
|
887
1096
|
],
|
|
1097
|
+
serviceTiers: {
|
|
1098
|
+
flex: { inputPerMTok: 15, outputPerMTok: 90 },
|
|
1099
|
+
},
|
|
888
1100
|
capability: 'frontier',
|
|
889
1101
|
tier: 'frontier',
|
|
890
1102
|
notes: OPENAI_EARLIER_LONG_NOTE,
|
|
@@ -908,6 +1120,10 @@ export const MODELS = [
|
|
|
908
1120
|
outputPerMTok: 22.5,
|
|
909
1121
|
},
|
|
910
1122
|
],
|
|
1123
|
+
serviceTiers: {
|
|
1124
|
+
flex: { inputPerMTok: 1.25, outputPerMTok: 7.5, tiers: openAiLongBand(2.5, 11.25) },
|
|
1125
|
+
fast: { inputPerMTok: 5, outputPerMTok: 30 },
|
|
1126
|
+
},
|
|
911
1127
|
capability: 'frontier',
|
|
912
1128
|
tier: 'frontier',
|
|
913
1129
|
notes: OPENAI_EARLIER_LONG_NOTE,
|
|
@@ -931,6 +1147,9 @@ export const MODELS = [
|
|
|
931
1147
|
outputPerMTok: 270,
|
|
932
1148
|
},
|
|
933
1149
|
],
|
|
1150
|
+
serviceTiers: {
|
|
1151
|
+
flex: { inputPerMTok: 15, outputPerMTok: 90, tiers: openAiLongBand(30, 135) },
|
|
1152
|
+
},
|
|
934
1153
|
capability: 'frontier',
|
|
935
1154
|
tier: 'frontier',
|
|
936
1155
|
notes: OPENAI_EARLIER_LONG_NOTE,
|
|
@@ -946,6 +1165,10 @@ export const MODELS = [
|
|
|
946
1165
|
cacheMinTokens: 1024,
|
|
947
1166
|
caching: 'automatic',
|
|
948
1167
|
multipliers: { cacheRead: 0.1, cacheWrite5m: 1, cacheWrite1h: 1, batch: 0.5 },
|
|
1168
|
+
serviceTiers: {
|
|
1169
|
+
flex: { inputPerMTok: 0.375, outputPerMTok: 2.25 },
|
|
1170
|
+
fast: { inputPerMTok: 1.5, outputPerMTok: 9 },
|
|
1171
|
+
},
|
|
949
1172
|
capability: 'mid',
|
|
950
1173
|
tier: 'sonnet',
|
|
951
1174
|
notes: OPENAI_EARLIER_NOTE,
|
|
@@ -962,6 +1185,9 @@ export const MODELS = [
|
|
|
962
1185
|
cacheMinTokens: 1024,
|
|
963
1186
|
caching: 'automatic',
|
|
964
1187
|
multipliers: { cacheRead: 0.1, cacheWrite5m: 1, cacheWrite1h: 1, batch: 0.5 },
|
|
1188
|
+
serviceTiers: {
|
|
1189
|
+
flex: { inputPerMTok: 0.1, outputPerMTok: 0.625 },
|
|
1190
|
+
},
|
|
965
1191
|
capability: 'small',
|
|
966
1192
|
tier: 'haiku',
|
|
967
1193
|
notes: OPENAI_EARLIER_NOTE + OPENAI_DEPRECATED_SUFFIX,
|
|
@@ -977,6 +1203,10 @@ export const MODELS = [
|
|
|
977
1203
|
cacheMinTokens: 1024,
|
|
978
1204
|
caching: 'automatic',
|
|
979
1205
|
multipliers: { cacheRead: 0.1, cacheWrite5m: 1, cacheWrite1h: 1, batch: 0.5 },
|
|
1206
|
+
serviceTiers: {
|
|
1207
|
+
flex: { inputPerMTok: 0.875, outputPerMTok: 7 },
|
|
1208
|
+
fast: { inputPerMTok: 3.5, outputPerMTok: 28 },
|
|
1209
|
+
},
|
|
980
1210
|
capability: 'frontier',
|
|
981
1211
|
tier: 'frontier',
|
|
982
1212
|
notes: OPENAI_EARLIER_NOTE,
|
|
@@ -1008,6 +1238,10 @@ export const MODELS = [
|
|
|
1008
1238
|
cacheMinTokens: 1024,
|
|
1009
1239
|
caching: 'automatic',
|
|
1010
1240
|
multipliers: { cacheRead: 0.1, cacheWrite5m: 1, cacheWrite1h: 1, batch: 0.5 },
|
|
1241
|
+
serviceTiers: {
|
|
1242
|
+
flex: { inputPerMTok: 0.625, outputPerMTok: 5 },
|
|
1243
|
+
fast: { inputPerMTok: 2.5, outputPerMTok: 20 },
|
|
1244
|
+
},
|
|
1011
1245
|
capability: 'frontier',
|
|
1012
1246
|
tier: 'frontier',
|
|
1013
1247
|
notes: OPENAI_EARLIER_NOTE + OPENAI_DEPRECATED_SUFFIX,
|
|
@@ -1040,6 +1274,9 @@ export const MODELS = [
|
|
|
1040
1274
|
cacheMinTokens: 1024,
|
|
1041
1275
|
caching: 'automatic',
|
|
1042
1276
|
multipliers: { cacheRead: 0.25, cacheWrite5m: 1, cacheWrite1h: 1, batch: 0.5 },
|
|
1277
|
+
serviceTiers: {
|
|
1278
|
+
fast: { inputPerMTok: 3.5, outputPerMTok: 14 },
|
|
1279
|
+
},
|
|
1043
1280
|
capability: 'large',
|
|
1044
1281
|
tier: 'opus',
|
|
1045
1282
|
notes: OPENAI_EARLIER_NOTE + OPENAI_DEPRECATED_SUFFIX,
|
|
@@ -1056,6 +1293,9 @@ export const MODELS = [
|
|
|
1056
1293
|
cacheMinTokens: 1024,
|
|
1057
1294
|
caching: 'automatic',
|
|
1058
1295
|
multipliers: { cacheRead: 0.25, cacheWrite5m: 1, cacheWrite1h: 1, batch: 0.5 },
|
|
1296
|
+
serviceTiers: {
|
|
1297
|
+
fast: { inputPerMTok: 0.7, outputPerMTok: 2.8 },
|
|
1298
|
+
},
|
|
1059
1299
|
capability: 'mid',
|
|
1060
1300
|
tier: 'sonnet',
|
|
1061
1301
|
notes: OPENAI_EARLIER_NOTE + OPENAI_DEPRECATED_SUFFIX,
|
|
@@ -1072,6 +1312,9 @@ export const MODELS = [
|
|
|
1072
1312
|
cacheMinTokens: 1024,
|
|
1073
1313
|
caching: 'automatic',
|
|
1074
1314
|
multipliers: { cacheRead: 0.5, cacheWrite5m: 1, cacheWrite1h: 1, batch: 0.5 },
|
|
1315
|
+
serviceTiers: {
|
|
1316
|
+
fast: { inputPerMTok: 4.25, outputPerMTok: 17 },
|
|
1317
|
+
},
|
|
1075
1318
|
capability: 'large',
|
|
1076
1319
|
tier: 'opus',
|
|
1077
1320
|
notes: OPENAI_EARLIER_NOTE + OPENAI_DEPRECATED_SUFFIX,
|
|
@@ -1088,6 +1331,9 @@ export const MODELS = [
|
|
|
1088
1331
|
cacheMinTokens: 1024,
|
|
1089
1332
|
caching: 'automatic',
|
|
1090
1333
|
multipliers: { cacheRead: 0.5, cacheWrite5m: 1, cacheWrite1h: 1, batch: 0.5 },
|
|
1334
|
+
serviceTiers: {
|
|
1335
|
+
fast: { inputPerMTok: 0.25, outputPerMTok: 1 },
|
|
1336
|
+
},
|
|
1091
1337
|
capability: 'small',
|
|
1092
1338
|
tier: 'haiku',
|
|
1093
1339
|
notes: OPENAI_EARLIER_NOTE + OPENAI_DEPRECATED_SUFFIX,
|
|
@@ -1104,6 +1350,10 @@ export const MODELS = [
|
|
|
1104
1350
|
cacheMinTokens: 1024,
|
|
1105
1351
|
caching: 'automatic',
|
|
1106
1352
|
multipliers: { cacheRead: 0.25, cacheWrite5m: 1, cacheWrite1h: 1, batch: 0.5 },
|
|
1353
|
+
serviceTiers: {
|
|
1354
|
+
flex: { inputPerMTok: 1, outputPerMTok: 4 },
|
|
1355
|
+
fast: { inputPerMTok: 3.5, outputPerMTok: 14 },
|
|
1356
|
+
},
|
|
1107
1357
|
capability: 'frontier',
|
|
1108
1358
|
tier: 'frontier',
|
|
1109
1359
|
notes: OPENAI_EARLIER_NOTE + OPENAI_DEPRECATED_SUFFIX,
|
|
@@ -1125,6 +1375,143 @@ export const MODELS = [
|
|
|
1125
1375
|
notes: OPENAI_EARLIER_NO_CACHE_NOTE + OPENAI_DEPRECATED_SUFFIX,
|
|
1126
1376
|
},
|
|
1127
1377
|
// ------------------------------------------------------------------------
|
|
1378
|
+
// The Codex models and chat-latest. Codex CLI sessions name these, and none
|
|
1379
|
+
// was priced, so every such call read as unpriced. Each from its own model
|
|
1380
|
+
// page (developers.openai.com/api/docs/models/<id>.md), read 2026-11-05,
|
|
1381
|
+
// and gpt-5.3-codex and chat-latest also from the pricing page's
|
|
1382
|
+
// "Specialized models" table. Every page says Batch is "Not supported", so
|
|
1383
|
+
// none has a batch price. gpt-5.3-codex is deprecated and the rest of the
|
|
1384
|
+
// Codex line is shut down; all are priced for the logs that hold them and
|
|
1385
|
+
// never recommended. chat-latest is served and not recommended either: it
|
|
1386
|
+
// points at whatever model ChatGPT uses, so a recommendation would not name
|
|
1387
|
+
// a fixed model. Cache reads are 0.1x everywhere but codex-mini-latest,
|
|
1388
|
+
// whose page gives $0.375 on $1.50, 0.25x. gpt-5-search-api is on the
|
|
1389
|
+
// pricing page too and its model page returns 404, so it has no context
|
|
1390
|
+
// window and is left unpriced (see scripts/price-drift.mjs).
|
|
1391
|
+
// ------------------------------------------------------------------------
|
|
1392
|
+
{
|
|
1393
|
+
id: 'gpt-5.3-codex',
|
|
1394
|
+
provider: 'openai',
|
|
1395
|
+
displayName: 'GPT-5.3-Codex',
|
|
1396
|
+
recommendable: false,
|
|
1397
|
+
inputPerMTok: 1.75,
|
|
1398
|
+
outputPerMTok: 14,
|
|
1399
|
+
contextWindow: 400_000,
|
|
1400
|
+
cacheMinTokens: 1024,
|
|
1401
|
+
caching: 'automatic',
|
|
1402
|
+
multipliers: { cacheRead: 0.1, cacheWrite5m: 1, cacheWrite1h: 1, batch: null },
|
|
1403
|
+
// The pricing page's specialized "Fast" table: $3.50/$28, cached $0.35.
|
|
1404
|
+
serviceTiers: { fast: { inputPerMTok: 3.5, outputPerMTok: 28 } },
|
|
1405
|
+
capability: 'frontier',
|
|
1406
|
+
tier: 'frontier',
|
|
1407
|
+
notes: OPENAI_CODEX_NOTE + ' At most 272,000 input tokens.' + OPENAI_DEPRECATED_SUFFIX,
|
|
1408
|
+
},
|
|
1409
|
+
{
|
|
1410
|
+
id: 'gpt-5.2-codex',
|
|
1411
|
+
provider: 'openai',
|
|
1412
|
+
displayName: 'GPT-5.2-Codex',
|
|
1413
|
+
recommendable: false,
|
|
1414
|
+
inputPerMTok: 1.75,
|
|
1415
|
+
outputPerMTok: 14,
|
|
1416
|
+
contextWindow: 400_000,
|
|
1417
|
+
cacheMinTokens: 1024,
|
|
1418
|
+
caching: 'automatic',
|
|
1419
|
+
multipliers: { cacheRead: 0.1, cacheWrite5m: 1, cacheWrite1h: 1, batch: null },
|
|
1420
|
+
capability: 'frontier',
|
|
1421
|
+
tier: 'frontier',
|
|
1422
|
+
notes: OPENAI_CODEX_NOTE + ' At most 272,000 input tokens.' + OPENAI_SHUT_DOWN_SUFFIX,
|
|
1423
|
+
},
|
|
1424
|
+
{
|
|
1425
|
+
id: 'gpt-5.1-codex',
|
|
1426
|
+
provider: 'openai',
|
|
1427
|
+
displayName: 'GPT-5.1-Codex',
|
|
1428
|
+
recommendable: false,
|
|
1429
|
+
inputPerMTok: 1.25,
|
|
1430
|
+
outputPerMTok: 10,
|
|
1431
|
+
contextWindow: 400_000,
|
|
1432
|
+
cacheMinTokens: 1024,
|
|
1433
|
+
caching: 'automatic',
|
|
1434
|
+
multipliers: { cacheRead: 0.1, cacheWrite5m: 1, cacheWrite1h: 1, batch: null },
|
|
1435
|
+
capability: 'frontier',
|
|
1436
|
+
tier: 'frontier',
|
|
1437
|
+
notes: OPENAI_CODEX_NOTE + OPENAI_SHUT_DOWN_SUFFIX,
|
|
1438
|
+
},
|
|
1439
|
+
{
|
|
1440
|
+
id: 'gpt-5.1-codex-max',
|
|
1441
|
+
provider: 'openai',
|
|
1442
|
+
displayName: 'GPT-5.1-Codex-Max',
|
|
1443
|
+
recommendable: false,
|
|
1444
|
+
inputPerMTok: 1.25,
|
|
1445
|
+
outputPerMTok: 10,
|
|
1446
|
+
contextWindow: 400_000,
|
|
1447
|
+
cacheMinTokens: 1024,
|
|
1448
|
+
caching: 'automatic',
|
|
1449
|
+
multipliers: { cacheRead: 0.1, cacheWrite5m: 1, cacheWrite1h: 1, batch: null },
|
|
1450
|
+
capability: 'frontier',
|
|
1451
|
+
tier: 'frontier',
|
|
1452
|
+
notes: OPENAI_CODEX_NOTE + OPENAI_SHUT_DOWN_SUFFIX,
|
|
1453
|
+
},
|
|
1454
|
+
{
|
|
1455
|
+
id: 'gpt-5.1-codex-mini',
|
|
1456
|
+
provider: 'openai',
|
|
1457
|
+
displayName: 'GPT-5.1-Codex Mini',
|
|
1458
|
+
recommendable: false,
|
|
1459
|
+
inputPerMTok: 0.25,
|
|
1460
|
+
outputPerMTok: 2,
|
|
1461
|
+
contextWindow: 400_000,
|
|
1462
|
+
cacheMinTokens: 1024,
|
|
1463
|
+
caching: 'automatic',
|
|
1464
|
+
multipliers: { cacheRead: 0.1, cacheWrite5m: 1, cacheWrite1h: 1, batch: null },
|
|
1465
|
+
capability: 'mid',
|
|
1466
|
+
tier: 'sonnet',
|
|
1467
|
+
notes: OPENAI_CODEX_NOTE + OPENAI_SHUT_DOWN_SUFFIX,
|
|
1468
|
+
},
|
|
1469
|
+
{
|
|
1470
|
+
id: 'gpt-5-codex',
|
|
1471
|
+
provider: 'openai',
|
|
1472
|
+
displayName: 'GPT-5-Codex',
|
|
1473
|
+
recommendable: false,
|
|
1474
|
+
inputPerMTok: 1.25,
|
|
1475
|
+
outputPerMTok: 10,
|
|
1476
|
+
contextWindow: 400_000,
|
|
1477
|
+
cacheMinTokens: 1024,
|
|
1478
|
+
caching: 'automatic',
|
|
1479
|
+
multipliers: { cacheRead: 0.1, cacheWrite5m: 1, cacheWrite1h: 1, batch: null },
|
|
1480
|
+
capability: 'frontier',
|
|
1481
|
+
tier: 'frontier',
|
|
1482
|
+
notes: OPENAI_CODEX_NOTE + ' At most 272,000 input tokens.' + OPENAI_SHUT_DOWN_SUFFIX,
|
|
1483
|
+
},
|
|
1484
|
+
{
|
|
1485
|
+
id: 'codex-mini-latest',
|
|
1486
|
+
provider: 'openai',
|
|
1487
|
+
displayName: 'codex-mini-latest',
|
|
1488
|
+
recommendable: false,
|
|
1489
|
+
inputPerMTok: 1.5,
|
|
1490
|
+
outputPerMTok: 6,
|
|
1491
|
+
contextWindow: 200_000,
|
|
1492
|
+
cacheMinTokens: 1024,
|
|
1493
|
+
caching: 'automatic',
|
|
1494
|
+
multipliers: { cacheRead: 0.25, cacheWrite5m: 1, cacheWrite1h: 1, batch: null },
|
|
1495
|
+
capability: 'mid',
|
|
1496
|
+
tier: 'sonnet',
|
|
1497
|
+
notes: OPENAI_CODEX_NOTE + ' A cache read costs 0.25x input.' + OPENAI_SHUT_DOWN_SUFFIX,
|
|
1498
|
+
},
|
|
1499
|
+
{
|
|
1500
|
+
id: 'chat-latest',
|
|
1501
|
+
provider: 'openai',
|
|
1502
|
+
displayName: 'Chat Latest',
|
|
1503
|
+
recommendable: false,
|
|
1504
|
+
inputPerMTok: 5,
|
|
1505
|
+
outputPerMTok: 30,
|
|
1506
|
+
contextWindow: 400_000,
|
|
1507
|
+
cacheMinTokens: 1024,
|
|
1508
|
+
caching: 'automatic',
|
|
1509
|
+
multipliers: { cacheRead: 0.1, cacheWrite5m: 1, cacheWrite1h: 1, batch: null },
|
|
1510
|
+
capability: 'large',
|
|
1511
|
+
tier: 'opus',
|
|
1512
|
+
notes: 'Points at the model ChatGPT currently uses, so it is priced and never recommended. Caching is automatic; a write costs what input costs. At most 272,000 input tokens, and no batch.',
|
|
1513
|
+
},
|
|
1514
|
+
// ------------------------------------------------------------------------
|
|
1128
1515
|
// Google
|
|
1129
1516
|
// ------------------------------------------------------------------------
|
|
1130
1517
|
{
|
|
@@ -1905,6 +2292,57 @@ export function getModel(id) {
|
|
|
1905
2292
|
export function listModels() {
|
|
1906
2293
|
return [...MODELS];
|
|
1907
2294
|
}
|
|
2295
|
+
/**
|
|
2296
|
+
* A response's `service_tier` as the tier whose table prices it, or
|
|
2297
|
+
* `undefined` for the standard one.
|
|
2298
|
+
*
|
|
2299
|
+
* OpenAI renamed Priority processing to Fast mode on 2026-07-30, and its guide
|
|
2300
|
+
* says "for GPT-5.6 and earlier models, the response returns `priority`
|
|
2301
|
+
* whether the request specifies `priority` or `fast`", so both spellings are
|
|
2302
|
+
* the Fast table. `"default"` is the standard tier, and is also what a Fast
|
|
2303
|
+
* request downgraded under the ramp-rate limit returns, "and charge standard
|
|
2304
|
+
* rates". `"auto"` and `"scale"`, or a value this table has never seen, are
|
|
2305
|
+
* priced at the standard rate rather than guessed into another tier.
|
|
2306
|
+
*/
|
|
2307
|
+
export function serviceTierOf(value) {
|
|
2308
|
+
if (typeof value !== 'string')
|
|
2309
|
+
return undefined;
|
|
2310
|
+
const tier = value.trim().toLowerCase();
|
|
2311
|
+
if (tier === 'flex')
|
|
2312
|
+
return 'flex';
|
|
2313
|
+
if (tier === 'fast' || tier === 'priority')
|
|
2314
|
+
return 'fast';
|
|
2315
|
+
if (tier === 'ultrafast')
|
|
2316
|
+
return 'ultrafast';
|
|
2317
|
+
return undefined;
|
|
2318
|
+
}
|
|
2319
|
+
/**
|
|
2320
|
+
* The row as one service tier prices it: that tier's rates and long band, the
|
|
2321
|
+
* row's own cache and batch ratios. Built once per row and tier.
|
|
2322
|
+
*/
|
|
2323
|
+
const serviceTierMemo = new WeakMap();
|
|
2324
|
+
function serviceTierRow(model, tier) {
|
|
2325
|
+
const sheet = model.serviceTiers?.[tier];
|
|
2326
|
+
if (sheet === undefined)
|
|
2327
|
+
return undefined;
|
|
2328
|
+
let rows = serviceTierMemo.get(model);
|
|
2329
|
+
if (rows === undefined) {
|
|
2330
|
+
rows = new Map();
|
|
2331
|
+
serviceTierMemo.set(model, rows);
|
|
2332
|
+
}
|
|
2333
|
+
let row = rows.get(tier);
|
|
2334
|
+
if (row === undefined) {
|
|
2335
|
+
const { history: _history, promo: _promo, tiers: _tiers, serviceTiers: _serviceTiers, ...rest } = model;
|
|
2336
|
+
row = Object.freeze({
|
|
2337
|
+
...rest,
|
|
2338
|
+
inputPerMTok: sheet.inputPerMTok,
|
|
2339
|
+
outputPerMTok: sheet.outputPerMTok,
|
|
2340
|
+
...(sheet.tiers !== undefined ? { tiers: sheet.tiers } : {}),
|
|
2341
|
+
});
|
|
2342
|
+
rows.set(tier, row);
|
|
2343
|
+
}
|
|
2344
|
+
return row;
|
|
2345
|
+
}
|
|
1908
2346
|
const pricingMemo = new WeakMap();
|
|
1909
2347
|
/**
|
|
1910
2348
|
* The row as it stood at `on`: itself when the current price applies, or a
|
|
@@ -1919,7 +2357,8 @@ function pricedAt(model, on) {
|
|
|
1919
2357
|
let periods = periodMemo.get(model);
|
|
1920
2358
|
if (periods === undefined) {
|
|
1921
2359
|
periods = history.map((period) => {
|
|
1922
|
-
|
|
2360
|
+
// A period's own price only: the service tiers below are today's tables.
|
|
2361
|
+
const { history: _history, promo: _promo, tiers: _tiers, multipliers: _multipliers, serviceTiers: _serviceTiers, ...rest } = model;
|
|
1923
2362
|
const row = Object.freeze({
|
|
1924
2363
|
...rest,
|
|
1925
2364
|
inputPerMTok: period.inputPerMTok,
|
|
@@ -2011,6 +2450,18 @@ export function effectivePricing(model, on = new Date(), context = {}) {
|
|
|
2011
2450
|
if (period !== model)
|
|
2012
2451
|
return effectivePricing(period, on, context);
|
|
2013
2452
|
}
|
|
2453
|
+
/*
|
|
2454
|
+
* A response that names another service tier is priced by that tier's own
|
|
2455
|
+
* table, long band included, and by nothing composed out of two.
|
|
2456
|
+
*/
|
|
2457
|
+
if (context.serviceTier !== undefined && model.serviceTiers !== undefined) {
|
|
2458
|
+
const named = serviceTierOf(context.serviceTier);
|
|
2459
|
+
const row = named === undefined ? undefined : serviceTierRow(model, named);
|
|
2460
|
+
if (row !== undefined) {
|
|
2461
|
+
const { serviceTier: _serviceTier, ...size } = context;
|
|
2462
|
+
return { ...effectivePricing(row, on, size), serviceTier: named };
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2014
2465
|
const memo = pricingMemo.get(model) ?? cache(model);
|
|
2015
2466
|
/**
|
|
2016
2467
|
* Tiers first, and a promotion never runs on top of one.
|