@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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- const B = [
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, a) {
17353
+ function L(t, e, i) {
17281
17354
  if (e <= 0) return 0;
17282
- let i = t.base;
17355
+ let a = t.base;
17283
17356
  for (const o of t.tiers)
17284
- a > o.start && (i = o.price);
17285
- return i * e / 1e6;
17357
+ i > o.start && (a = o.price);
17358
+ return a * e / 1e6;
17286
17359
  }
17287
- function c(t, e, a, i) {
17288
- return t === void 0 || e === void 0 ? 0 : typeof t == "number" ? t * e / 1e6 : L(t, e, i);
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 a = 0, i = 0;
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 k = s;
17300
- if (k -= n, k < 0)
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
- a += c(e.input_mtok, p, "input_mtok", o), a += c(e.cache_read_mtok, k, "cache_read_mtok", o), a += c(e.cache_write_mtok, m, "cache_write_mtok", o), a += c(e.input_audio_mtok, u, "input_audio_mtok", o), a += c(e.cache_audio_read_mtok, n, "cache_audio_read_mtok", o);
17303
- let q = t.output_tokens ?? 0;
17304
- if (q -= r, q < 0)
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
- i += c(e.output_mtok, q, "output_mtok", o), i += c(e.output_audio_mtok, t.output_audio_tokens, "output_audio_mtok", o);
17307
- let v = a + i;
17308
- return e.requests_kcount !== void 0 && (v += e.requests_kcount / 1e3), {
17309
- input_price: a,
17310
- output_price: i,
17311
- total_price: v
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 a = t.prices.length - 1; a >= 0; a--) {
17318
- const i = t.prices[a], o = i.constraint;
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 i.prices;
17393
+ return a.prices;
17321
17394
  if (o.type === "start_date") {
17322
17395
  if (e >= new Date(o.start_date))
17323
- return i.prices;
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 i.prices;
17401
+ return a.prices;
17329
17402
  } else if (s >= m && s < n)
17330
- return i.prices;
17403
+ return a.prices;
17331
17404
  }
17332
17405
  }
17333
17406
  return t.prices[0].prices;
17334
17407
  }
17335
- function _(t, e) {
17336
- return "or" in t ? t.or.some((a) => _(a, e)) : "and" in t ? t.and.every((a) => _(a, 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;
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 a = e.toLowerCase().trim(), i = t.find((o) => o.id === a);
17340
- return i || t.find((o) => o.provider_match && _(o.provider_match, a));
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 I(t, { modelId: e, providerApiUrl: a, providerId: i }) {
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 P(t, i);
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 && _(o.model_match, e));
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((a) => _(a.match, e));
17427
+ return t.find((i) => g(i.match, e));
17352
17428
  }
17353
- function M(t, e, a) {
17354
- const i = S(t.models, e);
17355
- if (i) return i;
17356
- if (t.fallback_model_providers && a)
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 = a.find((m) => m.id === o);
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 = B, b = Promise.resolve(B), f = null;
17442
+ let h = I, f = Promise.resolve(I), v = null;
17367
17443
  function G(t) {
17368
- t !== null && ("then" in t ? (b = t, t.then((e) => {
17444
+ t !== null && ("then" in t ? (f = t, t.then((e) => {
17369
17445
  e !== null && (h = e);
17370
- })) : (b = Promise.resolve(t), h = t));
17446
+ })) : (f = Promise.resolve(t), h = t));
17371
17447
  }
17372
17448
  function R(t) {
17373
- f = t;
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 b;
17459
+ return f;
17384
17460
  }
17385
- function E(t, e, a) {
17386
- f?.();
17387
- const i = e.toLowerCase().trim(), o = a?.provider ?? I(h, { modelId: i, providerApiUrl: a?.providerApiUrl, providerId: a?.providerId });
17388
- if (!o) return null;
17389
- const s = M(o, i, h);
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 = a?.timestamp ?? /* @__PURE__ */ new Date(), n = T(s, m), r = Q(t, n);
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: s,
17395
- model_price: n,
17396
- provider: o,
17397
- ...r
17475
+ model: m,
17476
+ model_price: r,
17477
+ provider: s,
17478
+ ...u
17398
17479
  };
17399
17480
  }
17400
17481
  function O(t) {
17401
- return f?.(), I(h, t);
17482
+ return v?.(), b(h, t);
17402
17483
  }
17403
- function F(t, e, a) {
17404
- if (a = a ?? "default", !t.extractors)
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 i = t.extractors.find((r) => r.api_flavor === a);
17407
- if (!i) {
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 '${a}', allowed values: ${r}`);
17490
+ throw new Error(`Unknown apiFlavor '${i}', allowed values: ${r}`);
17410
17491
  }
17411
- if (!g.guard(e))
17412
- throw new Error(`Expected response data to be a mapping object, got ${l(e)}`);
17413
- const o = w(i.model_path, e, C, !1, []), s = y(i.root), m = w(s, e, g, !0, []), n = {};
17414
- for (const r of i.mappings) {
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(i.root)}`);
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, a, i, o) {
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 ${l(s)}`);
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 (i)
17438
- throw new Error(`Expected \`${d(o, r)}\` value to be a mapping, got ${l(n)}`);
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 (g.guard(n))
17522
+ else if (q.guard(n))
17442
17523
  n = n[p];
17443
17524
  else {
17444
- if (i)
17445
- throw new Error(`Expected \`${d(o, r)}\` value to be a mapping, got ${l(n)}`);
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 (i) {
17450
- const k = typeof p == "object" ? "Unable to find item" : "Missing value";
17451
- throw new Error(`${k} at \`${d(o, r)}\``);
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 (!g.guard(n)) {
17456
- if (i)
17457
- throw new Error(`Expected \`${d(o, r)}\` value to be a mapping, got ${l(n)}`);
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 (i)
17463
- throw r.push(s), new Error(`Missing value at \`${d(o, r)}\``);
17543
+ if (a)
17544
+ throw r.push(s), new Error(`Missing value at \`${k(o, r)}\``);
17464
17545
  return null;
17465
17546
  }
17466
- if (a.guard(u))
17547
+ if (i.guard(u))
17467
17548
  return u;
17468
- if (i)
17469
- throw r.push(s), new Error(`Expected \`${d(o, r)}\` value to be a ${a.name}, got ${l(u)}`);
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 a of e)
17474
- if (g.guard(a)) {
17475
- const i = a[t.field];
17476
- if (typeof i == "string" && _(t.match, i))
17477
- return a;
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 l(t) {
17564
+ function d(t) {
17484
17565
  return t === null ? "null" : Array.isArray(t) ? "array" : typeof t == "object" ? "mapping" : typeof t;
17485
17566
  }
17486
- const g = {
17487
- guard: (t) => l(t) === "mapping",
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
- }, d = (t, e) => [...t.map(x), ...e.map(x)].join("."), x = (t) => typeof t == "string" ? t : JSON.stringify(t);
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((a, i) => a.start - i.start);
17581
+ this.base = e.base, this.tiers = [...e.tiers].sort((i, a) => i.start - a.start);
17501
17582
  }
17502
17583
  }
17503
17584
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pydantic/genai-prices",
3
- "version": "0.0.51",
3
+ "version": "0.0.52",
4
4
  "description": "Calculate prices for calling LLM inference APIs",
5
5
  "author": "Pydantic Team",
6
6
  "type": "module",