@pydantic/genai-prices 0.0.51 → 0.0.53
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/cli.js +605 -243
- package/dist/index.cjs +4 -4
- package/dist/index.js +496 -134
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const I = [
|
|
2
2
|
{
|
|
3
3
|
id: "anthropic",
|
|
4
4
|
name: "Anthropic",
|
|
@@ -338,6 +338,66 @@ const B = [
|
|
|
338
338
|
output_mtok: 25
|
|
339
339
|
}
|
|
340
340
|
},
|
|
341
|
+
{
|
|
342
|
+
id: "claude-opus-4-6",
|
|
343
|
+
name: "Claude Opus 4.6",
|
|
344
|
+
description: "Most intelligent model with adaptive thinking and 1M context beta",
|
|
345
|
+
match: {
|
|
346
|
+
or: [
|
|
347
|
+
{
|
|
348
|
+
starts_with: "claude-opus-4-6"
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
starts_with: "claude-opus-4.6"
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
starts_with: "claude-4-6-opus"
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
starts_with: "claude-4.6-opus"
|
|
358
|
+
}
|
|
359
|
+
]
|
|
360
|
+
},
|
|
361
|
+
context_window: 2e5,
|
|
362
|
+
prices: {
|
|
363
|
+
input_mtok: {
|
|
364
|
+
base: 5,
|
|
365
|
+
tiers: [
|
|
366
|
+
{
|
|
367
|
+
start: 2e5,
|
|
368
|
+
price: 10
|
|
369
|
+
}
|
|
370
|
+
]
|
|
371
|
+
},
|
|
372
|
+
cache_write_mtok: {
|
|
373
|
+
base: 6.25,
|
|
374
|
+
tiers: [
|
|
375
|
+
{
|
|
376
|
+
start: 2e5,
|
|
377
|
+
price: 12.5
|
|
378
|
+
}
|
|
379
|
+
]
|
|
380
|
+
},
|
|
381
|
+
cache_read_mtok: {
|
|
382
|
+
base: 0.5,
|
|
383
|
+
tiers: [
|
|
384
|
+
{
|
|
385
|
+
start: 2e5,
|
|
386
|
+
price: 1
|
|
387
|
+
}
|
|
388
|
+
]
|
|
389
|
+
},
|
|
390
|
+
output_mtok: {
|
|
391
|
+
base: 25,
|
|
392
|
+
tiers: [
|
|
393
|
+
{
|
|
394
|
+
start: 2e5,
|
|
395
|
+
price: 37.5
|
|
396
|
+
}
|
|
397
|
+
]
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
},
|
|
341
401
|
{
|
|
342
402
|
id: "claude-sonnet-4-0",
|
|
343
403
|
name: "Claude Sonnet 4",
|
|
@@ -2172,6 +2232,20 @@ Compared to other leading proprietary and open-weights models Command A delivers
|
|
|
2172
2232
|
output_mtok: 0.9
|
|
2173
2233
|
}
|
|
2174
2234
|
},
|
|
2235
|
+
{
|
|
2236
|
+
id: "deepseek-v3p2",
|
|
2237
|
+
name: "Deepseek V3.2",
|
|
2238
|
+
description: "Model from Deepseek that harmonizes high computational efficiency with superior reasoning and agent performance. 675B parameter MoE model.",
|
|
2239
|
+
match: {
|
|
2240
|
+
equals: "accounts/fireworks/models/deepseek-v3p2"
|
|
2241
|
+
},
|
|
2242
|
+
context_window: 163840,
|
|
2243
|
+
prices: {
|
|
2244
|
+
input_mtok: 0.56,
|
|
2245
|
+
cache_read_mtok: 0.28,
|
|
2246
|
+
output_mtok: 1.68
|
|
2247
|
+
}
|
|
2248
|
+
},
|
|
2175
2249
|
{
|
|
2176
2250
|
id: "gemma-3-27b-it",
|
|
2177
2251
|
name: "Gemma 3 27B Instruct",
|
|
@@ -2185,6 +2259,61 @@ Compared to other leading proprietary and open-weights models Command A delivers
|
|
|
2185
2259
|
output_mtok: 0.1
|
|
2186
2260
|
}
|
|
2187
2261
|
},
|
|
2262
|
+
{
|
|
2263
|
+
id: "glm-4p7",
|
|
2264
|
+
name: "GLM-4.7",
|
|
2265
|
+
description: "Next-generation general-purpose model from Z.ai optimized for coding, reasoning, and agentic workflows. 352B parameter MoE model with advanced thinking controls.",
|
|
2266
|
+
match: {
|
|
2267
|
+
equals: "accounts/fireworks/models/glm-4p7"
|
|
2268
|
+
},
|
|
2269
|
+
context_window: 202752,
|
|
2270
|
+
prices: {
|
|
2271
|
+
input_mtok: 0.6,
|
|
2272
|
+
output_mtok: 2.2
|
|
2273
|
+
}
|
|
2274
|
+
},
|
|
2275
|
+
{
|
|
2276
|
+
id: "gpt-oss-120b",
|
|
2277
|
+
name: "OpenAI gpt-oss-120b",
|
|
2278
|
+
description: "OpenAI's open-weight 117B parameter MoE model designed for production, general purpose, high reasoning use-cases. Features powerful reasoning, agentic tasks, and versatile developer use cases.",
|
|
2279
|
+
match: {
|
|
2280
|
+
equals: "accounts/fireworks/models/gpt-oss-120b"
|
|
2281
|
+
},
|
|
2282
|
+
context_window: 131072,
|
|
2283
|
+
prices: {
|
|
2284
|
+
input_mtok: 0.15,
|
|
2285
|
+
cache_read_mtok: 0.07,
|
|
2286
|
+
output_mtok: 0.6
|
|
2287
|
+
}
|
|
2288
|
+
},
|
|
2289
|
+
{
|
|
2290
|
+
id: "gpt-oss-20b",
|
|
2291
|
+
name: "OpenAI gpt-oss-20b",
|
|
2292
|
+
description: "OpenAI's open-weight 21.5B parameter model designed for powerful reasoning, agentic tasks, and versatile developer use cases. Optimized for lower latency and local or specialized tasks.",
|
|
2293
|
+
match: {
|
|
2294
|
+
equals: "accounts/fireworks/models/gpt-oss-20b"
|
|
2295
|
+
},
|
|
2296
|
+
context_window: 131072,
|
|
2297
|
+
prices: {
|
|
2298
|
+
input_mtok: 0.07,
|
|
2299
|
+
cache_read_mtok: 0.04,
|
|
2300
|
+
output_mtok: 0.3
|
|
2301
|
+
}
|
|
2302
|
+
},
|
|
2303
|
+
{
|
|
2304
|
+
id: "kimi-k2p5",
|
|
2305
|
+
name: "Kimi K2.5",
|
|
2306
|
+
description: "Moonshot AI's flagship agentic model. Unifies vision and text, thinking and non-thinking modes, and single-agent and multi-agent execution into one model. 1T parameter MoE model.",
|
|
2307
|
+
match: {
|
|
2308
|
+
equals: "accounts/fireworks/models/kimi-k2p5"
|
|
2309
|
+
},
|
|
2310
|
+
context_window: 262144,
|
|
2311
|
+
prices: {
|
|
2312
|
+
input_mtok: 0.6,
|
|
2313
|
+
cache_read_mtok: 0.1,
|
|
2314
|
+
output_mtok: 3
|
|
2315
|
+
}
|
|
2316
|
+
},
|
|
2188
2317
|
{
|
|
2189
2318
|
id: "llama-v3p1-8b-instruct",
|
|
2190
2319
|
name: "Llama 3.1 8B Instruct",
|
|
@@ -2212,6 +2341,19 @@ Compared to other leading proprietary and open-weights models Command A delivers
|
|
|
2212
2341
|
output_mtok: 0.88
|
|
2213
2342
|
}
|
|
2214
2343
|
},
|
|
2344
|
+
{
|
|
2345
|
+
id: "minimax-m2p1",
|
|
2346
|
+
name: "MiniMax-M2.1",
|
|
2347
|
+
description: "Built for strong real-world performance across complex, multi-language, and agent-driven workflows. 228B parameter model with robust support for systems, backend, web, mobile, and office-style tasks.",
|
|
2348
|
+
match: {
|
|
2349
|
+
equals: "accounts/fireworks/models/minimax-m2p1"
|
|
2350
|
+
},
|
|
2351
|
+
context_window: 204800,
|
|
2352
|
+
prices: {
|
|
2353
|
+
input_mtok: 0.3,
|
|
2354
|
+
output_mtok: 1.2
|
|
2355
|
+
}
|
|
2356
|
+
},
|
|
2215
2357
|
{
|
|
2216
2358
|
id: "qwen2p5-vl-72b-instruct",
|
|
2217
2359
|
name: "Qwen2.5-VL 72B Instruct",
|
|
@@ -2484,7 +2626,16 @@ Compared to other leading proprietary and open-weights models Command A delivers
|
|
|
2484
2626
|
contains: "claude-4-opus"
|
|
2485
2627
|
},
|
|
2486
2628
|
{
|
|
2487
|
-
contains: "claude-opus-4"
|
|
2629
|
+
contains: "claude-opus-4@"
|
|
2630
|
+
},
|
|
2631
|
+
{
|
|
2632
|
+
contains: "claude-opus-4-0"
|
|
2633
|
+
},
|
|
2634
|
+
{
|
|
2635
|
+
contains: "claude-opus-4-1"
|
|
2636
|
+
},
|
|
2637
|
+
{
|
|
2638
|
+
equals: "claude-opus-4"
|
|
2488
2639
|
}
|
|
2489
2640
|
]
|
|
2490
2641
|
},
|
|
@@ -2516,6 +2667,64 @@ Compared to other leading proprietary and open-weights models Command A delivers
|
|
|
2516
2667
|
output_mtok: 15
|
|
2517
2668
|
}
|
|
2518
2669
|
},
|
|
2670
|
+
{
|
|
2671
|
+
id: "claude-opus-4-6",
|
|
2672
|
+
match: {
|
|
2673
|
+
or: [
|
|
2674
|
+
{
|
|
2675
|
+
contains: "claude-4-6-opus"
|
|
2676
|
+
},
|
|
2677
|
+
{
|
|
2678
|
+
contains: "claude-opus-4-6"
|
|
2679
|
+
},
|
|
2680
|
+
{
|
|
2681
|
+
contains: "claude-4.6-opus"
|
|
2682
|
+
},
|
|
2683
|
+
{
|
|
2684
|
+
contains: "claude-opus-4.6"
|
|
2685
|
+
}
|
|
2686
|
+
]
|
|
2687
|
+
},
|
|
2688
|
+
context_window: 2e5,
|
|
2689
|
+
prices: {
|
|
2690
|
+
input_mtok: {
|
|
2691
|
+
base: 5,
|
|
2692
|
+
tiers: [
|
|
2693
|
+
{
|
|
2694
|
+
start: 2e5,
|
|
2695
|
+
price: 10
|
|
2696
|
+
}
|
|
2697
|
+
]
|
|
2698
|
+
},
|
|
2699
|
+
cache_write_mtok: {
|
|
2700
|
+
base: 6.25,
|
|
2701
|
+
tiers: [
|
|
2702
|
+
{
|
|
2703
|
+
start: 2e5,
|
|
2704
|
+
price: 12.5
|
|
2705
|
+
}
|
|
2706
|
+
]
|
|
2707
|
+
},
|
|
2708
|
+
cache_read_mtok: {
|
|
2709
|
+
base: 0.5,
|
|
2710
|
+
tiers: [
|
|
2711
|
+
{
|
|
2712
|
+
start: 2e5,
|
|
2713
|
+
price: 1
|
|
2714
|
+
}
|
|
2715
|
+
]
|
|
2716
|
+
},
|
|
2717
|
+
output_mtok: {
|
|
2718
|
+
base: 25,
|
|
2719
|
+
tiers: [
|
|
2720
|
+
{
|
|
2721
|
+
start: 2e5,
|
|
2722
|
+
price: 37.5
|
|
2723
|
+
}
|
|
2724
|
+
]
|
|
2725
|
+
}
|
|
2726
|
+
}
|
|
2727
|
+
},
|
|
2519
2728
|
{
|
|
2520
2729
|
id: "gemini-1.0-pro-vision-001",
|
|
2521
2730
|
name: "gemini 1.0 pro vision",
|
|
@@ -8989,6 +9198,12 @@ Compared to other leading proprietary and open-weights models Command A delivers
|
|
|
8989
9198
|
{
|
|
8990
9199
|
equals: "gpt-5.1-codex"
|
|
8991
9200
|
},
|
|
9201
|
+
{
|
|
9202
|
+
equals: "gpt-5.1-codex-max"
|
|
9203
|
+
},
|
|
9204
|
+
{
|
|
9205
|
+
equals: "gpt-5.1-chat"
|
|
9206
|
+
},
|
|
8992
9207
|
{
|
|
8993
9208
|
equals: "gpt-5.1-chat-latest"
|
|
8994
9209
|
},
|
|
@@ -9001,6 +9216,12 @@ Compared to other leading proprietary and open-weights models Command A delivers
|
|
|
9001
9216
|
{
|
|
9002
9217
|
equals: "gpt-5-1-codex"
|
|
9003
9218
|
},
|
|
9219
|
+
{
|
|
9220
|
+
equals: "gpt-5-1-codex-max"
|
|
9221
|
+
},
|
|
9222
|
+
{
|
|
9223
|
+
equals: "gpt-5-1-chat"
|
|
9224
|
+
},
|
|
9004
9225
|
{
|
|
9005
9226
|
equals: "gpt-5-1-chat-latest"
|
|
9006
9227
|
}
|
|
@@ -9057,8 +9278,23 @@ Compared to other leading proprietary and open-weights models Command A delivers
|
|
|
9057
9278
|
{
|
|
9058
9279
|
equals: "gpt-5-2-2025-12-11"
|
|
9059
9280
|
},
|
|
9281
|
+
{
|
|
9282
|
+
equals: "gpt-5.2-chat"
|
|
9283
|
+
},
|
|
9284
|
+
{
|
|
9285
|
+
equals: "gpt-5.2-chat-latest"
|
|
9286
|
+
},
|
|
9287
|
+
{
|
|
9288
|
+
equals: "gpt-5-2-chat"
|
|
9289
|
+
},
|
|
9060
9290
|
{
|
|
9061
9291
|
equals: "gpt-5-2-chat-latest"
|
|
9292
|
+
},
|
|
9293
|
+
{
|
|
9294
|
+
equals: "gpt-5.2-codex"
|
|
9295
|
+
},
|
|
9296
|
+
{
|
|
9297
|
+
equals: "gpt-5-2-codex"
|
|
9062
9298
|
}
|
|
9063
9299
|
]
|
|
9064
9300
|
},
|
|
@@ -9834,6 +10070,57 @@ Compared to other leading proprietary and open-weights models Command A delivers
|
|
|
9834
10070
|
output_mtok: 25
|
|
9835
10071
|
}
|
|
9836
10072
|
},
|
|
10073
|
+
{
|
|
10074
|
+
id: "anthropic/claude-opus-4.6",
|
|
10075
|
+
match: {
|
|
10076
|
+
or: [
|
|
10077
|
+
{
|
|
10078
|
+
equals: "anthropic/claude-opus-4.6"
|
|
10079
|
+
},
|
|
10080
|
+
{
|
|
10081
|
+
equals: "anthropic/claude-opus-4.6:beta"
|
|
10082
|
+
}
|
|
10083
|
+
]
|
|
10084
|
+
},
|
|
10085
|
+
prices: {
|
|
10086
|
+
input_mtok: {
|
|
10087
|
+
base: 5,
|
|
10088
|
+
tiers: [
|
|
10089
|
+
{
|
|
10090
|
+
start: 2e5,
|
|
10091
|
+
price: 10
|
|
10092
|
+
}
|
|
10093
|
+
]
|
|
10094
|
+
},
|
|
10095
|
+
cache_write_mtok: {
|
|
10096
|
+
base: 6.25,
|
|
10097
|
+
tiers: [
|
|
10098
|
+
{
|
|
10099
|
+
start: 2e5,
|
|
10100
|
+
price: 12.5
|
|
10101
|
+
}
|
|
10102
|
+
]
|
|
10103
|
+
},
|
|
10104
|
+
cache_read_mtok: {
|
|
10105
|
+
base: 0.5,
|
|
10106
|
+
tiers: [
|
|
10107
|
+
{
|
|
10108
|
+
start: 2e5,
|
|
10109
|
+
price: 1
|
|
10110
|
+
}
|
|
10111
|
+
]
|
|
10112
|
+
},
|
|
10113
|
+
output_mtok: {
|
|
10114
|
+
base: 25,
|
|
10115
|
+
tiers: [
|
|
10116
|
+
{
|
|
10117
|
+
start: 2e5,
|
|
10118
|
+
price: 37.5
|
|
10119
|
+
}
|
|
10120
|
+
]
|
|
10121
|
+
}
|
|
10122
|
+
}
|
|
10123
|
+
},
|
|
9837
10124
|
{
|
|
9838
10125
|
id: "anthropic/claude-sonnet-4.5",
|
|
9839
10126
|
match: {
|
|
@@ -13537,6 +13824,17 @@ Compared to other leading proprietary and open-weights models Command A delivers
|
|
|
13537
13824
|
output_mtok: 1.2
|
|
13538
13825
|
}
|
|
13539
13826
|
},
|
|
13827
|
+
{
|
|
13828
|
+
id: "moonshotai/kimi-k2.5",
|
|
13829
|
+
name: "Kimi K2.5",
|
|
13830
|
+
match: {
|
|
13831
|
+
equals: "moonshotai/kimi-k2.5"
|
|
13832
|
+
},
|
|
13833
|
+
prices: {
|
|
13834
|
+
input_mtok: 0.6,
|
|
13835
|
+
output_mtok: 3
|
|
13836
|
+
}
|
|
13837
|
+
},
|
|
13540
13838
|
{
|
|
13541
13839
|
id: "moonshotai/kimi-vl-a3b-thinking:free",
|
|
13542
13840
|
match: {
|
|
@@ -14963,6 +15261,17 @@ Compared to other leading proprietary and open-weights models Command A delivers
|
|
|
14963
15261
|
},
|
|
14964
15262
|
prices: {}
|
|
14965
15263
|
},
|
|
15264
|
+
{
|
|
15265
|
+
id: "qwen/qwen3-max",
|
|
15266
|
+
name: "Qwen 3 Max",
|
|
15267
|
+
match: {
|
|
15268
|
+
equals: "qwen/qwen3-max"
|
|
15269
|
+
},
|
|
15270
|
+
prices: {
|
|
15271
|
+
input_mtok: 1.2,
|
|
15272
|
+
output_mtok: 6
|
|
15273
|
+
}
|
|
15274
|
+
},
|
|
14966
15275
|
{
|
|
14967
15276
|
id: "qwen/qwq-32b",
|
|
14968
15277
|
match: {
|
|
@@ -17250,6 +17559,51 @@ Compared to other leading proprietary and open-weights models Command A delivers
|
|
|
17250
17559
|
output_mtok: 0.5
|
|
17251
17560
|
}
|
|
17252
17561
|
},
|
|
17562
|
+
{
|
|
17563
|
+
id: "grok-4-fast-non-reasoning",
|
|
17564
|
+
name: "Grok 4 Fast Non-Reasoning",
|
|
17565
|
+
description: "A frontier multimodal model optimized specifically for high-performance agentic tool calling.",
|
|
17566
|
+
match: {
|
|
17567
|
+
or: [
|
|
17568
|
+
{
|
|
17569
|
+
equals: "grok-4-fast-non-reasoning"
|
|
17570
|
+
},
|
|
17571
|
+
{
|
|
17572
|
+
equals: "grok-4-fast-non-reasoning-latest"
|
|
17573
|
+
}
|
|
17574
|
+
]
|
|
17575
|
+
},
|
|
17576
|
+
context_window: 2e6,
|
|
17577
|
+
prices: {
|
|
17578
|
+
input_mtok: 0.2,
|
|
17579
|
+
cache_read_mtok: 0.05,
|
|
17580
|
+
output_mtok: 0.5
|
|
17581
|
+
}
|
|
17582
|
+
},
|
|
17583
|
+
{
|
|
17584
|
+
id: "grok-4-fast-reasoning",
|
|
17585
|
+
name: "Grok 4 Fast Reasoning",
|
|
17586
|
+
description: "A frontier multimodal model optimized specifically for high-performance agentic tool calling.",
|
|
17587
|
+
match: {
|
|
17588
|
+
or: [
|
|
17589
|
+
{
|
|
17590
|
+
equals: "grok-4-fast"
|
|
17591
|
+
},
|
|
17592
|
+
{
|
|
17593
|
+
equals: "grok-4-fast-reasoning"
|
|
17594
|
+
},
|
|
17595
|
+
{
|
|
17596
|
+
equals: "grok-4-fast-reasoning-latest"
|
|
17597
|
+
}
|
|
17598
|
+
]
|
|
17599
|
+
},
|
|
17600
|
+
context_window: 2e6,
|
|
17601
|
+
prices: {
|
|
17602
|
+
input_mtok: 0.2,
|
|
17603
|
+
cache_read_mtok: 0.05,
|
|
17604
|
+
output_mtok: 0.5
|
|
17605
|
+
}
|
|
17606
|
+
},
|
|
17253
17607
|
{
|
|
17254
17608
|
id: "grok-code-fast-1",
|
|
17255
17609
|
name: "Grok Code Fast 1",
|
|
@@ -17277,235 +17631,243 @@ Compared to other leading proprietary and open-weights models Command A delivers
|
|
|
17277
17631
|
]
|
|
17278
17632
|
}
|
|
17279
17633
|
];
|
|
17280
|
-
function L(
|
|
17281
|
-
if (
|
|
17282
|
-
let
|
|
17283
|
-
for (const o of
|
|
17284
|
-
|
|
17285
|
-
return
|
|
17634
|
+
function L(e, t, i) {
|
|
17635
|
+
if (t <= 0) return 0;
|
|
17636
|
+
let a = e.base;
|
|
17637
|
+
for (const o of e.tiers)
|
|
17638
|
+
i > o.start && (a = o.price);
|
|
17639
|
+
return a * t / 1e6;
|
|
17286
17640
|
}
|
|
17287
|
-
function
|
|
17288
|
-
return
|
|
17641
|
+
function l(e, t, i, a) {
|
|
17642
|
+
return e === void 0 || t === void 0 ? 0 : typeof e == "number" ? e * t / 1e6 : L(e, t, a);
|
|
17289
17643
|
}
|
|
17290
|
-
function Q(
|
|
17291
|
-
let
|
|
17292
|
-
const o =
|
|
17293
|
-
let u =
|
|
17644
|
+
function Q(e, t) {
|
|
17645
|
+
let i = 0, a = 0;
|
|
17646
|
+
const o = e.input_tokens ?? 0, s = e.cache_read_tokens ?? 0, m = e.cache_write_tokens ?? 0, n = e.cache_audio_read_tokens ?? 0, r = e.output_audio_tokens ?? 0;
|
|
17647
|
+
let u = e.input_audio_tokens ?? 0;
|
|
17294
17648
|
if (u -= n, u < 0)
|
|
17295
17649
|
throw new Error("cache_audio_read_tokens cannot be greater than input_audio_tokens");
|
|
17296
|
-
let p =
|
|
17650
|
+
let p = e.input_tokens ?? 0;
|
|
17297
17651
|
if (p -= s, p -= m, p -= u, p < 0)
|
|
17298
17652
|
throw new Error("Uncached text input tokens cannot be negative");
|
|
17299
|
-
let
|
|
17300
|
-
if (
|
|
17653
|
+
let c = s;
|
|
17654
|
+
if (c -= n, c < 0)
|
|
17301
17655
|
throw new Error("cache_audio_read_tokens cannot be greater than cache_read_tokens");
|
|
17302
|
-
|
|
17303
|
-
let
|
|
17304
|
-
if (
|
|
17656
|
+
i += l(t.input_mtok, p, "input_mtok", o), i += l(t.cache_read_mtok, c, "cache_read_mtok", o), i += l(t.cache_write_mtok, m, "cache_write_mtok", o), i += l(t.input_audio_mtok, u, "input_audio_mtok", o), i += l(t.cache_audio_read_mtok, n, "cache_audio_read_mtok", o);
|
|
17657
|
+
let _ = e.output_tokens ?? 0;
|
|
17658
|
+
if (_ -= r, _ < 0)
|
|
17305
17659
|
throw new Error("output_audio_tokens cannot be greater than output_tokens");
|
|
17306
|
-
|
|
17307
|
-
let
|
|
17308
|
-
return
|
|
17309
|
-
input_price:
|
|
17310
|
-
output_price:
|
|
17311
|
-
total_price:
|
|
17660
|
+
a += l(t.output_mtok, _, "output_mtok", o), a += l(t.output_audio_mtok, e.output_audio_tokens, "output_audio_mtok", o);
|
|
17661
|
+
let x = i + a;
|
|
17662
|
+
return t.requests_kcount !== void 0 && (x += t.requests_kcount / 1e3), {
|
|
17663
|
+
input_price: i,
|
|
17664
|
+
output_price: a,
|
|
17665
|
+
total_price: x
|
|
17312
17666
|
};
|
|
17313
17667
|
}
|
|
17314
|
-
function T(
|
|
17315
|
-
if (!Array.isArray(
|
|
17316
|
-
return
|
|
17317
|
-
for (let
|
|
17318
|
-
const
|
|
17668
|
+
function T(e, t) {
|
|
17669
|
+
if (!Array.isArray(e.prices))
|
|
17670
|
+
return e.prices;
|
|
17671
|
+
for (let i = e.prices.length - 1; i >= 0; i--) {
|
|
17672
|
+
const a = e.prices[i], o = a.constraint;
|
|
17319
17673
|
if (o === void 0)
|
|
17320
|
-
return
|
|
17674
|
+
return a.prices;
|
|
17321
17675
|
if (o.type === "start_date") {
|
|
17322
|
-
if (
|
|
17323
|
-
return
|
|
17676
|
+
if (t >= new Date(o.start_date))
|
|
17677
|
+
return a.prices;
|
|
17324
17678
|
} else {
|
|
17325
|
-
const s =
|
|
17679
|
+
const s = t.toISOString().slice(11, 19), m = o.start_time, n = o.end_time;
|
|
17326
17680
|
if (n < m) {
|
|
17327
17681
|
if (s >= m || s < n)
|
|
17328
|
-
return
|
|
17682
|
+
return a.prices;
|
|
17329
17683
|
} else if (s >= m && s < n)
|
|
17330
|
-
return
|
|
17684
|
+
return a.prices;
|
|
17331
17685
|
}
|
|
17332
17686
|
}
|
|
17333
|
-
return
|
|
17687
|
+
return e.prices[0].prices;
|
|
17334
17688
|
}
|
|
17335
|
-
function
|
|
17336
|
-
return "or" in
|
|
17689
|
+
function g(e, t) {
|
|
17690
|
+
return "or" in e ? e.or.some((i) => g(i, t)) : "and" in e ? e.and.every((i) => g(i, t)) : "equals" in e ? t === e.equals : "starts_with" in e ? t.startsWith(e.starts_with) : "ends_with" in e ? t.endsWith(e.ends_with) : "contains" in e ? t.includes(e.contains) : "regex" in e ? new RegExp(e.regex).test(t) : !1;
|
|
17337
17691
|
}
|
|
17338
|
-
function P(
|
|
17339
|
-
const
|
|
17340
|
-
return
|
|
17692
|
+
function P(e, t) {
|
|
17693
|
+
const i = t.toLowerCase().trim(), a = e.find((o) => o.id === i);
|
|
17694
|
+
return a || e.find((o) => o.provider_match && g(o.provider_match, i));
|
|
17341
17695
|
}
|
|
17342
|
-
function
|
|
17696
|
+
function b(e, { modelId: t, providerApiUrl: i, providerId: a }) {
|
|
17697
|
+
if (a) {
|
|
17698
|
+
const o = P(e, a);
|
|
17699
|
+
if (o || a.toLowerCase() !== "litellm")
|
|
17700
|
+
return o;
|
|
17701
|
+
}
|
|
17343
17702
|
if (i)
|
|
17344
|
-
return
|
|
17345
|
-
if (
|
|
17346
|
-
return
|
|
17347
|
-
if (e)
|
|
17348
|
-
return t.find((o) => o.model_match && _(o.model_match, e));
|
|
17703
|
+
return e.find((o) => new RegExp(o.api_pattern).test(i));
|
|
17704
|
+
if (t)
|
|
17705
|
+
return e.find((o) => o.model_match && g(o.model_match, t));
|
|
17349
17706
|
}
|
|
17350
|
-
function S(
|
|
17351
|
-
return
|
|
17707
|
+
function S(e, t) {
|
|
17708
|
+
return e.find((i) => g(i.match, t));
|
|
17352
17709
|
}
|
|
17353
|
-
function M(
|
|
17354
|
-
const
|
|
17355
|
-
if (
|
|
17356
|
-
if (
|
|
17357
|
-
for (const o of
|
|
17358
|
-
const s =
|
|
17710
|
+
function M(e, t, i) {
|
|
17711
|
+
const a = S(e.models, t);
|
|
17712
|
+
if (a) return a;
|
|
17713
|
+
if (e.fallback_model_providers && i)
|
|
17714
|
+
for (const o of e.fallback_model_providers) {
|
|
17715
|
+
const s = i.find((m) => m.id === o);
|
|
17359
17716
|
if (s) {
|
|
17360
|
-
const m = M(s,
|
|
17717
|
+
const m = M(s, t);
|
|
17361
17718
|
if (m) return m;
|
|
17362
17719
|
}
|
|
17363
17720
|
}
|
|
17364
17721
|
}
|
|
17365
17722
|
const A = "https://raw.githubusercontent.com/pydantic/genai-prices/main/prices/data.json";
|
|
17366
|
-
let h =
|
|
17367
|
-
function G(
|
|
17368
|
-
|
|
17369
|
-
|
|
17370
|
-
})) : (
|
|
17723
|
+
let h = I, f = Promise.resolve(I), v = null;
|
|
17724
|
+
function G(e) {
|
|
17725
|
+
e !== null && ("then" in e ? (f = e, e.then((t) => {
|
|
17726
|
+
t !== null && (h = t);
|
|
17727
|
+
})) : (f = Promise.resolve(e), h = e));
|
|
17371
17728
|
}
|
|
17372
|
-
function R(
|
|
17373
|
-
|
|
17729
|
+
function R(e) {
|
|
17730
|
+
v = e;
|
|
17374
17731
|
}
|
|
17375
|
-
function N(
|
|
17376
|
-
|
|
17732
|
+
function N(e) {
|
|
17733
|
+
e({
|
|
17377
17734
|
onCalc: R,
|
|
17378
17735
|
remoteDataUrl: A,
|
|
17379
17736
|
setProviderData: G
|
|
17380
17737
|
});
|
|
17381
17738
|
}
|
|
17382
|
-
function
|
|
17383
|
-
return
|
|
17739
|
+
function E() {
|
|
17740
|
+
return f;
|
|
17384
17741
|
}
|
|
17385
|
-
function
|
|
17386
|
-
|
|
17387
|
-
|
|
17388
|
-
if (
|
|
17389
|
-
|
|
17742
|
+
function V(e, t, i) {
|
|
17743
|
+
v?.();
|
|
17744
|
+
let a = t.toLowerCase().trim(), o = i?.providerId;
|
|
17745
|
+
if (o && o.toLowerCase() === "litellm" && a.includes("/")) {
|
|
17746
|
+
const p = a.indexOf("/"), c = a.slice(0, p), _ = a.slice(p + 1);
|
|
17747
|
+
c && _ && b(h, { providerId: c }) && (o = c, a = _);
|
|
17748
|
+
}
|
|
17749
|
+
const s = i?.provider ?? b(h, { modelId: a, providerApiUrl: i?.providerApiUrl, providerId: o });
|
|
17390
17750
|
if (!s) return null;
|
|
17391
|
-
const m =
|
|
17751
|
+
const m = M(s, a, h);
|
|
17752
|
+
if (!m) return null;
|
|
17753
|
+
const n = i?.timestamp ?? /* @__PURE__ */ new Date(), r = T(m, n), u = Q(e, r);
|
|
17392
17754
|
return {
|
|
17393
17755
|
auto_update_timestamp: void 0,
|
|
17394
|
-
model:
|
|
17395
|
-
model_price:
|
|
17396
|
-
provider:
|
|
17397
|
-
...
|
|
17756
|
+
model: m,
|
|
17757
|
+
model_price: r,
|
|
17758
|
+
provider: s,
|
|
17759
|
+
...u
|
|
17398
17760
|
};
|
|
17399
17761
|
}
|
|
17400
|
-
function O(
|
|
17401
|
-
return
|
|
17762
|
+
function O(e) {
|
|
17763
|
+
return v?.(), b(h, e);
|
|
17402
17764
|
}
|
|
17403
|
-
function F(
|
|
17404
|
-
if (
|
|
17765
|
+
function F(e, t, i) {
|
|
17766
|
+
if (i = i ?? "default", !e.extractors)
|
|
17405
17767
|
throw new Error("No extraction logic defined for this provider");
|
|
17406
|
-
const
|
|
17407
|
-
if (!
|
|
17408
|
-
const r =
|
|
17409
|
-
throw new Error(`Unknown apiFlavor '${
|
|
17768
|
+
const a = e.extractors.find((r) => r.api_flavor === i);
|
|
17769
|
+
if (!a) {
|
|
17770
|
+
const r = e.extractors.map((u) => u.api_flavor).join(", ");
|
|
17771
|
+
throw new Error(`Unknown apiFlavor '${i}', allowed values: ${r}`);
|
|
17410
17772
|
}
|
|
17411
|
-
if (!
|
|
17412
|
-
throw new Error(`Expected response data to be a mapping object, got ${
|
|
17413
|
-
const o = w(
|
|
17414
|
-
for (const r of
|
|
17415
|
-
const u = w(r.path, m,
|
|
17773
|
+
if (!q.guard(t))
|
|
17774
|
+
throw new Error(`Expected response data to be a mapping object, got ${d(t)}`);
|
|
17775
|
+
const o = w(a.model_path, t, z, !1, []), s = y(a.root), m = w(s, t, q, !0, []), n = {};
|
|
17776
|
+
for (const r of a.mappings) {
|
|
17777
|
+
const u = w(r.path, m, C, r.required, s);
|
|
17416
17778
|
if (u !== null) {
|
|
17417
17779
|
const p = n[r.dest] ?? 0;
|
|
17418
17780
|
n[r.dest] = p + u;
|
|
17419
17781
|
}
|
|
17420
17782
|
}
|
|
17421
17783
|
if (!Object.keys(n).length)
|
|
17422
|
-
throw new Error(`No usage information found at ${JSON.stringify(
|
|
17784
|
+
throw new Error(`No usage information found at ${JSON.stringify(a.root)}`);
|
|
17423
17785
|
return { model: o, usage: n };
|
|
17424
17786
|
}
|
|
17425
|
-
function w(t,
|
|
17426
|
-
const [s, ...m] = y(
|
|
17787
|
+
function w(e, t, i, a, o) {
|
|
17788
|
+
const [s, ...m] = y(e).reverse();
|
|
17427
17789
|
if (typeof s != "string")
|
|
17428
|
-
throw new Error(`Expected last step of path to be a string, got ${
|
|
17790
|
+
throw new Error(`Expected last step of path to be a string, got ${d(s)}`);
|
|
17429
17791
|
m.reverse();
|
|
17430
|
-
let n =
|
|
17792
|
+
let n = t;
|
|
17431
17793
|
const r = [];
|
|
17432
17794
|
for (const p of m) {
|
|
17433
17795
|
if (r.push(p), typeof p == "object")
|
|
17434
17796
|
if (Array.isArray(n))
|
|
17435
17797
|
n = D(p, n);
|
|
17436
17798
|
else {
|
|
17437
|
-
if (
|
|
17438
|
-
throw new Error(`Expected \`${
|
|
17799
|
+
if (a)
|
|
17800
|
+
throw new Error(`Expected \`${k(o, r)}\` value to be a mapping, got ${d(n)}`);
|
|
17439
17801
|
return null;
|
|
17440
17802
|
}
|
|
17441
|
-
else if (
|
|
17803
|
+
else if (q.guard(n))
|
|
17442
17804
|
n = n[p];
|
|
17443
17805
|
else {
|
|
17444
|
-
if (
|
|
17445
|
-
throw new Error(`Expected \`${
|
|
17806
|
+
if (a)
|
|
17807
|
+
throw new Error(`Expected \`${k(o, r)}\` value to be a mapping, got ${d(n)}`);
|
|
17446
17808
|
return null;
|
|
17447
17809
|
}
|
|
17448
17810
|
if (typeof n > "u")
|
|
17449
|
-
if (
|
|
17450
|
-
const
|
|
17451
|
-
throw new Error(`${
|
|
17811
|
+
if (a) {
|
|
17812
|
+
const c = typeof p == "object" ? "Unable to find item" : "Missing value";
|
|
17813
|
+
throw new Error(`${c} at \`${k(o, r)}\``);
|
|
17452
17814
|
} else
|
|
17453
17815
|
return null;
|
|
17454
17816
|
}
|
|
17455
|
-
if (!
|
|
17456
|
-
if (
|
|
17457
|
-
throw new Error(`Expected \`${
|
|
17817
|
+
if (!q.guard(n)) {
|
|
17818
|
+
if (a)
|
|
17819
|
+
throw new Error(`Expected \`${k(o, r)}\` value to be a mapping, got ${d(n)}`);
|
|
17458
17820
|
return null;
|
|
17459
17821
|
}
|
|
17460
17822
|
const u = n[s];
|
|
17461
17823
|
if (typeof u > "u") {
|
|
17462
|
-
if (
|
|
17463
|
-
throw r.push(s), new Error(`Missing value at \`${
|
|
17824
|
+
if (a)
|
|
17825
|
+
throw r.push(s), new Error(`Missing value at \`${k(o, r)}\``);
|
|
17464
17826
|
return null;
|
|
17465
17827
|
}
|
|
17466
|
-
if (
|
|
17828
|
+
if (i.guard(u))
|
|
17467
17829
|
return u;
|
|
17468
|
-
if (
|
|
17469
|
-
throw r.push(s), new Error(`Expected \`${
|
|
17830
|
+
if (a)
|
|
17831
|
+
throw r.push(s), new Error(`Expected \`${k(o, r)}\` value to be a ${i.name}, got ${d(u)}`);
|
|
17470
17832
|
return null;
|
|
17471
17833
|
}
|
|
17472
|
-
function D(
|
|
17473
|
-
for (const
|
|
17474
|
-
if (
|
|
17475
|
-
const
|
|
17476
|
-
if (typeof
|
|
17477
|
-
return
|
|
17834
|
+
function D(e, t) {
|
|
17835
|
+
for (const i of t)
|
|
17836
|
+
if (q.guard(i)) {
|
|
17837
|
+
const a = i[e.field];
|
|
17838
|
+
if (typeof a == "string" && g(e.match, a))
|
|
17839
|
+
return i;
|
|
17478
17840
|
}
|
|
17479
17841
|
}
|
|
17480
|
-
function y(
|
|
17481
|
-
return Array.isArray(
|
|
17842
|
+
function y(e) {
|
|
17843
|
+
return Array.isArray(e) ? [...e] : [e];
|
|
17482
17844
|
}
|
|
17483
|
-
function
|
|
17484
|
-
return
|
|
17845
|
+
function d(e) {
|
|
17846
|
+
return e === null ? "null" : Array.isArray(e) ? "array" : typeof e == "object" ? "mapping" : typeof e;
|
|
17485
17847
|
}
|
|
17486
|
-
const
|
|
17487
|
-
guard: (
|
|
17848
|
+
const q = {
|
|
17849
|
+
guard: (e) => d(e) === "mapping",
|
|
17488
17850
|
name: "mapping"
|
|
17489
|
-
}, C = {
|
|
17490
|
-
guard: (t) => typeof t == "string",
|
|
17491
|
-
name: "string"
|
|
17492
17851
|
}, z = {
|
|
17493
|
-
guard: (
|
|
17852
|
+
guard: (e) => typeof e == "string",
|
|
17853
|
+
name: "string"
|
|
17854
|
+
}, C = {
|
|
17855
|
+
guard: (e) => typeof e == "number",
|
|
17494
17856
|
name: "number"
|
|
17495
|
-
},
|
|
17857
|
+
}, k = (e, t) => [...e.map(B), ...t.map(B)].join("."), B = (e) => typeof e == "string" ? e : JSON.stringify(e);
|
|
17496
17858
|
class j {
|
|
17497
17859
|
base;
|
|
17498
17860
|
tiers;
|
|
17499
|
-
constructor(
|
|
17500
|
-
this.base =
|
|
17861
|
+
constructor(t) {
|
|
17862
|
+
this.base = t.base, this.tiers = [...t.tiers].sort((i, a) => i.start - a.start);
|
|
17501
17863
|
}
|
|
17502
17864
|
}
|
|
17503
17865
|
export {
|
|
17504
17866
|
A as REMOTE_DATA_JSON_URL,
|
|
17505
17867
|
j as TieredPrices,
|
|
17506
|
-
|
|
17868
|
+
V as calcPrice,
|
|
17507
17869
|
F as extractUsage,
|
|
17508
17870
|
O as findProvider,
|
|
17509
17871
|
N as updatePrices,
|
|
17510
|
-
|
|
17872
|
+
E as waitForUpdate
|
|
17511
17873
|
};
|