@pydantic/genai-prices 0.0.51 → 0.0.52
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 +300 -219
- package/dist/index.cjs +2 -2
- package/dist/index.js +175 -94
- 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",
|
|
@@ -9059,6 +9059,12 @@ Compared to other leading proprietary and open-weights models Command A delivers
|
|
|
9059
9059
|
},
|
|
9060
9060
|
{
|
|
9061
9061
|
equals: "gpt-5-2-chat-latest"
|
|
9062
|
+
},
|
|
9063
|
+
{
|
|
9064
|
+
equals: "gpt-5.2-codex"
|
|
9065
|
+
},
|
|
9066
|
+
{
|
|
9067
|
+
equals: "gpt-5-2-codex"
|
|
9062
9068
|
}
|
|
9063
9069
|
]
|
|
9064
9070
|
},
|
|
@@ -13537,6 +13543,17 @@ Compared to other leading proprietary and open-weights models Command A delivers
|
|
|
13537
13543
|
output_mtok: 1.2
|
|
13538
13544
|
}
|
|
13539
13545
|
},
|
|
13546
|
+
{
|
|
13547
|
+
id: "moonshotai/kimi-k2.5",
|
|
13548
|
+
name: "Kimi K2.5",
|
|
13549
|
+
match: {
|
|
13550
|
+
equals: "moonshotai/kimi-k2.5"
|
|
13551
|
+
},
|
|
13552
|
+
prices: {
|
|
13553
|
+
input_mtok: 0.6,
|
|
13554
|
+
output_mtok: 3
|
|
13555
|
+
}
|
|
13556
|
+
},
|
|
13540
13557
|
{
|
|
13541
13558
|
id: "moonshotai/kimi-vl-a3b-thinking:free",
|
|
13542
13559
|
match: {
|
|
@@ -14963,6 +14980,17 @@ Compared to other leading proprietary and open-weights models Command A delivers
|
|
|
14963
14980
|
},
|
|
14964
14981
|
prices: {}
|
|
14965
14982
|
},
|
|
14983
|
+
{
|
|
14984
|
+
id: "qwen/qwen3-max-thinking",
|
|
14985
|
+
name: "Qwen 3 Max Thinking",
|
|
14986
|
+
match: {
|
|
14987
|
+
equals: "qwen/qwen3-max-thinking"
|
|
14988
|
+
},
|
|
14989
|
+
prices: {
|
|
14990
|
+
input_mtok: 1.2,
|
|
14991
|
+
output_mtok: 6
|
|
14992
|
+
}
|
|
14993
|
+
},
|
|
14966
14994
|
{
|
|
14967
14995
|
id: "qwen/qwq-32b",
|
|
14968
14996
|
match: {
|
|
@@ -17250,6 +17278,51 @@ Compared to other leading proprietary and open-weights models Command A delivers
|
|
|
17250
17278
|
output_mtok: 0.5
|
|
17251
17279
|
}
|
|
17252
17280
|
},
|
|
17281
|
+
{
|
|
17282
|
+
id: "grok-4-fast-non-reasoning",
|
|
17283
|
+
name: "Grok 4 Fast Non-Reasoning",
|
|
17284
|
+
description: "A frontier multimodal model optimized specifically for high-performance agentic tool calling.",
|
|
17285
|
+
match: {
|
|
17286
|
+
or: [
|
|
17287
|
+
{
|
|
17288
|
+
equals: "grok-4-fast-non-reasoning"
|
|
17289
|
+
},
|
|
17290
|
+
{
|
|
17291
|
+
equals: "grok-4-fast-non-reasoning-latest"
|
|
17292
|
+
}
|
|
17293
|
+
]
|
|
17294
|
+
},
|
|
17295
|
+
context_window: 2e6,
|
|
17296
|
+
prices: {
|
|
17297
|
+
input_mtok: 0.2,
|
|
17298
|
+
cache_read_mtok: 0.05,
|
|
17299
|
+
output_mtok: 0.5
|
|
17300
|
+
}
|
|
17301
|
+
},
|
|
17302
|
+
{
|
|
17303
|
+
id: "grok-4-fast-reasoning",
|
|
17304
|
+
name: "Grok 4 Fast Reasoning",
|
|
17305
|
+
description: "A frontier multimodal model optimized specifically for high-performance agentic tool calling.",
|
|
17306
|
+
match: {
|
|
17307
|
+
or: [
|
|
17308
|
+
{
|
|
17309
|
+
equals: "grok-4-fast"
|
|
17310
|
+
},
|
|
17311
|
+
{
|
|
17312
|
+
equals: "grok-4-fast-reasoning"
|
|
17313
|
+
},
|
|
17314
|
+
{
|
|
17315
|
+
equals: "grok-4-fast-reasoning-latest"
|
|
17316
|
+
}
|
|
17317
|
+
]
|
|
17318
|
+
},
|
|
17319
|
+
context_window: 2e6,
|
|
17320
|
+
prices: {
|
|
17321
|
+
input_mtok: 0.2,
|
|
17322
|
+
cache_read_mtok: 0.05,
|
|
17323
|
+
output_mtok: 0.5
|
|
17324
|
+
}
|
|
17325
|
+
},
|
|
17253
17326
|
{
|
|
17254
17327
|
id: "grok-code-fast-1",
|
|
17255
17328
|
name: "Grok Code Fast 1",
|
|
@@ -17277,18 +17350,18 @@ Compared to other leading proprietary and open-weights models Command A delivers
|
|
|
17277
17350
|
]
|
|
17278
17351
|
}
|
|
17279
17352
|
];
|
|
17280
|
-
function L(t, e,
|
|
17353
|
+
function L(t, e, i) {
|
|
17281
17354
|
if (e <= 0) return 0;
|
|
17282
|
-
let
|
|
17355
|
+
let a = t.base;
|
|
17283
17356
|
for (const o of t.tiers)
|
|
17284
|
-
|
|
17285
|
-
return
|
|
17357
|
+
i > o.start && (a = o.price);
|
|
17358
|
+
return a * e / 1e6;
|
|
17286
17359
|
}
|
|
17287
|
-
function
|
|
17288
|
-
return t === void 0 || e === void 0 ? 0 : typeof t == "number" ? t * e / 1e6 : L(t, e,
|
|
17360
|
+
function l(t, e, i, a) {
|
|
17361
|
+
return t === void 0 || e === void 0 ? 0 : typeof t == "number" ? t * e / 1e6 : L(t, e, a);
|
|
17289
17362
|
}
|
|
17290
17363
|
function Q(t, e) {
|
|
17291
|
-
let
|
|
17364
|
+
let i = 0, a = 0;
|
|
17292
17365
|
const o = t.input_tokens ?? 0, s = t.cache_read_tokens ?? 0, m = t.cache_write_tokens ?? 0, n = t.cache_audio_read_tokens ?? 0, r = t.output_audio_tokens ?? 0;
|
|
17293
17366
|
let u = t.input_audio_tokens ?? 0;
|
|
17294
17367
|
if (u -= n, u < 0)
|
|
@@ -17296,66 +17369,69 @@ function Q(t, e) {
|
|
|
17296
17369
|
let p = t.input_tokens ?? 0;
|
|
17297
17370
|
if (p -= s, p -= m, p -= u, p < 0)
|
|
17298
17371
|
throw new Error("Uncached text input tokens cannot be negative");
|
|
17299
|
-
let
|
|
17300
|
-
if (
|
|
17372
|
+
let c = s;
|
|
17373
|
+
if (c -= n, c < 0)
|
|
17301
17374
|
throw new Error("cache_audio_read_tokens cannot be greater than cache_read_tokens");
|
|
17302
|
-
|
|
17303
|
-
let
|
|
17304
|
-
if (
|
|
17375
|
+
i += l(e.input_mtok, p, "input_mtok", o), i += l(e.cache_read_mtok, c, "cache_read_mtok", o), i += l(e.cache_write_mtok, m, "cache_write_mtok", o), i += l(e.input_audio_mtok, u, "input_audio_mtok", o), i += l(e.cache_audio_read_mtok, n, "cache_audio_read_mtok", o);
|
|
17376
|
+
let _ = t.output_tokens ?? 0;
|
|
17377
|
+
if (_ -= r, _ < 0)
|
|
17305
17378
|
throw new Error("output_audio_tokens cannot be greater than output_tokens");
|
|
17306
|
-
|
|
17307
|
-
let
|
|
17308
|
-
return e.requests_kcount !== void 0 && (
|
|
17309
|
-
input_price:
|
|
17310
|
-
output_price:
|
|
17311
|
-
total_price:
|
|
17379
|
+
a += l(e.output_mtok, _, "output_mtok", o), a += l(e.output_audio_mtok, t.output_audio_tokens, "output_audio_mtok", o);
|
|
17380
|
+
let x = i + a;
|
|
17381
|
+
return e.requests_kcount !== void 0 && (x += e.requests_kcount / 1e3), {
|
|
17382
|
+
input_price: i,
|
|
17383
|
+
output_price: a,
|
|
17384
|
+
total_price: x
|
|
17312
17385
|
};
|
|
17313
17386
|
}
|
|
17314
17387
|
function T(t, e) {
|
|
17315
17388
|
if (!Array.isArray(t.prices))
|
|
17316
17389
|
return t.prices;
|
|
17317
|
-
for (let
|
|
17318
|
-
const
|
|
17390
|
+
for (let i = t.prices.length - 1; i >= 0; i--) {
|
|
17391
|
+
const a = t.prices[i], o = a.constraint;
|
|
17319
17392
|
if (o === void 0)
|
|
17320
|
-
return
|
|
17393
|
+
return a.prices;
|
|
17321
17394
|
if (o.type === "start_date") {
|
|
17322
17395
|
if (e >= new Date(o.start_date))
|
|
17323
|
-
return
|
|
17396
|
+
return a.prices;
|
|
17324
17397
|
} else {
|
|
17325
17398
|
const s = e.toISOString().slice(11, 19), m = o.start_time, n = o.end_time;
|
|
17326
17399
|
if (n < m) {
|
|
17327
17400
|
if (s >= m || s < n)
|
|
17328
|
-
return
|
|
17401
|
+
return a.prices;
|
|
17329
17402
|
} else if (s >= m && s < n)
|
|
17330
|
-
return
|
|
17403
|
+
return a.prices;
|
|
17331
17404
|
}
|
|
17332
17405
|
}
|
|
17333
17406
|
return t.prices[0].prices;
|
|
17334
17407
|
}
|
|
17335
|
-
function
|
|
17336
|
-
return "or" in t ? t.or.some((
|
|
17408
|
+
function g(t, e) {
|
|
17409
|
+
return "or" in t ? t.or.some((i) => g(i, e)) : "and" in t ? t.and.every((i) => g(i, e)) : "equals" in t ? e === t.equals : "starts_with" in t ? e.startsWith(t.starts_with) : "ends_with" in t ? e.endsWith(t.ends_with) : "contains" in t ? e.includes(t.contains) : "regex" in t ? new RegExp(t.regex).test(e) : !1;
|
|
17337
17410
|
}
|
|
17338
17411
|
function P(t, e) {
|
|
17339
|
-
const
|
|
17340
|
-
return
|
|
17412
|
+
const i = e.toLowerCase().trim(), a = t.find((o) => o.id === i);
|
|
17413
|
+
return a || t.find((o) => o.provider_match && g(o.provider_match, i));
|
|
17341
17414
|
}
|
|
17342
|
-
function
|
|
17415
|
+
function b(t, { modelId: e, providerApiUrl: i, providerId: a }) {
|
|
17416
|
+
if (a) {
|
|
17417
|
+
const o = P(t, a);
|
|
17418
|
+
if (o || a.toLowerCase() !== "litellm")
|
|
17419
|
+
return o;
|
|
17420
|
+
}
|
|
17343
17421
|
if (i)
|
|
17344
|
-
return
|
|
17345
|
-
if (a)
|
|
17346
|
-
return t.find((o) => new RegExp(o.api_pattern).test(a));
|
|
17422
|
+
return t.find((o) => new RegExp(o.api_pattern).test(i));
|
|
17347
17423
|
if (e)
|
|
17348
|
-
return t.find((o) => o.model_match &&
|
|
17424
|
+
return t.find((o) => o.model_match && g(o.model_match, e));
|
|
17349
17425
|
}
|
|
17350
17426
|
function S(t, e) {
|
|
17351
|
-
return t.find((
|
|
17427
|
+
return t.find((i) => g(i.match, e));
|
|
17352
17428
|
}
|
|
17353
|
-
function M(t, e,
|
|
17354
|
-
const
|
|
17355
|
-
if (
|
|
17356
|
-
if (t.fallback_model_providers &&
|
|
17429
|
+
function M(t, e, i) {
|
|
17430
|
+
const a = S(t.models, e);
|
|
17431
|
+
if (a) return a;
|
|
17432
|
+
if (t.fallback_model_providers && i)
|
|
17357
17433
|
for (const o of t.fallback_model_providers) {
|
|
17358
|
-
const s =
|
|
17434
|
+
const s = i.find((m) => m.id === o);
|
|
17359
17435
|
if (s) {
|
|
17360
17436
|
const m = M(s, e);
|
|
17361
17437
|
if (m) return m;
|
|
@@ -17363,14 +17439,14 @@ function M(t, e, a) {
|
|
|
17363
17439
|
}
|
|
17364
17440
|
}
|
|
17365
17441
|
const A = "https://raw.githubusercontent.com/pydantic/genai-prices/main/prices/data.json";
|
|
17366
|
-
let h =
|
|
17442
|
+
let h = I, f = Promise.resolve(I), v = null;
|
|
17367
17443
|
function G(t) {
|
|
17368
|
-
t !== null && ("then" in t ? (
|
|
17444
|
+
t !== null && ("then" in t ? (f = t, t.then((e) => {
|
|
17369
17445
|
e !== null && (h = e);
|
|
17370
|
-
})) : (
|
|
17446
|
+
})) : (f = Promise.resolve(t), h = t));
|
|
17371
17447
|
}
|
|
17372
17448
|
function R(t) {
|
|
17373
|
-
|
|
17449
|
+
v = t;
|
|
17374
17450
|
}
|
|
17375
17451
|
function N(t) {
|
|
17376
17452
|
t({
|
|
@@ -17380,38 +17456,43 @@ function N(t) {
|
|
|
17380
17456
|
});
|
|
17381
17457
|
}
|
|
17382
17458
|
function V() {
|
|
17383
|
-
return
|
|
17459
|
+
return f;
|
|
17384
17460
|
}
|
|
17385
|
-
function E(t, e,
|
|
17386
|
-
|
|
17387
|
-
|
|
17388
|
-
if (
|
|
17389
|
-
|
|
17461
|
+
function E(t, e, i) {
|
|
17462
|
+
v?.();
|
|
17463
|
+
let a = e.toLowerCase().trim(), o = i?.providerId;
|
|
17464
|
+
if (o && o.toLowerCase() === "litellm" && a.includes("/")) {
|
|
17465
|
+
const p = a.indexOf("/"), c = a.slice(0, p), _ = a.slice(p + 1);
|
|
17466
|
+
c && _ && b(h, { providerId: c }) && (o = c, a = _);
|
|
17467
|
+
}
|
|
17468
|
+
const s = i?.provider ?? b(h, { modelId: a, providerApiUrl: i?.providerApiUrl, providerId: o });
|
|
17390
17469
|
if (!s) return null;
|
|
17391
|
-
const m =
|
|
17470
|
+
const m = M(s, a, h);
|
|
17471
|
+
if (!m) return null;
|
|
17472
|
+
const n = i?.timestamp ?? /* @__PURE__ */ new Date(), r = T(m, n), u = Q(t, r);
|
|
17392
17473
|
return {
|
|
17393
17474
|
auto_update_timestamp: void 0,
|
|
17394
|
-
model:
|
|
17395
|
-
model_price:
|
|
17396
|
-
provider:
|
|
17397
|
-
...
|
|
17475
|
+
model: m,
|
|
17476
|
+
model_price: r,
|
|
17477
|
+
provider: s,
|
|
17478
|
+
...u
|
|
17398
17479
|
};
|
|
17399
17480
|
}
|
|
17400
17481
|
function O(t) {
|
|
17401
|
-
return
|
|
17482
|
+
return v?.(), b(h, t);
|
|
17402
17483
|
}
|
|
17403
|
-
function F(t, e,
|
|
17404
|
-
if (
|
|
17484
|
+
function F(t, e, i) {
|
|
17485
|
+
if (i = i ?? "default", !t.extractors)
|
|
17405
17486
|
throw new Error("No extraction logic defined for this provider");
|
|
17406
|
-
const
|
|
17407
|
-
if (!
|
|
17487
|
+
const a = t.extractors.find((r) => r.api_flavor === i);
|
|
17488
|
+
if (!a) {
|
|
17408
17489
|
const r = t.extractors.map((u) => u.api_flavor).join(", ");
|
|
17409
|
-
throw new Error(`Unknown apiFlavor '${
|
|
17490
|
+
throw new Error(`Unknown apiFlavor '${i}', allowed values: ${r}`);
|
|
17410
17491
|
}
|
|
17411
|
-
if (!
|
|
17412
|
-
throw new Error(`Expected response data to be a mapping object, got ${
|
|
17413
|
-
const o = w(
|
|
17414
|
-
for (const r of
|
|
17492
|
+
if (!q.guard(e))
|
|
17493
|
+
throw new Error(`Expected response data to be a mapping object, got ${d(e)}`);
|
|
17494
|
+
const o = w(a.model_path, e, C, !1, []), s = y(a.root), m = w(s, e, q, !0, []), n = {};
|
|
17495
|
+
for (const r of a.mappings) {
|
|
17415
17496
|
const u = w(r.path, m, z, r.required, s);
|
|
17416
17497
|
if (u !== null) {
|
|
17417
17498
|
const p = n[r.dest] ?? 0;
|
|
@@ -17419,13 +17500,13 @@ function F(t, e, a) {
|
|
|
17419
17500
|
}
|
|
17420
17501
|
}
|
|
17421
17502
|
if (!Object.keys(n).length)
|
|
17422
|
-
throw new Error(`No usage information found at ${JSON.stringify(
|
|
17503
|
+
throw new Error(`No usage information found at ${JSON.stringify(a.root)}`);
|
|
17423
17504
|
return { model: o, usage: n };
|
|
17424
17505
|
}
|
|
17425
|
-
function w(t, e,
|
|
17506
|
+
function w(t, e, i, a, o) {
|
|
17426
17507
|
const [s, ...m] = y(t).reverse();
|
|
17427
17508
|
if (typeof s != "string")
|
|
17428
|
-
throw new Error(`Expected last step of path to be a string, got ${
|
|
17509
|
+
throw new Error(`Expected last step of path to be a string, got ${d(s)}`);
|
|
17429
17510
|
m.reverse();
|
|
17430
17511
|
let n = e;
|
|
17431
17512
|
const r = [];
|
|
@@ -17434,57 +17515,57 @@ function w(t, e, a, i, o) {
|
|
|
17434
17515
|
if (Array.isArray(n))
|
|
17435
17516
|
n = D(p, n);
|
|
17436
17517
|
else {
|
|
17437
|
-
if (
|
|
17438
|
-
throw new Error(`Expected \`${
|
|
17518
|
+
if (a)
|
|
17519
|
+
throw new Error(`Expected \`${k(o, r)}\` value to be a mapping, got ${d(n)}`);
|
|
17439
17520
|
return null;
|
|
17440
17521
|
}
|
|
17441
|
-
else if (
|
|
17522
|
+
else if (q.guard(n))
|
|
17442
17523
|
n = n[p];
|
|
17443
17524
|
else {
|
|
17444
|
-
if (
|
|
17445
|
-
throw new Error(`Expected \`${
|
|
17525
|
+
if (a)
|
|
17526
|
+
throw new Error(`Expected \`${k(o, r)}\` value to be a mapping, got ${d(n)}`);
|
|
17446
17527
|
return null;
|
|
17447
17528
|
}
|
|
17448
17529
|
if (typeof n > "u")
|
|
17449
|
-
if (
|
|
17450
|
-
const
|
|
17451
|
-
throw new Error(`${
|
|
17530
|
+
if (a) {
|
|
17531
|
+
const c = typeof p == "object" ? "Unable to find item" : "Missing value";
|
|
17532
|
+
throw new Error(`${c} at \`${k(o, r)}\``);
|
|
17452
17533
|
} else
|
|
17453
17534
|
return null;
|
|
17454
17535
|
}
|
|
17455
|
-
if (!
|
|
17456
|
-
if (
|
|
17457
|
-
throw new Error(`Expected \`${
|
|
17536
|
+
if (!q.guard(n)) {
|
|
17537
|
+
if (a)
|
|
17538
|
+
throw new Error(`Expected \`${k(o, r)}\` value to be a mapping, got ${d(n)}`);
|
|
17458
17539
|
return null;
|
|
17459
17540
|
}
|
|
17460
17541
|
const u = n[s];
|
|
17461
17542
|
if (typeof u > "u") {
|
|
17462
|
-
if (
|
|
17463
|
-
throw r.push(s), new Error(`Missing value at \`${
|
|
17543
|
+
if (a)
|
|
17544
|
+
throw r.push(s), new Error(`Missing value at \`${k(o, r)}\``);
|
|
17464
17545
|
return null;
|
|
17465
17546
|
}
|
|
17466
|
-
if (
|
|
17547
|
+
if (i.guard(u))
|
|
17467
17548
|
return u;
|
|
17468
|
-
if (
|
|
17469
|
-
throw r.push(s), new Error(`Expected \`${
|
|
17549
|
+
if (a)
|
|
17550
|
+
throw r.push(s), new Error(`Expected \`${k(o, r)}\` value to be a ${i.name}, got ${d(u)}`);
|
|
17470
17551
|
return null;
|
|
17471
17552
|
}
|
|
17472
17553
|
function D(t, e) {
|
|
17473
|
-
for (const
|
|
17474
|
-
if (
|
|
17475
|
-
const
|
|
17476
|
-
if (typeof
|
|
17477
|
-
return
|
|
17554
|
+
for (const i of e)
|
|
17555
|
+
if (q.guard(i)) {
|
|
17556
|
+
const a = i[t.field];
|
|
17557
|
+
if (typeof a == "string" && g(t.match, a))
|
|
17558
|
+
return i;
|
|
17478
17559
|
}
|
|
17479
17560
|
}
|
|
17480
17561
|
function y(t) {
|
|
17481
17562
|
return Array.isArray(t) ? [...t] : [t];
|
|
17482
17563
|
}
|
|
17483
|
-
function
|
|
17564
|
+
function d(t) {
|
|
17484
17565
|
return t === null ? "null" : Array.isArray(t) ? "array" : typeof t == "object" ? "mapping" : typeof t;
|
|
17485
17566
|
}
|
|
17486
|
-
const
|
|
17487
|
-
guard: (t) =>
|
|
17567
|
+
const q = {
|
|
17568
|
+
guard: (t) => d(t) === "mapping",
|
|
17488
17569
|
name: "mapping"
|
|
17489
17570
|
}, C = {
|
|
17490
17571
|
guard: (t) => typeof t == "string",
|
|
@@ -17492,12 +17573,12 @@ const g = {
|
|
|
17492
17573
|
}, z = {
|
|
17493
17574
|
guard: (t) => typeof t == "number",
|
|
17494
17575
|
name: "number"
|
|
17495
|
-
},
|
|
17576
|
+
}, k = (t, e) => [...t.map(B), ...e.map(B)].join("."), B = (t) => typeof t == "string" ? t : JSON.stringify(t);
|
|
17496
17577
|
class j {
|
|
17497
17578
|
base;
|
|
17498
17579
|
tiers;
|
|
17499
17580
|
constructor(e) {
|
|
17500
|
-
this.base = e.base, this.tiers = [...e.tiers].sort((
|
|
17581
|
+
this.base = e.base, this.tiers = [...e.tiers].sort((i, a) => i.start - a.start);
|
|
17501
17582
|
}
|
|
17502
17583
|
}
|
|
17503
17584
|
export {
|