@pydantic/genai-prices 0.0.35 → 0.0.36
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 +172 -96
- package/dist/index.cjs +2 -2
- package/dist/index.js +155 -68
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const x = [
|
|
2
2
|
{
|
|
3
3
|
id: "anthropic",
|
|
4
4
|
name: "Anthropic",
|
|
@@ -5503,7 +5503,14 @@ Compared to other leading proprietary and open-weights models Command A delivers
|
|
|
5503
5503
|
id: "gemini-2.5-flash",
|
|
5504
5504
|
name: "Gemini 2.5 Flash",
|
|
5505
5505
|
match: {
|
|
5506
|
-
|
|
5506
|
+
or: [
|
|
5507
|
+
{
|
|
5508
|
+
equals: "gemini-2.5-flash"
|
|
5509
|
+
},
|
|
5510
|
+
{
|
|
5511
|
+
equals: "google/gemini-2.5-flash"
|
|
5512
|
+
}
|
|
5513
|
+
]
|
|
5507
5514
|
},
|
|
5508
5515
|
prices: {
|
|
5509
5516
|
input_mtok: 0.3,
|
|
@@ -5842,6 +5849,48 @@ Compared to other leading proprietary and open-weights models Command A delivers
|
|
|
5842
5849
|
},
|
|
5843
5850
|
prices: {}
|
|
5844
5851
|
},
|
|
5852
|
+
{
|
|
5853
|
+
id: "google/gemini-2.5-flash-image",
|
|
5854
|
+
name: "Gemini 2.5 Flash Image (Nano Banana)",
|
|
5855
|
+
match: {
|
|
5856
|
+
or: [
|
|
5857
|
+
{
|
|
5858
|
+
equals: "google/gemini-2.5-flash-image"
|
|
5859
|
+
},
|
|
5860
|
+
{
|
|
5861
|
+
equals: "google/gemini-2.5-flash-image-preview"
|
|
5862
|
+
}
|
|
5863
|
+
]
|
|
5864
|
+
},
|
|
5865
|
+
prices: {
|
|
5866
|
+
input_mtok: 0.3,
|
|
5867
|
+
output_mtok: 2.5
|
|
5868
|
+
}
|
|
5869
|
+
},
|
|
5870
|
+
{
|
|
5871
|
+
id: "google/gemini-2.5-flash-lite",
|
|
5872
|
+
name: "Gemini 2.5 Flash Lite",
|
|
5873
|
+
match: {
|
|
5874
|
+
equals: "google/gemini-2.5-flash-lite"
|
|
5875
|
+
},
|
|
5876
|
+
prices: {
|
|
5877
|
+
input_mtok: 0.1,
|
|
5878
|
+
cache_write_mtok: 0.183,
|
|
5879
|
+
cache_read_mtok: 0.025,
|
|
5880
|
+
output_mtok: 0.4
|
|
5881
|
+
}
|
|
5882
|
+
},
|
|
5883
|
+
{
|
|
5884
|
+
id: "google/gemini-2.5-flash-lite-preview-09-2025",
|
|
5885
|
+
name: "Gemini 2.5 Flash Lite Preview 09-2025",
|
|
5886
|
+
match: {
|
|
5887
|
+
equals: "google/gemini-2.5-flash-lite-preview-09-2025"
|
|
5888
|
+
},
|
|
5889
|
+
prices: {
|
|
5890
|
+
input_mtok: 0.1,
|
|
5891
|
+
output_mtok: 0.4
|
|
5892
|
+
}
|
|
5893
|
+
},
|
|
5845
5894
|
{
|
|
5846
5895
|
id: "google/gemini-2.5-flash-preview",
|
|
5847
5896
|
match: {
|
|
@@ -5852,6 +5901,19 @@ Compared to other leading proprietary and open-weights models Command A delivers
|
|
|
5852
5901
|
output_mtok: 0.6
|
|
5853
5902
|
}
|
|
5854
5903
|
},
|
|
5904
|
+
{
|
|
5905
|
+
id: "google/gemini-2.5-flash-preview-09-2025",
|
|
5906
|
+
name: "Gemini 2.5 Flash Preview 09-2025",
|
|
5907
|
+
match: {
|
|
5908
|
+
equals: "google/gemini-2.5-flash-preview-09-2025"
|
|
5909
|
+
},
|
|
5910
|
+
prices: {
|
|
5911
|
+
input_mtok: 0.3,
|
|
5912
|
+
cache_write_mtok: 0.383,
|
|
5913
|
+
cache_read_mtok: 0.075,
|
|
5914
|
+
output_mtok: 2.5
|
|
5915
|
+
}
|
|
5916
|
+
},
|
|
5855
5917
|
{
|
|
5856
5918
|
id: "google/gemini-2.5-flash-preview:thinking",
|
|
5857
5919
|
match: {
|
|
@@ -11070,7 +11132,7 @@ Compared to other leading proprietary and open-weights models Command A delivers
|
|
|
11070
11132
|
]
|
|
11071
11133
|
}
|
|
11072
11134
|
];
|
|
11073
|
-
function
|
|
11135
|
+
function M(t, e) {
|
|
11074
11136
|
if (e <= 0) return 0;
|
|
11075
11137
|
let a = 0;
|
|
11076
11138
|
const i = [...t.tiers].sort((r, s) => r.start - s.start), o = i[0]?.start ?? e, m = Math.min(e, o);
|
|
@@ -11081,20 +11143,34 @@ function y(t, e) {
|
|
|
11081
11143
|
}
|
|
11082
11144
|
return a;
|
|
11083
11145
|
}
|
|
11084
|
-
function
|
|
11085
|
-
return t === void 0 || e === void 0 ? 0 : typeof t == "number" ? t * e / 1e6 :
|
|
11146
|
+
function p(t, e, a) {
|
|
11147
|
+
return t === void 0 || e === void 0 ? 0 : typeof t == "number" ? t * e / 1e6 : M(t, e);
|
|
11086
11148
|
}
|
|
11087
|
-
function
|
|
11149
|
+
function I(t, e) {
|
|
11088
11150
|
let a = 0, i = 0;
|
|
11089
|
-
|
|
11090
|
-
|
|
11091
|
-
|
|
11151
|
+
const o = t.cache_read_tokens ?? 0, m = t.cache_write_tokens ?? 0, r = t.cache_audio_read_tokens ?? 0, s = t.output_audio_tokens ?? 0;
|
|
11152
|
+
let n = t.input_audio_tokens ?? 0;
|
|
11153
|
+
if (n -= r, n < 0)
|
|
11154
|
+
throw new Error("cache_audio_read_tokens cannot be greater than input_audio_tokens");
|
|
11155
|
+
let u = t.input_tokens ?? 0;
|
|
11156
|
+
if (u -= o, u -= m, u -= n, u < 0)
|
|
11157
|
+
throw new Error("Uncached text input tokens cannot be negative");
|
|
11158
|
+
let l = o;
|
|
11159
|
+
if (l -= r, l < 0)
|
|
11160
|
+
throw new Error("cache_audio_read_tokens cannot be greater than cache_read_tokens");
|
|
11161
|
+
a += p(e.input_mtok, u), a += p(e.cache_read_mtok, l), a += p(e.cache_write_mtok, m), a += p(e.input_audio_mtok, n), a += p(e.cache_audio_read_mtok, r);
|
|
11162
|
+
let k = t.output_tokens ?? 0;
|
|
11163
|
+
if (k -= s, k < 0)
|
|
11164
|
+
throw new Error("output_audio_tokens cannot be greater than output_tokens");
|
|
11165
|
+
i += p(e.output_mtok, k), i += p(e.output_audio_mtok, t.output_audio_tokens);
|
|
11166
|
+
let w = a + i;
|
|
11167
|
+
return e.requests_kcount !== void 0 && (w += e.requests_kcount / 1e3), {
|
|
11092
11168
|
input_price: a,
|
|
11093
11169
|
output_price: i,
|
|
11094
|
-
total_price:
|
|
11170
|
+
total_price: w
|
|
11095
11171
|
};
|
|
11096
11172
|
}
|
|
11097
|
-
function
|
|
11173
|
+
function P(t, e) {
|
|
11098
11174
|
if (!Array.isArray(t.prices))
|
|
11099
11175
|
return t.prices;
|
|
11100
11176
|
for (let a = t.prices.length - 1; a >= 0; a--) {
|
|
@@ -11118,48 +11194,48 @@ function I(t, e) {
|
|
|
11118
11194
|
function h(t, e) {
|
|
11119
11195
|
return "or" in t ? t.or.some((a) => h(a, e)) : "and" in t ? t.and.every((a) => h(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;
|
|
11120
11196
|
}
|
|
11121
|
-
function
|
|
11197
|
+
function L(t, e) {
|
|
11122
11198
|
const a = e.toLowerCase().trim(), i = t.find((o) => o.id === a);
|
|
11123
11199
|
return i || t.find((o) => o.provider_match && h(o.provider_match, a));
|
|
11124
11200
|
}
|
|
11125
|
-
function
|
|
11201
|
+
function B(t, { modelId: e, providerApiUrl: a, providerId: i }) {
|
|
11126
11202
|
if (i)
|
|
11127
|
-
return
|
|
11203
|
+
return L(t, i);
|
|
11128
11204
|
if (a)
|
|
11129
11205
|
return t.find((o) => new RegExp(o.api_pattern).test(a));
|
|
11130
11206
|
if (e)
|
|
11131
11207
|
return t.find((o) => o.model_match && h(o.model_match, e));
|
|
11132
11208
|
}
|
|
11133
|
-
function
|
|
11209
|
+
function T(t, e) {
|
|
11134
11210
|
return t.find((a) => h(a.match, e));
|
|
11135
11211
|
}
|
|
11136
|
-
const
|
|
11137
|
-
let
|
|
11138
|
-
function G(t) {
|
|
11139
|
-
"then" in t ? (q = t, t.then((e) => {
|
|
11140
|
-
_ = e;
|
|
11141
|
-
})) : (q = Promise.resolve(t), _ = t);
|
|
11142
|
-
}
|
|
11212
|
+
const G = "https://raw.githubusercontent.com/pydantic/genai-prices/main/prices/data.json";
|
|
11213
|
+
let g = x, b = Promise.resolve(x), f = null;
|
|
11143
11214
|
function S(t) {
|
|
11144
|
-
b = t
|
|
11215
|
+
"then" in t ? (b = t, t.then((e) => {
|
|
11216
|
+
g = e;
|
|
11217
|
+
})) : (b = Promise.resolve(t), g = t);
|
|
11145
11218
|
}
|
|
11146
|
-
function
|
|
11219
|
+
function A(t) {
|
|
11220
|
+
f = t;
|
|
11221
|
+
}
|
|
11222
|
+
function N(t) {
|
|
11147
11223
|
t({
|
|
11148
|
-
onCalc:
|
|
11149
|
-
remoteDataUrl:
|
|
11150
|
-
setProviderData:
|
|
11224
|
+
onCalc: A,
|
|
11225
|
+
remoteDataUrl: G,
|
|
11226
|
+
setProviderData: S
|
|
11151
11227
|
});
|
|
11152
11228
|
}
|
|
11153
11229
|
function Q() {
|
|
11154
|
-
return
|
|
11230
|
+
return b;
|
|
11155
11231
|
}
|
|
11156
|
-
function
|
|
11157
|
-
|
|
11158
|
-
const i = e.toLowerCase().trim(), o = a?.provider ??
|
|
11232
|
+
function E(t, e, a) {
|
|
11233
|
+
f?.();
|
|
11234
|
+
const i = e.toLowerCase().trim(), o = a?.provider ?? B(g, { modelId: i, providerApiUrl: a?.providerApiUrl, providerId: a?.providerId });
|
|
11159
11235
|
if (!o) return null;
|
|
11160
|
-
const m =
|
|
11236
|
+
const m = T(o.models, i);
|
|
11161
11237
|
if (!m) return null;
|
|
11162
|
-
const r = a?.timestamp ?? /* @__PURE__ */ new Date(), s =
|
|
11238
|
+
const r = a?.timestamp ?? /* @__PURE__ */ new Date(), s = P(m, r), n = I(t, s);
|
|
11163
11239
|
return {
|
|
11164
11240
|
auto_update_timestamp: void 0,
|
|
11165
11241
|
model: m,
|
|
@@ -11168,10 +11244,10 @@ function N(t, e, a) {
|
|
|
11168
11244
|
...n
|
|
11169
11245
|
};
|
|
11170
11246
|
}
|
|
11171
|
-
function
|
|
11172
|
-
return
|
|
11247
|
+
function O(t) {
|
|
11248
|
+
return f?.(), B(g, t);
|
|
11173
11249
|
}
|
|
11174
|
-
function
|
|
11250
|
+
function D(t, e, a) {
|
|
11175
11251
|
if (a = a ?? "default", !t.extractors)
|
|
11176
11252
|
throw new Error("No extraction logic defined for this provider");
|
|
11177
11253
|
const i = t.extractors.find((n) => n.api_flavor === a);
|
|
@@ -11179,46 +11255,55 @@ function O(t, e, a) {
|
|
|
11179
11255
|
const n = t.extractors.map((u) => u.api_flavor).join(", ");
|
|
11180
11256
|
throw new Error(`Unknown apiFlavor '${a}', allowed values: ${n}`);
|
|
11181
11257
|
}
|
|
11182
|
-
if (!
|
|
11258
|
+
if (!_.guard(e))
|
|
11183
11259
|
throw new Error(`Expected response data to be a mapping object, got ${c(e)}`);
|
|
11184
|
-
const o =
|
|
11260
|
+
const o = q(i.model_path, e, C, !1, []), m = y(i.root), r = q(m, e, _, !0, []), s = {};
|
|
11185
11261
|
for (const n of i.mappings) {
|
|
11186
|
-
const u =
|
|
11262
|
+
const u = q(n.path, r, z, n.required, m);
|
|
11187
11263
|
if (u !== null) {
|
|
11188
|
-
const
|
|
11189
|
-
s[n.dest] =
|
|
11264
|
+
const l = s[n.dest] ?? 0;
|
|
11265
|
+
s[n.dest] = l + u;
|
|
11190
11266
|
}
|
|
11191
11267
|
}
|
|
11192
11268
|
if (!Object.keys(s).length)
|
|
11193
11269
|
throw new Error(`No usage information found at ${JSON.stringify(i.root)}`);
|
|
11194
11270
|
return { model: o, usage: s };
|
|
11195
11271
|
}
|
|
11196
|
-
function
|
|
11197
|
-
const [m, ...r] =
|
|
11272
|
+
function q(t, e, a, i, o) {
|
|
11273
|
+
const [m, ...r] = y(t).reverse();
|
|
11198
11274
|
if (typeof m != "string")
|
|
11199
11275
|
throw new Error(`Expected last step of path to be a string, got ${c(m)}`);
|
|
11200
11276
|
r.reverse();
|
|
11201
11277
|
let s = e;
|
|
11202
11278
|
const n = [];
|
|
11203
|
-
for (const
|
|
11204
|
-
if (n.push(
|
|
11279
|
+
for (const l of r) {
|
|
11280
|
+
if (n.push(l), typeof l == "object")
|
|
11205
11281
|
if (Array.isArray(s))
|
|
11206
|
-
s =
|
|
11207
|
-
else
|
|
11282
|
+
s = R(l, s);
|
|
11283
|
+
else {
|
|
11284
|
+
if (i)
|
|
11285
|
+
throw new Error(`Expected \`${d(o, n)}\` value to be a mapping, got ${c(s)}`);
|
|
11286
|
+
return null;
|
|
11287
|
+
}
|
|
11288
|
+
else if (_.guard(s))
|
|
11289
|
+
s = s[l];
|
|
11290
|
+
else {
|
|
11291
|
+
if (i)
|
|
11208
11292
|
throw new Error(`Expected \`${d(o, n)}\` value to be a mapping, got ${c(s)}`);
|
|
11209
|
-
|
|
11210
|
-
|
|
11211
|
-
else
|
|
11212
|
-
throw new Error(`Expected \`${d(o, n)}\` value to be a mapping, got ${c(s)}`);
|
|
11293
|
+
return null;
|
|
11294
|
+
}
|
|
11213
11295
|
if (typeof s > "u")
|
|
11214
11296
|
if (i) {
|
|
11215
|
-
const
|
|
11216
|
-
throw new Error(`${
|
|
11297
|
+
const k = typeof l == "object" ? "Unable to find item" : "Missing value";
|
|
11298
|
+
throw new Error(`${k} at \`${d(o, n)}\``);
|
|
11217
11299
|
} else
|
|
11218
11300
|
return null;
|
|
11219
11301
|
}
|
|
11220
|
-
if (!
|
|
11221
|
-
|
|
11302
|
+
if (!_.guard(s)) {
|
|
11303
|
+
if (i)
|
|
11304
|
+
throw new Error(`Expected \`${d(o, n)}\` value to be a mapping, got ${c(s)}`);
|
|
11305
|
+
return null;
|
|
11306
|
+
}
|
|
11222
11307
|
const u = s[m];
|
|
11223
11308
|
if (typeof u > "u") {
|
|
11224
11309
|
if (i)
|
|
@@ -11227,37 +11312,39 @@ function g(t, e, a, i, o) {
|
|
|
11227
11312
|
}
|
|
11228
11313
|
if (a.guard(u))
|
|
11229
11314
|
return u;
|
|
11230
|
-
|
|
11315
|
+
if (i)
|
|
11316
|
+
throw n.push(m), new Error(`Expected \`${d(o, n)}\` value to be a ${a.name}, got ${c(u)}`);
|
|
11317
|
+
return null;
|
|
11231
11318
|
}
|
|
11232
|
-
function
|
|
11319
|
+
function R(t, e) {
|
|
11233
11320
|
for (const a of e)
|
|
11234
|
-
if (
|
|
11321
|
+
if (_.guard(a)) {
|
|
11235
11322
|
const i = a[t.field];
|
|
11236
11323
|
if (typeof i == "string" && h(t.match, i))
|
|
11237
11324
|
return a;
|
|
11238
11325
|
}
|
|
11239
11326
|
}
|
|
11240
|
-
function
|
|
11327
|
+
function y(t) {
|
|
11241
11328
|
return Array.isArray(t) ? [...t] : [t];
|
|
11242
11329
|
}
|
|
11243
11330
|
function c(t) {
|
|
11244
11331
|
return t === null ? "null" : Array.isArray(t) ? "array" : typeof t == "object" ? "mapping" : typeof t;
|
|
11245
11332
|
}
|
|
11246
|
-
const
|
|
11333
|
+
const _ = {
|
|
11247
11334
|
guard: (t) => c(t) === "mapping",
|
|
11248
11335
|
name: "mapping"
|
|
11249
|
-
},
|
|
11336
|
+
}, C = {
|
|
11250
11337
|
guard: (t) => typeof t == "string",
|
|
11251
11338
|
name: "string"
|
|
11252
|
-
},
|
|
11339
|
+
}, z = {
|
|
11253
11340
|
guard: (t) => typeof t == "number",
|
|
11254
11341
|
name: "number"
|
|
11255
|
-
}, d = (t, e) => [...t.map(
|
|
11342
|
+
}, d = (t, e) => [...t.map(v), ...e.map(v)].join("."), v = (t) => typeof t == "string" ? t : JSON.stringify(t);
|
|
11256
11343
|
export {
|
|
11257
|
-
|
|
11258
|
-
|
|
11259
|
-
|
|
11260
|
-
|
|
11261
|
-
|
|
11344
|
+
G as REMOTE_DATA_JSON_URL,
|
|
11345
|
+
E as calcPrice,
|
|
11346
|
+
D as extractUsage,
|
|
11347
|
+
O as findProvider,
|
|
11348
|
+
N as updatePrices,
|
|
11262
11349
|
Q as waitForUpdate
|
|
11263
11350
|
};
|