@eidentic/model 0.1.0

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 ADDED
@@ -0,0 +1,1143 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
8
+ // src/model.ts
9
+ import { generateText, streamText, jsonSchema as jsonSchema2, Output } from "ai";
10
+
11
+ // src/map.ts
12
+ import { tool, jsonSchema } from "ai";
13
+ import { decodeMultimodalInput } from "@eidentic/types";
14
+ var ANTHROPIC_CACHE_BREAKPOINT = {
15
+ anthropic: { cacheControl: { type: "ephemeral" } }
16
+ };
17
+ function mapMessages(msgs, opts) {
18
+ const systemParts = [];
19
+ const messages = [];
20
+ for (const m of msgs) {
21
+ if (m.role === "system") {
22
+ systemParts.push(typeof m.content === "string" ? m.content : textOf(m.content));
23
+ continue;
24
+ }
25
+ if (m.role === "user") {
26
+ const userBlocks = typeof m.content === "string" ? decodeMultimodalInput(m.content) : m.content;
27
+ if (userBlocks !== null) {
28
+ const hasImages = userBlocks.some((b) => b.type === "image");
29
+ if (hasImages) {
30
+ const parts = userBlocks.flatMap((b) => {
31
+ if (b.type === "text") return [{ type: "text", text: b.text }];
32
+ if (b.type === "image") {
33
+ const img = b.image;
34
+ const source = img.url ? new URL(img.url) : img.data;
35
+ if (source === void 0) return [];
36
+ const imagePart = {
37
+ type: "image",
38
+ image: source,
39
+ ...img.mediaType ? { mediaType: img.mediaType } : {}
40
+ };
41
+ return [imagePart];
42
+ }
43
+ return [];
44
+ });
45
+ if (parts.length > 0) messages.push({ role: "user", content: parts });
46
+ } else {
47
+ messages.push({ role: "user", content: textOf(userBlocks) });
48
+ }
49
+ } else {
50
+ messages.push({ role: "user", content: m.content });
51
+ }
52
+ continue;
53
+ }
54
+ if (m.role === "assistant") {
55
+ const parts = typeof m.content === "string" ? [{ type: "text", text: m.content }] : m.content.flatMap(
56
+ (b) => b.type === "text" ? [{ type: "text", text: b.text }] : b.type === "tool_use" ? [{ type: "tool-call", toolCallId: b.callId, toolName: b.name, input: b.input }] : []
57
+ );
58
+ if (parts.length > 0) messages.push({ role: "assistant", content: parts });
59
+ continue;
60
+ }
61
+ messages.push({
62
+ role: "tool",
63
+ content: [
64
+ {
65
+ type: "tool-result",
66
+ toolCallId: m.callId ?? "",
67
+ toolName: m.toolName ?? "",
68
+ output: { type: "text", value: typeof m.content === "string" ? m.content : textOf(m.content) }
69
+ }
70
+ ]
71
+ });
72
+ }
73
+ if (!systemParts.length) return { messages };
74
+ const systemText = systemParts.join("\n\n");
75
+ if (opts?.cacheControl) {
76
+ return {
77
+ system: { role: "system", content: systemText, providerOptions: ANTHROPIC_CACHE_BREAKPOINT },
78
+ messages
79
+ };
80
+ }
81
+ return { system: systemText, messages };
82
+ }
83
+ function textOf(content) {
84
+ return content.filter((b) => b.type === "text").map((b) => b.text).join("");
85
+ }
86
+ function buildTools(schemas) {
87
+ return Object.fromEntries(
88
+ schemas.map((s) => [
89
+ s.name,
90
+ tool({ description: s.description, inputSchema: jsonSchema(s.inputSchema) })
91
+ ])
92
+ );
93
+ }
94
+ function readStructuredOutput(result) {
95
+ try {
96
+ return result.experimental_output;
97
+ } catch {
98
+ return void 0;
99
+ }
100
+ }
101
+ function mapResult(result, opts) {
102
+ const content = [];
103
+ if (result.text) content.push({ type: "text", text: result.text });
104
+ for (const tc of result.toolCalls) {
105
+ content.push({ type: "tool_use", callId: tc.toolCallId, name: tc.toolName, input: tc.input });
106
+ }
107
+ const cached = result.usage.cachedInputTokens;
108
+ const object = opts?.structured && result.toolCalls.length === 0 ? readStructuredOutput(result) : void 0;
109
+ return {
110
+ content,
111
+ usage: {
112
+ inputTokens: result.usage.inputTokens ?? 0,
113
+ outputTokens: result.usage.outputTokens ?? 0,
114
+ ...cached !== void 0 && cached > 0 ? { cachedInputTokens: cached } : {}
115
+ },
116
+ ...object !== void 0 ? { object } : {}
117
+ };
118
+ }
119
+
120
+ // src/model.ts
121
+ var toolsArg = (t) => Object.keys(t).length > 0 ? t : void 0;
122
+ var outputArg = (schema) => schema !== void 0 ? Output.object({ schema: jsonSchema2(schema) }) : void 0;
123
+ var AIModel = class {
124
+ resolve;
125
+ settings;
126
+ /** The model's own identifier, sourced from the AI SDK LanguageModel when a static model is passed. */
127
+ modelId;
128
+ constructor(model, options = {}) {
129
+ if (typeof model === "function") {
130
+ this.resolve = model;
131
+ this.modelId = void 0;
132
+ } else {
133
+ this.resolve = () => model;
134
+ this.modelId = model.modelId;
135
+ }
136
+ this.settings = options;
137
+ }
138
+ async complete(request) {
139
+ const model = await this.resolve(request.model);
140
+ const { system, messages } = mapMessages(request.messages, { cacheControl: request.cacheControl });
141
+ const tools = buildTools(request.tools);
142
+ const output = outputArg(request.outputSchema);
143
+ const result = await generateText({
144
+ model,
145
+ system,
146
+ messages,
147
+ tools: toolsArg(tools),
148
+ ...this.settings,
149
+ // no `stopWhen` and no tool `execute` → single round-trip; tool calls returned to our loop
150
+ ...output ? { experimental_output: output } : {},
151
+ ...request.signal ? { abortSignal: request.signal } : {}
152
+ });
153
+ return mapResult(result, { structured: output !== void 0 });
154
+ }
155
+ async *stream(request) {
156
+ const model = await this.resolve(request.model);
157
+ const { system, messages } = mapMessages(request.messages, { cacheControl: request.cacheControl });
158
+ const tools = buildTools(request.tools);
159
+ const output = outputArg(request.outputSchema);
160
+ const result = streamText({
161
+ model,
162
+ system,
163
+ messages,
164
+ tools: toolsArg(tools),
165
+ ...this.settings,
166
+ ...output ? { experimental_output: output } : {},
167
+ ...request.signal ? { abortSignal: request.signal } : {}
168
+ });
169
+ const toolUses = [];
170
+ for await (const part of result.fullStream) {
171
+ if (part.type === "text-delta") {
172
+ yield { type: "delta", delta: { text: part.text } };
173
+ } else if (part.type === "tool-call") {
174
+ toolUses.push({ type: "tool_use", callId: part.toolCallId, name: part.toolName, input: part.input });
175
+ } else if (part.type === "error") {
176
+ throw part.error instanceof Error ? part.error : new Error(`model stream error: ${String(part.error)}`);
177
+ }
178
+ }
179
+ if (request.signal?.aborted) {
180
+ throw new DOMException("stream aborted", "AbortError");
181
+ }
182
+ const text = await result.text;
183
+ const usage = await result.usage;
184
+ const content = [];
185
+ if (text) content.push({ type: "text", text });
186
+ content.push(...toolUses);
187
+ const cached = usage.cachedInputTokens;
188
+ let object;
189
+ if (output && toolUses.length === 0 && text) {
190
+ try {
191
+ object = JSON.parse(text);
192
+ } catch {
193
+ object = void 0;
194
+ }
195
+ }
196
+ yield {
197
+ type: "final",
198
+ response: {
199
+ content,
200
+ usage: {
201
+ inputTokens: usage.inputTokens ?? 0,
202
+ outputTokens: usage.outputTokens ?? 0,
203
+ ...cached !== void 0 && cached > 0 ? { cachedInputTokens: cached } : {}
204
+ },
205
+ ...object !== void 0 ? { object } : {}
206
+ }
207
+ };
208
+ }
209
+ };
210
+
211
+ // src/embedder.ts
212
+ import { embed, embedMany } from "ai";
213
+ var AIEmbedder = class _AIEmbedder {
214
+ constructor(model, dim) {
215
+ this.model = model;
216
+ this.dim = dim;
217
+ }
218
+ model;
219
+ dim;
220
+ /** Construct an embedder, probing the model once to discover its output dimension. */
221
+ static async create(model) {
222
+ const { embedding } = await embed({ model, value: "x" });
223
+ return new _AIEmbedder(model, embedding.length);
224
+ }
225
+ async embed(text) {
226
+ const { embedding } = await embed({ model: this.model, value: text });
227
+ return embedding;
228
+ }
229
+ /**
230
+ * Batch embedding via AI SDK v6 `embedMany({ model, values })` → `{ embeddings: number[][] }`.
231
+ * Embeds all texts in a single provider call (fewer round-trips on the ingest hot path).
232
+ * Each returned vector is validated to have length === `this.dim`.
233
+ */
234
+ async embedBatch(texts) {
235
+ if (texts.length === 0) return [];
236
+ const { embeddings } = await embedMany({ model: this.model, values: texts });
237
+ for (let i = 0; i < embeddings.length; i++) {
238
+ if (embeddings[i].length !== this.dim) {
239
+ throw new Error(`embedBatch: embedding[${i}] has length ${embeddings[i].length}, expected ${this.dim}`);
240
+ }
241
+ }
242
+ return embeddings;
243
+ }
244
+ };
245
+
246
+ // src/prices.ts
247
+ var pricesUpdatedAt = "2026-06-08T00:00:00.000Z";
248
+ var defaultPrices = {
249
+ "chatgpt-4o-latest": { inputPerMTok: 5, outputPerMTok: 15 },
250
+ "claude-3-5-haiku": { inputPerMTok: 1, outputPerMTok: 5 },
251
+ "claude-3-5-haiku@20241022": { inputPerMTok: 1, outputPerMTok: 5 },
252
+ "claude-3-5-sonnet": { inputPerMTok: 3, outputPerMTok: 15 },
253
+ "claude-3-5-sonnet@20240620": { inputPerMTok: 3, outputPerMTok: 15 },
254
+ "claude-3-7-sonnet-20250219": { inputPerMTok: 3, outputPerMTok: 15, cachedInputPerMTok: 0.3 },
255
+ "claude-3-7-sonnet@20250219": { inputPerMTok: 3, outputPerMTok: 15, cachedInputPerMTok: 0.3 },
256
+ "claude-3-haiku": { inputPerMTok: 0.25, outputPerMTok: 1.25 },
257
+ "claude-3-haiku-20240307": { inputPerMTok: 0.25, outputPerMTok: 1.25, cachedInputPerMTok: 0.03 },
258
+ "claude-3-haiku@20240307": { inputPerMTok: 0.25, outputPerMTok: 1.25 },
259
+ "claude-3-opus": { inputPerMTok: 15, outputPerMTok: 75 },
260
+ "claude-3-opus-20240229": { inputPerMTok: 15, outputPerMTok: 75, cachedInputPerMTok: 1.5 },
261
+ "claude-3-opus@20240229": { inputPerMTok: 15, outputPerMTok: 75 },
262
+ "claude-3-sonnet": { inputPerMTok: 3, outputPerMTok: 15 },
263
+ "claude-3-sonnet@20240229": { inputPerMTok: 3, outputPerMTok: 15 },
264
+ "claude-4-opus-20250514": { inputPerMTok: 15, outputPerMTok: 75, cachedInputPerMTok: 1.5 },
265
+ "claude-4-sonnet-20250514": { inputPerMTok: 3, outputPerMTok: 15, cachedInputPerMTok: 0.3 },
266
+ "claude-haiku-4-5": { inputPerMTok: 1, outputPerMTok: 5, cachedInputPerMTok: 0.1 },
267
+ "claude-haiku-4-5-20251001": { inputPerMTok: 1, outputPerMTok: 5, cachedInputPerMTok: 0.1 },
268
+ "claude-haiku-4-5@20251001": { inputPerMTok: 1, outputPerMTok: 5, cachedInputPerMTok: 0.1 },
269
+ "claude-opus-4": { inputPerMTok: 15, outputPerMTok: 75, cachedInputPerMTok: 1.5 },
270
+ "claude-opus-4-1": { inputPerMTok: 15, outputPerMTok: 75, cachedInputPerMTok: 1.5 },
271
+ "claude-opus-4-1-20250805": { inputPerMTok: 15, outputPerMTok: 75, cachedInputPerMTok: 1.5 },
272
+ "claude-opus-4-1@20250805": { inputPerMTok: 15, outputPerMTok: 75, cachedInputPerMTok: 1.5 },
273
+ "claude-opus-4-20250514": { inputPerMTok: 15, outputPerMTok: 75, cachedInputPerMTok: 1.5 },
274
+ "claude-opus-4-5": { inputPerMTok: 5, outputPerMTok: 25, cachedInputPerMTok: 0.5 },
275
+ "claude-opus-4-5-20251101": { inputPerMTok: 5, outputPerMTok: 25, cachedInputPerMTok: 0.5 },
276
+ "claude-opus-4-5@20251101": { inputPerMTok: 5, outputPerMTok: 25, cachedInputPerMTok: 0.5 },
277
+ "claude-opus-4-6": { inputPerMTok: 5, outputPerMTok: 25, cachedInputPerMTok: 0.5 },
278
+ "claude-opus-4-6-20260205": { inputPerMTok: 5, outputPerMTok: 25, cachedInputPerMTok: 0.5 },
279
+ "claude-opus-4-6@default": { inputPerMTok: 5, outputPerMTok: 25, cachedInputPerMTok: 0.5 },
280
+ "claude-opus-4-7": { inputPerMTok: 5, outputPerMTok: 25, cachedInputPerMTok: 0.5 },
281
+ "claude-opus-4-7-20260416": { inputPerMTok: 5, outputPerMTok: 25, cachedInputPerMTok: 0.5 },
282
+ "claude-opus-4-7@default": { inputPerMTok: 5, outputPerMTok: 25, cachedInputPerMTok: 0.5 },
283
+ "claude-opus-4-8": { inputPerMTok: 5, outputPerMTok: 25, cachedInputPerMTok: 0.5 },
284
+ "claude-opus-4-8@default": { inputPerMTok: 5, outputPerMTok: 25, cachedInputPerMTok: 0.5 },
285
+ "claude-opus-4@20250514": { inputPerMTok: 15, outputPerMTok: 75, cachedInputPerMTok: 1.5 },
286
+ "claude-sonnet-4": { inputPerMTok: 3, outputPerMTok: 15, cachedInputPerMTok: 0.3 },
287
+ "claude-sonnet-4-20250514": { inputPerMTok: 3, outputPerMTok: 15, cachedInputPerMTok: 0.3 },
288
+ "claude-sonnet-4-5": { inputPerMTok: 3, outputPerMTok: 15, cachedInputPerMTok: 0.3 },
289
+ "claude-sonnet-4-5-20250929": { inputPerMTok: 3, outputPerMTok: 15, cachedInputPerMTok: 0.3 },
290
+ "claude-sonnet-4-5@20250929": { inputPerMTok: 3, outputPerMTok: 15, cachedInputPerMTok: 0.3 },
291
+ "claude-sonnet-4-6": { inputPerMTok: 3, outputPerMTok: 15, cachedInputPerMTok: 0.3 },
292
+ "claude-sonnet-4-6@default": { inputPerMTok: 3, outputPerMTok: 15, cachedInputPerMTok: 0.3 },
293
+ "claude-sonnet-4@20250514": { inputPerMTok: 3, outputPerMTok: 15, cachedInputPerMTok: 0.3 },
294
+ "codestral-2": { inputPerMTok: 0.3, outputPerMTok: 0.9 },
295
+ "codestral-2405": { inputPerMTok: 1, outputPerMTok: 3 },
296
+ "codestral-2501": { inputPerMTok: 0.2, outputPerMTok: 0.6 },
297
+ "codestral-2508": { inputPerMTok: 0.3, outputPerMTok: 0.9 },
298
+ "codestral-2@001": { inputPerMTok: 0.3, outputPerMTok: 0.9 },
299
+ "codestral-latest": { inputPerMTok: 1, outputPerMTok: 3 },
300
+ "codestral-mamba-latest": { inputPerMTok: 0.25, outputPerMTok: 0.25 },
301
+ "codestral@2405": { inputPerMTok: 0.2, outputPerMTok: 0.6 },
302
+ "codestral@latest": { inputPerMTok: 0.2, outputPerMTok: 0.6 },
303
+ "codex-mini-latest": { inputPerMTok: 1.5, outputPerMTok: 6, cachedInputPerMTok: 0.375 },
304
+ "cohere/embed-v4.0": { inputPerMTok: 0.12, outputPerMTok: 0 },
305
+ "command": { inputPerMTok: 1, outputPerMTok: 2 },
306
+ "command-nightly": { inputPerMTok: 1, outputPerMTok: 2 },
307
+ "deep-research-pro-preview-12-2025": { inputPerMTok: 2, outputPerMTok: 12 },
308
+ "deepseek-chat": { inputPerMTok: 0.28, outputPerMTok: 0.42, cachedInputPerMTok: 0.028 },
309
+ "deepseek-coder": { inputPerMTok: 0.14, outputPerMTok: 0.28 },
310
+ "deepseek-r1": { inputPerMTok: 0.55, outputPerMTok: 2.19 },
311
+ "deepseek-reasoner": { inputPerMTok: 0.28, outputPerMTok: 0.42, cachedInputPerMTok: 0.028 },
312
+ "deepseek-v3": { inputPerMTok: 0.27, outputPerMTok: 1.1, cachedInputPerMTok: 0.07 },
313
+ "deepseek-v3.2": { inputPerMTok: 0.28, outputPerMTok: 0.4 },
314
+ "deepseek/deepseek-chat": { inputPerMTok: 0.28, outputPerMTok: 0.42, cachedInputPerMTok: 0.028 },
315
+ "deepseek/deepseek-coder": { inputPerMTok: 0.14, outputPerMTok: 0.28 },
316
+ "deepseek/deepseek-r1": { inputPerMTok: 0.55, outputPerMTok: 2.19 },
317
+ "deepseek/deepseek-reasoner": { inputPerMTok: 0.28, outputPerMTok: 0.42, cachedInputPerMTok: 0.028 },
318
+ "deepseek/deepseek-v3": { inputPerMTok: 0.27, outputPerMTok: 1.1, cachedInputPerMTok: 0.07 },
319
+ "deepseek/deepseek-v3.2": { inputPerMTok: 0.28, outputPerMTok: 0.4 },
320
+ "devstral-2512": { inputPerMTok: 0.4, outputPerMTok: 2 },
321
+ "devstral-latest": { inputPerMTok: 0.4, outputPerMTok: 2 },
322
+ "devstral-medium-2507": { inputPerMTok: 0.4, outputPerMTok: 2 },
323
+ "devstral-medium-latest": { inputPerMTok: 0.4, outputPerMTok: 2 },
324
+ "devstral-small-2505": { inputPerMTok: 0.1, outputPerMTok: 0.3 },
325
+ "devstral-small-2507": { inputPerMTok: 0.1, outputPerMTok: 0.3 },
326
+ "devstral-small-latest": { inputPerMTok: 0.1, outputPerMTok: 0.3 },
327
+ "embed-english-light-v2.0": { inputPerMTok: 0.1, outputPerMTok: 0 },
328
+ "embed-english-light-v3.0": { inputPerMTok: 0.1, outputPerMTok: 0 },
329
+ "embed-english-v2.0": { inputPerMTok: 0.1, outputPerMTok: 0 },
330
+ "embed-english-v3.0": { inputPerMTok: 0.1, outputPerMTok: 0 },
331
+ "embed-multilingual-light-v3.0": { inputPerMTok: 100, outputPerMTok: 0 },
332
+ "embed-multilingual-v2.0": { inputPerMTok: 0.1, outputPerMTok: 0 },
333
+ "embed-multilingual-v3.0": { inputPerMTok: 0.1, outputPerMTok: 0 },
334
+ "embed-v4.0": { inputPerMTok: 0.12, outputPerMTok: 0 },
335
+ "ft:gpt-3.5-turbo": { inputPerMTok: 3, outputPerMTok: 6 },
336
+ "ft:gpt-3.5-turbo-0125": { inputPerMTok: 3, outputPerMTok: 6 },
337
+ "ft:gpt-3.5-turbo-0613": { inputPerMTok: 3, outputPerMTok: 6 },
338
+ "ft:gpt-3.5-turbo-1106": { inputPerMTok: 3, outputPerMTok: 6 },
339
+ "ft:gpt-4-0613": { inputPerMTok: 30, outputPerMTok: 60 },
340
+ "ft:gpt-4.1-2025-04-14": { inputPerMTok: 3, outputPerMTok: 12, cachedInputPerMTok: 0.75 },
341
+ "ft:gpt-4.1-mini-2025-04-14": { inputPerMTok: 0.8, outputPerMTok: 3.2, cachedInputPerMTok: 0.2 },
342
+ "ft:gpt-4.1-nano-2025-04-14": { inputPerMTok: 0.2, outputPerMTok: 0.8, cachedInputPerMTok: 0.05 },
343
+ "ft:gpt-4o-2024-08-06": { inputPerMTok: 3.75, outputPerMTok: 15, cachedInputPerMTok: 1.875 },
344
+ "ft:gpt-4o-2024-11-20": { inputPerMTok: 3.75, outputPerMTok: 15 },
345
+ "ft:gpt-4o-mini-2024-07-18": { inputPerMTok: 0.3, outputPerMTok: 1.2, cachedInputPerMTok: 0.15 },
346
+ "ft:o4-mini-2025-04-16": { inputPerMTok: 4, outputPerMTok: 16, cachedInputPerMTok: 1 },
347
+ "gemini-1.5-flash": { inputPerMTok: 0.075, outputPerMTok: 0 },
348
+ "gemini-2.0-flash": { inputPerMTok: 0.1, outputPerMTok: 0.4, cachedInputPerMTok: 0.025 },
349
+ "gemini-2.0-flash-001": { inputPerMTok: 0.15, outputPerMTok: 0.6, cachedInputPerMTok: 0.0375 },
350
+ "gemini-2.0-flash-exp-image-generation": { inputPerMTok: 0, outputPerMTok: 0 },
351
+ "gemini-2.0-flash-lite": { inputPerMTok: 0.075, outputPerMTok: 0.3, cachedInputPerMTok: 0.01875 },
352
+ "gemini-2.0-flash-lite-001": { inputPerMTok: 0.075, outputPerMTok: 0.3, cachedInputPerMTok: 0.01875 },
353
+ "gemini-2.5-computer-use-preview-10-2025": { inputPerMTok: 1.25, outputPerMTok: 10 },
354
+ "gemini-2.5-flash": { inputPerMTok: 0.3, outputPerMTok: 2.5, cachedInputPerMTok: 0.03 },
355
+ "gemini-2.5-flash-image": { inputPerMTok: 0.3, outputPerMTok: 2.5, cachedInputPerMTok: 0.03 },
356
+ "gemini-2.5-flash-lite": { inputPerMTok: 0.1, outputPerMTok: 0.4, cachedInputPerMTok: 0.01 },
357
+ "gemini-2.5-flash-lite-preview-06-17": { inputPerMTok: 0.1, outputPerMTok: 0.4, cachedInputPerMTok: 0.025 },
358
+ "gemini-2.5-flash-lite-preview-09-2025": { inputPerMTok: 0.1, outputPerMTok: 0.4, cachedInputPerMTok: 0.01 },
359
+ "gemini-2.5-flash-native-audio-latest": { inputPerMTok: 0.3, outputPerMTok: 2.5 },
360
+ "gemini-2.5-flash-native-audio-preview-09-2025": { inputPerMTok: 0.3, outputPerMTok: 2.5 },
361
+ "gemini-2.5-flash-native-audio-preview-12-2025": { inputPerMTok: 0.3, outputPerMTok: 2.5 },
362
+ "gemini-2.5-flash-preview-09-2025": { inputPerMTok: 0.3, outputPerMTok: 2.5, cachedInputPerMTok: 0.075 },
363
+ "gemini-2.5-flash-preview-tts": { inputPerMTok: 0.3, outputPerMTok: 2.5 },
364
+ "gemini-2.5-pro": { inputPerMTok: 1.25, outputPerMTok: 10, cachedInputPerMTok: 0.125 },
365
+ "gemini-2.5-pro-preview-tts": { inputPerMTok: 1.25, outputPerMTok: 10, cachedInputPerMTok: 0.125 },
366
+ "gemini-3-flash-preview": { inputPerMTok: 0.5, outputPerMTok: 3, cachedInputPerMTok: 0.05 },
367
+ "gemini-3-pro-image-preview": { inputPerMTok: 2, outputPerMTok: 12 },
368
+ "gemini-3-pro-preview": { inputPerMTok: 2, outputPerMTok: 12, cachedInputPerMTok: 0.2 },
369
+ "gemini-3.1-flash-image-preview": { inputPerMTok: 0.5, outputPerMTok: 3 },
370
+ "gemini-3.1-flash-lite": { inputPerMTok: 0.25, outputPerMTok: 1.5, cachedInputPerMTok: 0.025 },
371
+ "gemini-3.1-flash-lite-preview": { inputPerMTok: 0.25, outputPerMTok: 1.5, cachedInputPerMTok: 0.025 },
372
+ "gemini-3.1-flash-live-preview": { inputPerMTok: 0.75, outputPerMTok: 4.5 },
373
+ "gemini-3.1-pro-preview": { inputPerMTok: 2, outputPerMTok: 12, cachedInputPerMTok: 0.2 },
374
+ "gemini-3.1-pro-preview-customtools": { inputPerMTok: 2, outputPerMTok: 12, cachedInputPerMTok: 0.2 },
375
+ "gemini-3.5-flash": { inputPerMTok: 1.5, outputPerMTok: 9, cachedInputPerMTok: 0.15 },
376
+ "gemini-embedding-001": { inputPerMTok: 0.15, outputPerMTok: 0 },
377
+ "gemini-embedding-2": { inputPerMTok: 0.2, outputPerMTok: 0 },
378
+ "gemini-embedding-2-preview": { inputPerMTok: 0.2, outputPerMTok: 0 },
379
+ "gemini-exp-1114": { inputPerMTok: 0, outputPerMTok: 0 },
380
+ "gemini-exp-1206": { inputPerMTok: 0.3, outputPerMTok: 2.5, cachedInputPerMTok: 0.03 },
381
+ "gemini-flash-experimental": { inputPerMTok: 0, outputPerMTok: 0 },
382
+ "gemini-flash-latest": { inputPerMTok: 0.3, outputPerMTok: 2.5, cachedInputPerMTok: 0.03 },
383
+ "gemini-flash-lite-latest": { inputPerMTok: 0.1, outputPerMTok: 0.4, cachedInputPerMTok: 0.01 },
384
+ "gemini-gemma-2-27b-it": { inputPerMTok: 0.35, outputPerMTok: 1.05 },
385
+ "gemini-gemma-2-9b-it": { inputPerMTok: 0.35, outputPerMTok: 1.05 },
386
+ "gemini-live-2.5-flash-preview-native-audio-09-2025": { inputPerMTok: 0.3, outputPerMTok: 2, cachedInputPerMTok: 0.075 },
387
+ "gemini-pro-latest": { inputPerMTok: 1.25, outputPerMTok: 10, cachedInputPerMTok: 0.125 },
388
+ "gemini-robotics-er-1.5-preview": { inputPerMTok: 0.3, outputPerMTok: 2.5, cachedInputPerMTok: 0 },
389
+ "gemini/deep-research-pro-preview-12-2025": { inputPerMTok: 2, outputPerMTok: 12 },
390
+ "gemini/gemini-1.5-flash": { inputPerMTok: 0.075, outputPerMTok: 0 },
391
+ "gemini/gemini-2.0-flash": { inputPerMTok: 0.1, outputPerMTok: 0.4, cachedInputPerMTok: 0.025 },
392
+ "gemini/gemini-2.0-flash-001": { inputPerMTok: 0.1, outputPerMTok: 0.4, cachedInputPerMTok: 0.025 },
393
+ "gemini/gemini-2.0-flash-exp-image-generation": { inputPerMTok: 0, outputPerMTok: 0 },
394
+ "gemini/gemini-2.0-flash-lite": { inputPerMTok: 0.075, outputPerMTok: 0.3, cachedInputPerMTok: 0.01875 },
395
+ "gemini/gemini-2.0-flash-lite-001": { inputPerMTok: 0.075, outputPerMTok: 0.3, cachedInputPerMTok: 0.01875 },
396
+ "gemini/gemini-2.5-computer-use-preview-10-2025": { inputPerMTok: 1.25, outputPerMTok: 10 },
397
+ "gemini/gemini-2.5-flash": { inputPerMTok: 0.3, outputPerMTok: 2.5, cachedInputPerMTok: 0.03 },
398
+ "gemini/gemini-2.5-flash-image": { inputPerMTok: 0.3, outputPerMTok: 2.5, cachedInputPerMTok: 0.03 },
399
+ "gemini/gemini-2.5-flash-lite": { inputPerMTok: 0.1, outputPerMTok: 0.4, cachedInputPerMTok: 0.01 },
400
+ "gemini/gemini-2.5-flash-lite-preview-06-17": { inputPerMTok: 0.1, outputPerMTok: 0.4, cachedInputPerMTok: 0.025 },
401
+ "gemini/gemini-2.5-flash-lite-preview-09-2025": { inputPerMTok: 0.1, outputPerMTok: 0.4, cachedInputPerMTok: 0.01 },
402
+ "gemini/gemini-2.5-flash-native-audio-latest": { inputPerMTok: 0.3, outputPerMTok: 2.5 },
403
+ "gemini/gemini-2.5-flash-native-audio-preview-09-2025": { inputPerMTok: 0.3, outputPerMTok: 2.5 },
404
+ "gemini/gemini-2.5-flash-native-audio-preview-12-2025": { inputPerMTok: 0.3, outputPerMTok: 2.5 },
405
+ "gemini/gemini-2.5-flash-preview-09-2025": { inputPerMTok: 0.3, outputPerMTok: 2.5, cachedInputPerMTok: 0.075 },
406
+ "gemini/gemini-2.5-flash-preview-tts": { inputPerMTok: 0.3, outputPerMTok: 2.5 },
407
+ "gemini/gemini-2.5-pro": { inputPerMTok: 1.25, outputPerMTok: 10, cachedInputPerMTok: 0.125 },
408
+ "gemini/gemini-2.5-pro-preview-tts": { inputPerMTok: 1.25, outputPerMTok: 10, cachedInputPerMTok: 0.125 },
409
+ "gemini/gemini-3-flash-preview": { inputPerMTok: 0.5, outputPerMTok: 3, cachedInputPerMTok: 0.05 },
410
+ "gemini/gemini-3-pro-image-preview": { inputPerMTok: 2, outputPerMTok: 12 },
411
+ "gemini/gemini-3-pro-preview": { inputPerMTok: 2, outputPerMTok: 12, cachedInputPerMTok: 0.2 },
412
+ "gemini/gemini-3.1-flash-image-preview": { inputPerMTok: 0.25, outputPerMTok: 1.5 },
413
+ "gemini/gemini-3.1-flash-lite": { inputPerMTok: 0.25, outputPerMTok: 1.5, cachedInputPerMTok: 0.025 },
414
+ "gemini/gemini-3.1-flash-lite-preview": { inputPerMTok: 0.25, outputPerMTok: 1.5, cachedInputPerMTok: 0.025 },
415
+ "gemini/gemini-3.1-flash-live-preview": { inputPerMTok: 0.75, outputPerMTok: 4.5 },
416
+ "gemini/gemini-3.1-pro-preview": { inputPerMTok: 2, outputPerMTok: 12, cachedInputPerMTok: 0.2 },
417
+ "gemini/gemini-3.1-pro-preview-customtools": { inputPerMTok: 2, outputPerMTok: 12, cachedInputPerMTok: 0.2 },
418
+ "gemini/gemini-3.5-flash": { inputPerMTok: 1.5, outputPerMTok: 9, cachedInputPerMTok: 0.15 },
419
+ "gemini/gemini-embedding-001": { inputPerMTok: 0.15, outputPerMTok: 0 },
420
+ "gemini/gemini-embedding-2": { inputPerMTok: 0.2, outputPerMTok: 0 },
421
+ "gemini/gemini-embedding-2-preview": { inputPerMTok: 0.2, outputPerMTok: 0 },
422
+ "gemini/gemini-exp-1114": { inputPerMTok: 0, outputPerMTok: 0 },
423
+ "gemini/gemini-exp-1206": { inputPerMTok: 0, outputPerMTok: 0 },
424
+ "gemini/gemini-flash-latest": { inputPerMTok: 0.3, outputPerMTok: 2.5, cachedInputPerMTok: 0.075 },
425
+ "gemini/gemini-flash-lite-latest": { inputPerMTok: 0.1, outputPerMTok: 0.4, cachedInputPerMTok: 0.025 },
426
+ "gemini/gemini-gemma-2-27b-it": { inputPerMTok: 0.35, outputPerMTok: 1.05 },
427
+ "gemini/gemini-gemma-2-9b-it": { inputPerMTok: 0.35, outputPerMTok: 1.05 },
428
+ "gemini/gemini-live-2.5-flash-preview-native-audio-09-2025": { inputPerMTok: 0.3, outputPerMTok: 2, cachedInputPerMTok: 0.075 },
429
+ "gemini/gemini-pro-latest": { inputPerMTok: 1.25, outputPerMTok: 10, cachedInputPerMTok: 0.125 },
430
+ "gemini/gemini-robotics-er-1.5-preview": { inputPerMTok: 0.3, outputPerMTok: 2.5, cachedInputPerMTok: 0 },
431
+ "gemini/gemma-3-27b-it": { inputPerMTok: 0, outputPerMTok: 0 },
432
+ "gemini/learnlm-1.5-pro-experimental": { inputPerMTok: 0, outputPerMTok: 0 },
433
+ "gemini/lyria-3-clip-preview": { inputPerMTok: 0, outputPerMTok: 0 },
434
+ "gemini/lyria-3-pro-preview": { inputPerMTok: 0, outputPerMTok: 0 },
435
+ "gemma-3-27b-it": { inputPerMTok: 0, outputPerMTok: 0 },
436
+ "gpt-3.5-turbo": { inputPerMTok: 0.5, outputPerMTok: 1.5 },
437
+ "gpt-3.5-turbo-0125": { inputPerMTok: 0.5, outputPerMTok: 1.5 },
438
+ "gpt-3.5-turbo-1106": { inputPerMTok: 1, outputPerMTok: 2 },
439
+ "gpt-3.5-turbo-16k": { inputPerMTok: 3, outputPerMTok: 4 },
440
+ "gpt-4": { inputPerMTok: 30, outputPerMTok: 60 },
441
+ "gpt-4-0125-preview": { inputPerMTok: 10, outputPerMTok: 30 },
442
+ "gpt-4-0314": { inputPerMTok: 30, outputPerMTok: 60 },
443
+ "gpt-4-0613": { inputPerMTok: 30, outputPerMTok: 60 },
444
+ "gpt-4-1106-preview": { inputPerMTok: 10, outputPerMTok: 30 },
445
+ "gpt-4-turbo": { inputPerMTok: 10, outputPerMTok: 30 },
446
+ "gpt-4-turbo-2024-04-09": { inputPerMTok: 10, outputPerMTok: 30 },
447
+ "gpt-4-turbo-preview": { inputPerMTok: 10, outputPerMTok: 30 },
448
+ "gpt-4.1": { inputPerMTok: 2, outputPerMTok: 8, cachedInputPerMTok: 0.5 },
449
+ "gpt-4.1-2025-04-14": { inputPerMTok: 2, outputPerMTok: 8, cachedInputPerMTok: 0.5 },
450
+ "gpt-4.1-mini": { inputPerMTok: 0.4, outputPerMTok: 1.6, cachedInputPerMTok: 0.1 },
451
+ "gpt-4.1-mini-2025-04-14": { inputPerMTok: 0.4, outputPerMTok: 1.6, cachedInputPerMTok: 0.1 },
452
+ "gpt-4.1-nano": { inputPerMTok: 0.1, outputPerMTok: 0.4, cachedInputPerMTok: 0.025 },
453
+ "gpt-4.1-nano-2025-04-14": { inputPerMTok: 0.1, outputPerMTok: 0.4, cachedInputPerMTok: 0.025 },
454
+ "gpt-4o": { inputPerMTok: 2.5, outputPerMTok: 10, cachedInputPerMTok: 1.25 },
455
+ "gpt-4o-2024-05-13": { inputPerMTok: 5, outputPerMTok: 15 },
456
+ "gpt-4o-2024-08-06": { inputPerMTok: 2.5, outputPerMTok: 10, cachedInputPerMTok: 1.25 },
457
+ "gpt-4o-2024-11-20": { inputPerMTok: 2.5, outputPerMTok: 10, cachedInputPerMTok: 1.25 },
458
+ "gpt-4o-audio-preview": { inputPerMTok: 2.5, outputPerMTok: 10 },
459
+ "gpt-4o-audio-preview-2024-12-17": { inputPerMTok: 2.5, outputPerMTok: 10 },
460
+ "gpt-4o-audio-preview-2025-06-03": { inputPerMTok: 2.5, outputPerMTok: 10 },
461
+ "gpt-4o-mini": { inputPerMTok: 0.15, outputPerMTok: 0.6, cachedInputPerMTok: 0.075 },
462
+ "gpt-4o-mini-2024-07-18": { inputPerMTok: 0.15, outputPerMTok: 0.6, cachedInputPerMTok: 0.075 },
463
+ "gpt-4o-mini-audio-preview": { inputPerMTok: 0.15, outputPerMTok: 0.6 },
464
+ "gpt-4o-mini-audio-preview-2024-12-17": { inputPerMTok: 0.15, outputPerMTok: 0.6 },
465
+ "gpt-4o-mini-realtime-preview": { inputPerMTok: 0.6, outputPerMTok: 2.4, cachedInputPerMTok: 0.3 },
466
+ "gpt-4o-mini-realtime-preview-2024-12-17": { inputPerMTok: 0.6, outputPerMTok: 2.4, cachedInputPerMTok: 0.3 },
467
+ "gpt-4o-mini-search-preview": { inputPerMTok: 0.15, outputPerMTok: 0.6, cachedInputPerMTok: 0.075 },
468
+ "gpt-4o-mini-search-preview-2025-03-11": { inputPerMTok: 0.15, outputPerMTok: 0.6, cachedInputPerMTok: 0.075 },
469
+ "gpt-4o-mini-transcribe": { inputPerMTok: 1.25, outputPerMTok: 5 },
470
+ "gpt-4o-mini-transcribe-2025-03-20": { inputPerMTok: 1.25, outputPerMTok: 5 },
471
+ "gpt-4o-mini-transcribe-2025-12-15": { inputPerMTok: 1.25, outputPerMTok: 5 },
472
+ "gpt-4o-mini-tts": { inputPerMTok: 2.5, outputPerMTok: 10 },
473
+ "gpt-4o-mini-tts-2025-03-20": { inputPerMTok: 2.5, outputPerMTok: 10 },
474
+ "gpt-4o-mini-tts-2025-12-15": { inputPerMTok: 2.5, outputPerMTok: 10 },
475
+ "gpt-4o-realtime-preview": { inputPerMTok: 5, outputPerMTok: 20, cachedInputPerMTok: 2.5 },
476
+ "gpt-4o-realtime-preview-2024-12-17": { inputPerMTok: 5, outputPerMTok: 20, cachedInputPerMTok: 2.5 },
477
+ "gpt-4o-realtime-preview-2025-06-03": { inputPerMTok: 5, outputPerMTok: 20, cachedInputPerMTok: 2.5 },
478
+ "gpt-4o-search-preview": { inputPerMTok: 2.5, outputPerMTok: 10, cachedInputPerMTok: 1.25 },
479
+ "gpt-4o-search-preview-2025-03-11": { inputPerMTok: 2.5, outputPerMTok: 10, cachedInputPerMTok: 1.25 },
480
+ "gpt-4o-transcribe": { inputPerMTok: 2.5, outputPerMTok: 10 },
481
+ "gpt-4o-transcribe-diarize": { inputPerMTok: 2.5, outputPerMTok: 10 },
482
+ "gpt-5": { inputPerMTok: 1.25, outputPerMTok: 10, cachedInputPerMTok: 0.125 },
483
+ "gpt-5-2025-08-07": { inputPerMTok: 1.25, outputPerMTok: 10, cachedInputPerMTok: 0.125 },
484
+ "gpt-5-chat": { inputPerMTok: 1.25, outputPerMTok: 10, cachedInputPerMTok: 0.125 },
485
+ "gpt-5-chat-latest": { inputPerMTok: 1.25, outputPerMTok: 10, cachedInputPerMTok: 0.125 },
486
+ "gpt-5-codex": { inputPerMTok: 1.25, outputPerMTok: 10, cachedInputPerMTok: 0.125 },
487
+ "gpt-5-mini": { inputPerMTok: 0.25, outputPerMTok: 2, cachedInputPerMTok: 0.025 },
488
+ "gpt-5-mini-2025-08-07": { inputPerMTok: 0.25, outputPerMTok: 2, cachedInputPerMTok: 0.025 },
489
+ "gpt-5-nano": { inputPerMTok: 0.05, outputPerMTok: 0.4, cachedInputPerMTok: 5e-3 },
490
+ "gpt-5-nano-2025-08-07": { inputPerMTok: 0.05, outputPerMTok: 0.4, cachedInputPerMTok: 5e-3 },
491
+ "gpt-5-pro": { inputPerMTok: 15, outputPerMTok: 120 },
492
+ "gpt-5-pro-2025-10-06": { inputPerMTok: 15, outputPerMTok: 120 },
493
+ "gpt-5-search-api": { inputPerMTok: 1.25, outputPerMTok: 10, cachedInputPerMTok: 0.125 },
494
+ "gpt-5-search-api-2025-10-14": { inputPerMTok: 1.25, outputPerMTok: 10, cachedInputPerMTok: 0.125 },
495
+ "gpt-5.1": { inputPerMTok: 1.25, outputPerMTok: 10, cachedInputPerMTok: 0.125 },
496
+ "gpt-5.1-2025-11-13": { inputPerMTok: 1.25, outputPerMTok: 10, cachedInputPerMTok: 0.125 },
497
+ "gpt-5.1-chat-latest": { inputPerMTok: 1.25, outputPerMTok: 10, cachedInputPerMTok: 0.125 },
498
+ "gpt-5.1-codex": { inputPerMTok: 1.25, outputPerMTok: 10, cachedInputPerMTok: 0.125 },
499
+ "gpt-5.1-codex-max": { inputPerMTok: 1.25, outputPerMTok: 10, cachedInputPerMTok: 0.125 },
500
+ "gpt-5.1-codex-mini": { inputPerMTok: 0.25, outputPerMTok: 2, cachedInputPerMTok: 0.025 },
501
+ "gpt-5.2": { inputPerMTok: 1.75, outputPerMTok: 14, cachedInputPerMTok: 0.175 },
502
+ "gpt-5.2-2025-12-11": { inputPerMTok: 1.75, outputPerMTok: 14, cachedInputPerMTok: 0.175 },
503
+ "gpt-5.2-chat-latest": { inputPerMTok: 1.75, outputPerMTok: 14, cachedInputPerMTok: 0.175 },
504
+ "gpt-5.2-codex": { inputPerMTok: 1.75, outputPerMTok: 14, cachedInputPerMTok: 0.175 },
505
+ "gpt-5.2-pro": { inputPerMTok: 21, outputPerMTok: 168 },
506
+ "gpt-5.2-pro-2025-12-11": { inputPerMTok: 21, outputPerMTok: 168 },
507
+ "gpt-5.3-chat-latest": { inputPerMTok: 1.75, outputPerMTok: 14, cachedInputPerMTok: 0.175 },
508
+ "gpt-5.3-codex": { inputPerMTok: 1.75, outputPerMTok: 14, cachedInputPerMTok: 0.175 },
509
+ "gpt-5.4": { inputPerMTok: 2.5, outputPerMTok: 15, cachedInputPerMTok: 0.25 },
510
+ "gpt-5.4-2026-03-05": { inputPerMTok: 2.5, outputPerMTok: 15, cachedInputPerMTok: 0.25 },
511
+ "gpt-5.4-mini": { inputPerMTok: 0.75, outputPerMTok: 4.5, cachedInputPerMTok: 0.075 },
512
+ "gpt-5.4-mini-2026-03-17": { inputPerMTok: 0.75, outputPerMTok: 4.5, cachedInputPerMTok: 0.075 },
513
+ "gpt-5.4-nano": { inputPerMTok: 0.2, outputPerMTok: 1.25, cachedInputPerMTok: 0.02 },
514
+ "gpt-5.4-nano-2026-03-17": { inputPerMTok: 0.2, outputPerMTok: 1.25, cachedInputPerMTok: 0.02 },
515
+ "gpt-5.4-pro": { inputPerMTok: 30, outputPerMTok: 180, cachedInputPerMTok: 3 },
516
+ "gpt-5.4-pro-2026-03-05": { inputPerMTok: 30, outputPerMTok: 180, cachedInputPerMTok: 3 },
517
+ "gpt-5.5": { inputPerMTok: 5, outputPerMTok: 30, cachedInputPerMTok: 0.5 },
518
+ "gpt-5.5-2026-04-23": { inputPerMTok: 5, outputPerMTok: 30, cachedInputPerMTok: 0.5 },
519
+ "gpt-5.5-pro": { inputPerMTok: 30, outputPerMTok: 180, cachedInputPerMTok: 3 },
520
+ "gpt-5.5-pro-2026-04-23": { inputPerMTok: 30, outputPerMTok: 180, cachedInputPerMTok: 3 },
521
+ "gpt-audio": { inputPerMTok: 2.5, outputPerMTok: 10 },
522
+ "gpt-audio-1.5": { inputPerMTok: 2.5, outputPerMTok: 10 },
523
+ "gpt-audio-2025-08-28": { inputPerMTok: 2.5, outputPerMTok: 10 },
524
+ "gpt-audio-mini": { inputPerMTok: 0.6, outputPerMTok: 2.4 },
525
+ "gpt-audio-mini-2025-10-06": { inputPerMTok: 0.6, outputPerMTok: 2.4 },
526
+ "gpt-audio-mini-2025-12-15": { inputPerMTok: 0.6, outputPerMTok: 2.4 },
527
+ "gpt-image-1.5": { inputPerMTok: 5, outputPerMTok: 10, cachedInputPerMTok: 1.25 },
528
+ "gpt-image-1.5-2025-12-16": { inputPerMTok: 5, outputPerMTok: 10, cachedInputPerMTok: 1.25 },
529
+ "gpt-image-2": { inputPerMTok: 5, outputPerMTok: 10, cachedInputPerMTok: 1.25 },
530
+ "gpt-image-2-2026-04-21": { inputPerMTok: 5, outputPerMTok: 10, cachedInputPerMTok: 1.25 },
531
+ "gpt-realtime": { inputPerMTok: 4, outputPerMTok: 16, cachedInputPerMTok: 0.4 },
532
+ "gpt-realtime-1.5": { inputPerMTok: 4, outputPerMTok: 16, cachedInputPerMTok: 0.4 },
533
+ "gpt-realtime-2": { inputPerMTok: 4, outputPerMTok: 16, cachedInputPerMTok: 0.4 },
534
+ "gpt-realtime-2025-08-28": { inputPerMTok: 4, outputPerMTok: 16, cachedInputPerMTok: 0.4 },
535
+ "gpt-realtime-mini": { inputPerMTok: 0.6, outputPerMTok: 2.4 },
536
+ "gpt-realtime-mini-2025-10-06": { inputPerMTok: 0.6, outputPerMTok: 2.4, cachedInputPerMTok: 0.06 },
537
+ "gpt-realtime-mini-2025-12-15": { inputPerMTok: 0.6, outputPerMTok: 2.4, cachedInputPerMTok: 0.06 },
538
+ "grok-2": { inputPerMTok: 2, outputPerMTok: 10 },
539
+ "grok-2-1212": { inputPerMTok: 2, outputPerMTok: 10 },
540
+ "grok-2-latest": { inputPerMTok: 2, outputPerMTok: 10 },
541
+ "grok-2-vision": { inputPerMTok: 2, outputPerMTok: 10 },
542
+ "grok-2-vision-1212": { inputPerMTok: 2, outputPerMTok: 10 },
543
+ "grok-2-vision-latest": { inputPerMTok: 2, outputPerMTok: 10 },
544
+ "grok-3": { inputPerMTok: 3, outputPerMTok: 15, cachedInputPerMTok: 0.75 },
545
+ "grok-3-beta": { inputPerMTok: 3, outputPerMTok: 15, cachedInputPerMTok: 0.75 },
546
+ "grok-3-fast-beta": { inputPerMTok: 5, outputPerMTok: 25, cachedInputPerMTok: 1.25 },
547
+ "grok-3-fast-latest": { inputPerMTok: 5, outputPerMTok: 25, cachedInputPerMTok: 1.25 },
548
+ "grok-3-latest": { inputPerMTok: 3, outputPerMTok: 15, cachedInputPerMTok: 0.75 },
549
+ "grok-3-mini": { inputPerMTok: 0.3, outputPerMTok: 0.5, cachedInputPerMTok: 0.075 },
550
+ "grok-3-mini-beta": { inputPerMTok: 0.3, outputPerMTok: 0.5, cachedInputPerMTok: 0.075 },
551
+ "grok-3-mini-fast": { inputPerMTok: 0.6, outputPerMTok: 4, cachedInputPerMTok: 0.15 },
552
+ "grok-3-mini-fast-beta": { inputPerMTok: 0.6, outputPerMTok: 4, cachedInputPerMTok: 0.15 },
553
+ "grok-3-mini-fast-latest": { inputPerMTok: 0.6, outputPerMTok: 4, cachedInputPerMTok: 0.15 },
554
+ "grok-3-mini-latest": { inputPerMTok: 0.3, outputPerMTok: 0.5, cachedInputPerMTok: 0.075 },
555
+ "grok-4": { inputPerMTok: 3, outputPerMTok: 15 },
556
+ "grok-4-0709": { inputPerMTok: 3, outputPerMTok: 15 },
557
+ "grok-4-1-fast": { inputPerMTok: 0.2, outputPerMTok: 0.5, cachedInputPerMTok: 0.05 },
558
+ "grok-4-1-fast-non-reasoning": { inputPerMTok: 0.2, outputPerMTok: 0.5, cachedInputPerMTok: 0.05 },
559
+ "grok-4-1-fast-non-reasoning-latest": { inputPerMTok: 0.2, outputPerMTok: 0.5, cachedInputPerMTok: 0.05 },
560
+ "grok-4-1-fast-reasoning": { inputPerMTok: 0.2, outputPerMTok: 0.5, cachedInputPerMTok: 0.05 },
561
+ "grok-4-1-fast-reasoning-latest": { inputPerMTok: 0.2, outputPerMTok: 0.5, cachedInputPerMTok: 0.05 },
562
+ "grok-4-fast-non-reasoning": { inputPerMTok: 0.2, outputPerMTok: 0.5, cachedInputPerMTok: 0.05 },
563
+ "grok-4-fast-reasoning": { inputPerMTok: 0.2, outputPerMTok: 0.5, cachedInputPerMTok: 0.05 },
564
+ "grok-4-latest": { inputPerMTok: 3, outputPerMTok: 15 },
565
+ "grok-4.20-0309-reasoning": { inputPerMTok: 2, outputPerMTok: 6, cachedInputPerMTok: 0.2 },
566
+ "grok-4.20-beta-0309-non-reasoning": { inputPerMTok: 2, outputPerMTok: 6, cachedInputPerMTok: 0.2 },
567
+ "grok-4.20-beta-0309-reasoning": { inputPerMTok: 2, outputPerMTok: 6, cachedInputPerMTok: 0.2 },
568
+ "grok-4.20-multi-agent-beta-0309": { inputPerMTok: 2, outputPerMTok: 6, cachedInputPerMTok: 0.2 },
569
+ "grok-4.3": { inputPerMTok: 1.25, outputPerMTok: 2.5, cachedInputPerMTok: 0.2 },
570
+ "grok-4.3-latest": { inputPerMTok: 1.25, outputPerMTok: 2.5, cachedInputPerMTok: 0.2 },
571
+ "grok-beta": { inputPerMTok: 5, outputPerMTok: 15 },
572
+ "grok-code-fast": { inputPerMTok: 0.2, outputPerMTok: 1.5, cachedInputPerMTok: 0.02 },
573
+ "grok-code-fast-1": { inputPerMTok: 0.2, outputPerMTok: 1.5, cachedInputPerMTok: 0.02 },
574
+ "grok-code-fast-1-0825": { inputPerMTok: 0.2, outputPerMTok: 1.5, cachedInputPerMTok: 0.02 },
575
+ "grok-vision-beta": { inputPerMTok: 5, outputPerMTok: 15 },
576
+ "labs-devstral-small-2512": { inputPerMTok: 0.1, outputPerMTok: 0.3 },
577
+ "learnlm-1.5-pro-experimental": { inputPerMTok: 0, outputPerMTok: 0 },
578
+ "lyria-3-clip-preview": { inputPerMTok: 0, outputPerMTok: 0 },
579
+ "lyria-3-pro-preview": { inputPerMTok: 0, outputPerMTok: 0 },
580
+ "magistral-medium-1-2-2509": { inputPerMTok: 2, outputPerMTok: 5 },
581
+ "magistral-medium-2506": { inputPerMTok: 2, outputPerMTok: 5 },
582
+ "magistral-medium-2509": { inputPerMTok: 2, outputPerMTok: 5 },
583
+ "magistral-medium-latest": { inputPerMTok: 2, outputPerMTok: 5 },
584
+ "magistral-small-1-2-2509": { inputPerMTok: 0.5, outputPerMTok: 1.5 },
585
+ "magistral-small-2506": { inputPerMTok: 0.5, outputPerMTok: 1.5 },
586
+ "magistral-small-latest": { inputPerMTok: 0.5, outputPerMTok: 1.5 },
587
+ "ministral-3-14b-2512": { inputPerMTok: 0.2, outputPerMTok: 0.2 },
588
+ "ministral-3-3b-2512": { inputPerMTok: 0.1, outputPerMTok: 0.1 },
589
+ "ministral-3-8b-2512": { inputPerMTok: 0.15, outputPerMTok: 0.15 },
590
+ "ministral-8b-2512": { inputPerMTok: 0.15, outputPerMTok: 0.15 },
591
+ "ministral-8b-latest": { inputPerMTok: 0.15, outputPerMTok: 0.15 },
592
+ "mistral-large-2402": { inputPerMTok: 4, outputPerMTok: 12 },
593
+ "mistral-large-2407": { inputPerMTok: 3, outputPerMTok: 9 },
594
+ "mistral-large-2411": { inputPerMTok: 2, outputPerMTok: 6 },
595
+ "mistral-large-2512": { inputPerMTok: 0.5, outputPerMTok: 1.5 },
596
+ "mistral-large-3": { inputPerMTok: 0.5, outputPerMTok: 1.5 },
597
+ "mistral-large-latest": { inputPerMTok: 0.5, outputPerMTok: 1.5 },
598
+ "mistral-large@2407": { inputPerMTok: 2, outputPerMTok: 6 },
599
+ "mistral-large@2411-001": { inputPerMTok: 2, outputPerMTok: 6 },
600
+ "mistral-large@latest": { inputPerMTok: 2, outputPerMTok: 6 },
601
+ "mistral-medium": { inputPerMTok: 2.7, outputPerMTok: 8.1 },
602
+ "mistral-medium-2312": { inputPerMTok: 2.7, outputPerMTok: 8.1 },
603
+ "mistral-medium-2505": { inputPerMTok: 0.4, outputPerMTok: 2 },
604
+ "mistral-medium-3": { inputPerMTok: 0.4, outputPerMTok: 2 },
605
+ "mistral-medium-3-1-2508": { inputPerMTok: 0.4, outputPerMTok: 2 },
606
+ "mistral-medium-3@001": { inputPerMTok: 0.4, outputPerMTok: 2 },
607
+ "mistral-medium-latest": { inputPerMTok: 0.4, outputPerMTok: 2 },
608
+ "mistral-nemo@2407": { inputPerMTok: 3, outputPerMTok: 3 },
609
+ "mistral-nemo@latest": { inputPerMTok: 0.15, outputPerMTok: 0.15 },
610
+ "mistral-small": { inputPerMTok: 0.1, outputPerMTok: 0.3 },
611
+ "mistral-small-2503": { inputPerMTok: 1, outputPerMTok: 3 },
612
+ "mistral-small-2503@001": { inputPerMTok: 1, outputPerMTok: 3 },
613
+ "mistral-small-3-2-2506": { inputPerMTok: 0.06, outputPerMTok: 0.18 },
614
+ "mistral-small-latest": { inputPerMTok: 0.06, outputPerMTok: 0.18 },
615
+ "mistral-tiny": { inputPerMTok: 0.25, outputPerMTok: 0.25 },
616
+ "mistral/codestral-2405": { inputPerMTok: 1, outputPerMTok: 3 },
617
+ "mistral/codestral-2508": { inputPerMTok: 0.3, outputPerMTok: 0.9 },
618
+ "mistral/codestral-latest": { inputPerMTok: 1, outputPerMTok: 3 },
619
+ "mistral/codestral-mamba-latest": { inputPerMTok: 0.25, outputPerMTok: 0.25 },
620
+ "mistral/devstral-2512": { inputPerMTok: 0.4, outputPerMTok: 2 },
621
+ "mistral/devstral-latest": { inputPerMTok: 0.4, outputPerMTok: 2 },
622
+ "mistral/devstral-medium-2507": { inputPerMTok: 0.4, outputPerMTok: 2 },
623
+ "mistral/devstral-medium-latest": { inputPerMTok: 0.4, outputPerMTok: 2 },
624
+ "mistral/devstral-small-2505": { inputPerMTok: 0.1, outputPerMTok: 0.3 },
625
+ "mistral/devstral-small-2507": { inputPerMTok: 0.1, outputPerMTok: 0.3 },
626
+ "mistral/devstral-small-latest": { inputPerMTok: 0.1, outputPerMTok: 0.3 },
627
+ "mistral/labs-devstral-small-2512": { inputPerMTok: 0.1, outputPerMTok: 0.3 },
628
+ "mistral/magistral-medium-1-2-2509": { inputPerMTok: 2, outputPerMTok: 5 },
629
+ "mistral/magistral-medium-2506": { inputPerMTok: 2, outputPerMTok: 5 },
630
+ "mistral/magistral-medium-2509": { inputPerMTok: 2, outputPerMTok: 5 },
631
+ "mistral/magistral-medium-latest": { inputPerMTok: 2, outputPerMTok: 5 },
632
+ "mistral/magistral-small-1-2-2509": { inputPerMTok: 0.5, outputPerMTok: 1.5 },
633
+ "mistral/magistral-small-2506": { inputPerMTok: 0.5, outputPerMTok: 1.5 },
634
+ "mistral/magistral-small-latest": { inputPerMTok: 0.5, outputPerMTok: 1.5 },
635
+ "mistral/ministral-3-14b-2512": { inputPerMTok: 0.2, outputPerMTok: 0.2 },
636
+ "mistral/ministral-3-3b-2512": { inputPerMTok: 0.1, outputPerMTok: 0.1 },
637
+ "mistral/ministral-3-8b-2512": { inputPerMTok: 0.15, outputPerMTok: 0.15 },
638
+ "mistral/ministral-8b-2512": { inputPerMTok: 0.15, outputPerMTok: 0.15 },
639
+ "mistral/ministral-8b-latest": { inputPerMTok: 0.15, outputPerMTok: 0.15 },
640
+ "mistral/mistral-large-2402": { inputPerMTok: 4, outputPerMTok: 12 },
641
+ "mistral/mistral-large-2407": { inputPerMTok: 3, outputPerMTok: 9 },
642
+ "mistral/mistral-large-2411": { inputPerMTok: 2, outputPerMTok: 6 },
643
+ "mistral/mistral-large-2512": { inputPerMTok: 0.5, outputPerMTok: 1.5 },
644
+ "mistral/mistral-large-3": { inputPerMTok: 0.5, outputPerMTok: 1.5 },
645
+ "mistral/mistral-large-latest": { inputPerMTok: 0.5, outputPerMTok: 1.5 },
646
+ "mistral/mistral-medium": { inputPerMTok: 2.7, outputPerMTok: 8.1 },
647
+ "mistral/mistral-medium-2312": { inputPerMTok: 2.7, outputPerMTok: 8.1 },
648
+ "mistral/mistral-medium-2505": { inputPerMTok: 0.4, outputPerMTok: 2 },
649
+ "mistral/mistral-medium-3-1-2508": { inputPerMTok: 0.4, outputPerMTok: 2 },
650
+ "mistral/mistral-medium-latest": { inputPerMTok: 0.4, outputPerMTok: 2 },
651
+ "mistral/mistral-small": { inputPerMTok: 0.1, outputPerMTok: 0.3 },
652
+ "mistral/mistral-small-3-2-2506": { inputPerMTok: 0.06, outputPerMTok: 0.18 },
653
+ "mistral/mistral-small-latest": { inputPerMTok: 0.06, outputPerMTok: 0.18 },
654
+ "mistral/mistral-tiny": { inputPerMTok: 0.25, outputPerMTok: 0.25 },
655
+ "mistral/open-codestral-mamba": { inputPerMTok: 0.25, outputPerMTok: 0.25 },
656
+ "mistral/open-mistral-7b": { inputPerMTok: 0.25, outputPerMTok: 0.25 },
657
+ "mistral/open-mistral-nemo": { inputPerMTok: 0.3, outputPerMTok: 0.3 },
658
+ "mistral/open-mistral-nemo-2407": { inputPerMTok: 0.3, outputPerMTok: 0.3 },
659
+ "mistral/open-mixtral-8x22b": { inputPerMTok: 2, outputPerMTok: 6 },
660
+ "mistral/open-mixtral-8x7b": { inputPerMTok: 0.7, outputPerMTok: 0.7 },
661
+ "mistral/pixtral-12b-2409": { inputPerMTok: 0.15, outputPerMTok: 0.15 },
662
+ "mistral/pixtral-large-2411": { inputPerMTok: 2, outputPerMTok: 6 },
663
+ "mistral/pixtral-large-latest": { inputPerMTok: 2, outputPerMTok: 6 },
664
+ "mistralai/codestral-2": { inputPerMTok: 0.3, outputPerMTok: 0.9 },
665
+ "mistralai/codestral-2@001": { inputPerMTok: 0.3, outputPerMTok: 0.9 },
666
+ "mistralai/mistral-medium-3": { inputPerMTok: 0.4, outputPerMTok: 2 },
667
+ "mistralai/mistral-medium-3@001": { inputPerMTok: 0.4, outputPerMTok: 2 },
668
+ "o1": { inputPerMTok: 15, outputPerMTok: 60, cachedInputPerMTok: 7.5 },
669
+ "o1-2024-12-17": { inputPerMTok: 15, outputPerMTok: 60, cachedInputPerMTok: 7.5 },
670
+ "o1-pro": { inputPerMTok: 150, outputPerMTok: 600 },
671
+ "o1-pro-2025-03-19": { inputPerMTok: 150, outputPerMTok: 600 },
672
+ "o3": { inputPerMTok: 2, outputPerMTok: 8, cachedInputPerMTok: 0.5 },
673
+ "o3-2025-04-16": { inputPerMTok: 2, outputPerMTok: 8, cachedInputPerMTok: 0.5 },
674
+ "o3-deep-research": { inputPerMTok: 10, outputPerMTok: 40, cachedInputPerMTok: 2.5 },
675
+ "o3-deep-research-2025-06-26": { inputPerMTok: 10, outputPerMTok: 40, cachedInputPerMTok: 2.5 },
676
+ "o3-mini": { inputPerMTok: 1.1, outputPerMTok: 4.4, cachedInputPerMTok: 0.55 },
677
+ "o3-mini-2025-01-31": { inputPerMTok: 1.1, outputPerMTok: 4.4, cachedInputPerMTok: 0.55 },
678
+ "o3-pro": { inputPerMTok: 20, outputPerMTok: 80 },
679
+ "o3-pro-2025-06-10": { inputPerMTok: 20, outputPerMTok: 80 },
680
+ "o4-mini": { inputPerMTok: 1.1, outputPerMTok: 4.4, cachedInputPerMTok: 0.275 },
681
+ "o4-mini-2025-04-16": { inputPerMTok: 1.1, outputPerMTok: 4.4, cachedInputPerMTok: 0.275 },
682
+ "o4-mini-deep-research": { inputPerMTok: 2, outputPerMTok: 8, cachedInputPerMTok: 0.5 },
683
+ "o4-mini-deep-research-2025-06-26": { inputPerMTok: 2, outputPerMTok: 8, cachedInputPerMTok: 0.5 },
684
+ "omni-moderation-2024-09-26": { inputPerMTok: 0, outputPerMTok: 0 },
685
+ "omni-moderation-latest": { inputPerMTok: 0, outputPerMTok: 0 },
686
+ "open-codestral-mamba": { inputPerMTok: 0.25, outputPerMTok: 0.25 },
687
+ "open-mistral-7b": { inputPerMTok: 0.25, outputPerMTok: 0.25 },
688
+ "open-mistral-nemo": { inputPerMTok: 0.3, outputPerMTok: 0.3 },
689
+ "open-mistral-nemo-2407": { inputPerMTok: 0.3, outputPerMTok: 0.3 },
690
+ "open-mixtral-8x22b": { inputPerMTok: 2, outputPerMTok: 6 },
691
+ "open-mixtral-8x7b": { inputPerMTok: 0.7, outputPerMTok: 0.7 },
692
+ "pixtral-12b-2409": { inputPerMTok: 0.15, outputPerMTok: 0.15 },
693
+ "pixtral-large-2411": { inputPerMTok: 2, outputPerMTok: 6 },
694
+ "pixtral-large-latest": { inputPerMTok: 2, outputPerMTok: 6 },
695
+ "rerank-english-v2.0": { inputPerMTok: 0, outputPerMTok: 0 },
696
+ "rerank-english-v3.0": { inputPerMTok: 0, outputPerMTok: 0 },
697
+ "rerank-multilingual-v2.0": { inputPerMTok: 0, outputPerMTok: 0 },
698
+ "rerank-multilingual-v3.0": { inputPerMTok: 0, outputPerMTok: 0 },
699
+ "rerank-v3.5": { inputPerMTok: 0, outputPerMTok: 0 },
700
+ "text-embedding-3-large": { inputPerMTok: 0.13, outputPerMTok: 0 },
701
+ "text-embedding-3-small": { inputPerMTok: 0.02, outputPerMTok: 0 },
702
+ "text-embedding-ada-002": { inputPerMTok: 0.1, outputPerMTok: 0 },
703
+ "text-embedding-ada-002-v2": { inputPerMTok: 0.1, outputPerMTok: 0 },
704
+ "text-moderation-007": { inputPerMTok: 0, outputPerMTok: 0 },
705
+ "text-moderation-latest": { inputPerMTok: 0, outputPerMTok: 0 },
706
+ "text-moderation-stable": { inputPerMTok: 0, outputPerMTok: 0 },
707
+ "vertex_ai/claude-3-5-haiku": { inputPerMTok: 1, outputPerMTok: 5 },
708
+ "vertex_ai/claude-3-5-haiku@20241022": { inputPerMTok: 1, outputPerMTok: 5 },
709
+ "vertex_ai/claude-3-5-sonnet": { inputPerMTok: 3, outputPerMTok: 15 },
710
+ "vertex_ai/claude-3-5-sonnet@20240620": { inputPerMTok: 3, outputPerMTok: 15 },
711
+ "vertex_ai/claude-3-7-sonnet@20250219": { inputPerMTok: 3, outputPerMTok: 15, cachedInputPerMTok: 0.3 },
712
+ "vertex_ai/claude-3-haiku": { inputPerMTok: 0.25, outputPerMTok: 1.25 },
713
+ "vertex_ai/claude-3-haiku@20240307": { inputPerMTok: 0.25, outputPerMTok: 1.25 },
714
+ "vertex_ai/claude-3-opus": { inputPerMTok: 15, outputPerMTok: 75 },
715
+ "vertex_ai/claude-3-opus@20240229": { inputPerMTok: 15, outputPerMTok: 75 },
716
+ "vertex_ai/claude-3-sonnet": { inputPerMTok: 3, outputPerMTok: 15 },
717
+ "vertex_ai/claude-3-sonnet@20240229": { inputPerMTok: 3, outputPerMTok: 15 },
718
+ "vertex_ai/claude-haiku-4-5": { inputPerMTok: 1, outputPerMTok: 5, cachedInputPerMTok: 0.1 },
719
+ "vertex_ai/claude-haiku-4-5@20251001": { inputPerMTok: 1, outputPerMTok: 5, cachedInputPerMTok: 0.1 },
720
+ "vertex_ai/claude-opus-4": { inputPerMTok: 15, outputPerMTok: 75, cachedInputPerMTok: 1.5 },
721
+ "vertex_ai/claude-opus-4-1": { inputPerMTok: 15, outputPerMTok: 75, cachedInputPerMTok: 1.5 },
722
+ "vertex_ai/claude-opus-4-1@20250805": { inputPerMTok: 15, outputPerMTok: 75, cachedInputPerMTok: 1.5 },
723
+ "vertex_ai/claude-opus-4-5": { inputPerMTok: 5, outputPerMTok: 25, cachedInputPerMTok: 0.5 },
724
+ "vertex_ai/claude-opus-4-5@20251101": { inputPerMTok: 5, outputPerMTok: 25, cachedInputPerMTok: 0.5 },
725
+ "vertex_ai/claude-opus-4-6": { inputPerMTok: 5, outputPerMTok: 25, cachedInputPerMTok: 0.5 },
726
+ "vertex_ai/claude-opus-4-6@default": { inputPerMTok: 5, outputPerMTok: 25, cachedInputPerMTok: 0.5 },
727
+ "vertex_ai/claude-opus-4-7": { inputPerMTok: 5, outputPerMTok: 25, cachedInputPerMTok: 0.5 },
728
+ "vertex_ai/claude-opus-4-7@default": { inputPerMTok: 5, outputPerMTok: 25, cachedInputPerMTok: 0.5 },
729
+ "vertex_ai/claude-opus-4-8": { inputPerMTok: 5, outputPerMTok: 25, cachedInputPerMTok: 0.5 },
730
+ "vertex_ai/claude-opus-4-8@default": { inputPerMTok: 5, outputPerMTok: 25, cachedInputPerMTok: 0.5 },
731
+ "vertex_ai/claude-opus-4@20250514": { inputPerMTok: 15, outputPerMTok: 75, cachedInputPerMTok: 1.5 },
732
+ "vertex_ai/claude-sonnet-4": { inputPerMTok: 3, outputPerMTok: 15, cachedInputPerMTok: 0.3 },
733
+ "vertex_ai/claude-sonnet-4-5": { inputPerMTok: 3, outputPerMTok: 15, cachedInputPerMTok: 0.3 },
734
+ "vertex_ai/claude-sonnet-4-5@20250929": { inputPerMTok: 3, outputPerMTok: 15, cachedInputPerMTok: 0.3 },
735
+ "vertex_ai/claude-sonnet-4-6": { inputPerMTok: 3, outputPerMTok: 15, cachedInputPerMTok: 0.3 },
736
+ "vertex_ai/claude-sonnet-4-6@default": { inputPerMTok: 3, outputPerMTok: 15, cachedInputPerMTok: 0.3 },
737
+ "vertex_ai/claude-sonnet-4@20250514": { inputPerMTok: 3, outputPerMTok: 15, cachedInputPerMTok: 0.3 },
738
+ "vertex_ai/codestral-2": { inputPerMTok: 0.3, outputPerMTok: 0.9 },
739
+ "vertex_ai/codestral-2501": { inputPerMTok: 0.2, outputPerMTok: 0.6 },
740
+ "vertex_ai/codestral-2@001": { inputPerMTok: 0.3, outputPerMTok: 0.9 },
741
+ "vertex_ai/codestral@2405": { inputPerMTok: 0.2, outputPerMTok: 0.6 },
742
+ "vertex_ai/codestral@latest": { inputPerMTok: 0.2, outputPerMTok: 0.6 },
743
+ "vertex_ai/deep-research-pro-preview-12-2025": { inputPerMTok: 2, outputPerMTok: 12 },
744
+ "vertex_ai/gemini-2.5-flash-image": { inputPerMTok: 0.3, outputPerMTok: 2.5, cachedInputPerMTok: 0.03 },
745
+ "vertex_ai/gemini-3-pro-image-preview": { inputPerMTok: 2, outputPerMTok: 12 },
746
+ "vertex_ai/gemini-3.1-flash-image-preview": { inputPerMTok: 0.5, outputPerMTok: 3 },
747
+ "vertex_ai/gemini-3.1-flash-lite": { inputPerMTok: 0.25, outputPerMTok: 1.5, cachedInputPerMTok: 0.025 },
748
+ "vertex_ai/gemini-3.1-flash-lite-preview": { inputPerMTok: 0.25, outputPerMTok: 1.5, cachedInputPerMTok: 0.025 },
749
+ "vertex_ai/mistral-large-2411": { inputPerMTok: 2, outputPerMTok: 6 },
750
+ "vertex_ai/mistral-large@2407": { inputPerMTok: 2, outputPerMTok: 6 },
751
+ "vertex_ai/mistral-large@2411-001": { inputPerMTok: 2, outputPerMTok: 6 },
752
+ "vertex_ai/mistral-large@latest": { inputPerMTok: 2, outputPerMTok: 6 },
753
+ "vertex_ai/mistral-medium-3": { inputPerMTok: 0.4, outputPerMTok: 2 },
754
+ "vertex_ai/mistral-medium-3@001": { inputPerMTok: 0.4, outputPerMTok: 2 },
755
+ "vertex_ai/mistral-nemo@2407": { inputPerMTok: 3, outputPerMTok: 3 },
756
+ "vertex_ai/mistral-nemo@latest": { inputPerMTok: 0.15, outputPerMTok: 0.15 },
757
+ "vertex_ai/mistral-small-2503": { inputPerMTok: 1, outputPerMTok: 3 },
758
+ "vertex_ai/mistral-small-2503@001": { inputPerMTok: 1, outputPerMTok: 3 },
759
+ "vertex_ai/mistralai/codestral-2": { inputPerMTok: 0.3, outputPerMTok: 0.9 },
760
+ "vertex_ai/mistralai/codestral-2@001": { inputPerMTok: 0.3, outputPerMTok: 0.9 },
761
+ "vertex_ai/mistralai/mistral-medium-3": { inputPerMTok: 0.4, outputPerMTok: 2 },
762
+ "vertex_ai/mistralai/mistral-medium-3@001": { inputPerMTok: 0.4, outputPerMTok: 2 },
763
+ "xai/grok-2": { inputPerMTok: 2, outputPerMTok: 10 },
764
+ "xai/grok-2-1212": { inputPerMTok: 2, outputPerMTok: 10 },
765
+ "xai/grok-2-latest": { inputPerMTok: 2, outputPerMTok: 10 },
766
+ "xai/grok-2-vision": { inputPerMTok: 2, outputPerMTok: 10 },
767
+ "xai/grok-2-vision-1212": { inputPerMTok: 2, outputPerMTok: 10 },
768
+ "xai/grok-2-vision-latest": { inputPerMTok: 2, outputPerMTok: 10 },
769
+ "xai/grok-3": { inputPerMTok: 3, outputPerMTok: 15, cachedInputPerMTok: 0.75 },
770
+ "xai/grok-3-beta": { inputPerMTok: 3, outputPerMTok: 15, cachedInputPerMTok: 0.75 },
771
+ "xai/grok-3-fast-beta": { inputPerMTok: 5, outputPerMTok: 25, cachedInputPerMTok: 1.25 },
772
+ "xai/grok-3-fast-latest": { inputPerMTok: 5, outputPerMTok: 25, cachedInputPerMTok: 1.25 },
773
+ "xai/grok-3-latest": { inputPerMTok: 3, outputPerMTok: 15, cachedInputPerMTok: 0.75 },
774
+ "xai/grok-3-mini": { inputPerMTok: 0.3, outputPerMTok: 0.5, cachedInputPerMTok: 0.075 },
775
+ "xai/grok-3-mini-beta": { inputPerMTok: 0.3, outputPerMTok: 0.5, cachedInputPerMTok: 0.075 },
776
+ "xai/grok-3-mini-fast": { inputPerMTok: 0.6, outputPerMTok: 4, cachedInputPerMTok: 0.15 },
777
+ "xai/grok-3-mini-fast-beta": { inputPerMTok: 0.6, outputPerMTok: 4, cachedInputPerMTok: 0.15 },
778
+ "xai/grok-3-mini-fast-latest": { inputPerMTok: 0.6, outputPerMTok: 4, cachedInputPerMTok: 0.15 },
779
+ "xai/grok-3-mini-latest": { inputPerMTok: 0.3, outputPerMTok: 0.5, cachedInputPerMTok: 0.075 },
780
+ "xai/grok-4": { inputPerMTok: 3, outputPerMTok: 15 },
781
+ "xai/grok-4-0709": { inputPerMTok: 3, outputPerMTok: 15 },
782
+ "xai/grok-4-1-fast": { inputPerMTok: 0.2, outputPerMTok: 0.5, cachedInputPerMTok: 0.05 },
783
+ "xai/grok-4-1-fast-non-reasoning": { inputPerMTok: 0.2, outputPerMTok: 0.5, cachedInputPerMTok: 0.05 },
784
+ "xai/grok-4-1-fast-non-reasoning-latest": { inputPerMTok: 0.2, outputPerMTok: 0.5, cachedInputPerMTok: 0.05 },
785
+ "xai/grok-4-1-fast-reasoning": { inputPerMTok: 0.2, outputPerMTok: 0.5, cachedInputPerMTok: 0.05 },
786
+ "xai/grok-4-1-fast-reasoning-latest": { inputPerMTok: 0.2, outputPerMTok: 0.5, cachedInputPerMTok: 0.05 },
787
+ "xai/grok-4-fast-non-reasoning": { inputPerMTok: 0.2, outputPerMTok: 0.5, cachedInputPerMTok: 0.05 },
788
+ "xai/grok-4-fast-reasoning": { inputPerMTok: 0.2, outputPerMTok: 0.5, cachedInputPerMTok: 0.05 },
789
+ "xai/grok-4-latest": { inputPerMTok: 3, outputPerMTok: 15 },
790
+ "xai/grok-4.20-0309-reasoning": { inputPerMTok: 2, outputPerMTok: 6, cachedInputPerMTok: 0.2 },
791
+ "xai/grok-4.20-beta-0309-non-reasoning": { inputPerMTok: 2, outputPerMTok: 6, cachedInputPerMTok: 0.2 },
792
+ "xai/grok-4.20-beta-0309-reasoning": { inputPerMTok: 2, outputPerMTok: 6, cachedInputPerMTok: 0.2 },
793
+ "xai/grok-4.20-multi-agent-beta-0309": { inputPerMTok: 2, outputPerMTok: 6, cachedInputPerMTok: 0.2 },
794
+ "xai/grok-4.3": { inputPerMTok: 1.25, outputPerMTok: 2.5, cachedInputPerMTok: 0.2 },
795
+ "xai/grok-4.3-latest": { inputPerMTok: 1.25, outputPerMTok: 2.5, cachedInputPerMTok: 0.2 },
796
+ "xai/grok-beta": { inputPerMTok: 5, outputPerMTok: 15 },
797
+ "xai/grok-code-fast": { inputPerMTok: 0.2, outputPerMTok: 1.5, cachedInputPerMTok: 0.02 },
798
+ "xai/grok-code-fast-1": { inputPerMTok: 0.2, outputPerMTok: 1.5, cachedInputPerMTok: 0.02 },
799
+ "xai/grok-code-fast-1-0825": { inputPerMTok: 0.2, outputPerMTok: 1.5, cachedInputPerMTok: 0.02 },
800
+ "xai/grok-vision-beta": { inputPerMTok: 5, outputPerMTok: 15 }
801
+ };
802
+
803
+ // src/fetch-prices.ts
804
+ var LITELLM_URL = "https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json";
805
+ var TARGET_PROVIDERS = /* @__PURE__ */ new Set([
806
+ "anthropic",
807
+ "openai",
808
+ "gemini",
809
+ "deepseek",
810
+ "mistral",
811
+ "xai",
812
+ "cohere",
813
+ "vertex_ai-anthropic_models",
814
+ "vertex_ai-language-models",
815
+ "vertex_ai-mistral_models"
816
+ ]);
817
+ var STRIP_PREFIXES = [
818
+ "gemini/",
819
+ "vertex_ai/",
820
+ "anthropic/",
821
+ "openai/",
822
+ "xai/",
823
+ "cohere/",
824
+ "mistral/",
825
+ "deepseek/"
826
+ ];
827
+ function roundPrice(v) {
828
+ if (v === 0) return 0;
829
+ const mag = Math.floor(Math.log10(Math.abs(v)));
830
+ const factor = Math.pow(10, 5 - mag);
831
+ return Math.round(v * factor) / factor;
832
+ }
833
+ function mapLiteLLM(raw) {
834
+ const out = {};
835
+ for (const [key, val] of Object.entries(raw)) {
836
+ if (!val || typeof val !== "object") continue;
837
+ const entry = val;
838
+ const prov = entry.litellm_provider ?? "";
839
+ if (!TARGET_PROVIDERS.has(prov)) continue;
840
+ const inputCost = entry.input_cost_per_token;
841
+ const outputCost = entry.output_cost_per_token;
842
+ if (inputCost == null || outputCost == null) continue;
843
+ const priceEntry = {
844
+ inputPerMTok: roundPrice(inputCost * 1e6),
845
+ outputPerMTok: roundPrice(outputCost * 1e6)
846
+ };
847
+ if (entry.cache_read_input_token_cost != null) {
848
+ priceEntry.cachedInputPerMTok = roundPrice(entry.cache_read_input_token_cost * 1e6);
849
+ }
850
+ out[key] = priceEntry;
851
+ for (const prefix of STRIP_PREFIXES) {
852
+ if (key.startsWith(prefix)) {
853
+ const bare = key.slice(prefix.length);
854
+ if (!(bare in out)) out[bare] = priceEntry;
855
+ break;
856
+ }
857
+ }
858
+ }
859
+ return out;
860
+ }
861
+ async function fetchLatestPrices(opts) {
862
+ const fetchFn = opts?.fetchImpl ?? fetch;
863
+ const url = opts?.url ?? LITELLM_URL;
864
+ let res;
865
+ try {
866
+ res = await fetchFn(url);
867
+ } catch (e) {
868
+ throw new Error(
869
+ `fetchLatestPrices: network request to ${url} failed \u2014 ${e instanceof Error ? e.message : String(e)}`
870
+ );
871
+ }
872
+ if (!res.ok) {
873
+ throw new Error(`fetchLatestPrices: HTTP ${res.status} ${res.statusText} from ${url}`);
874
+ }
875
+ let raw;
876
+ try {
877
+ raw = await res.json();
878
+ } catch (e) {
879
+ throw new Error(
880
+ `fetchLatestPrices: failed to parse JSON from ${url} \u2014 ${e instanceof Error ? e.message : String(e)}`
881
+ );
882
+ }
883
+ return mapLiteLLM(raw);
884
+ }
885
+
886
+ // src/ollama.ts
887
+ import { createRequire } from "node:module";
888
+ function loadOllamaModule() {
889
+ const req = typeof __require === "function" ? __require : createRequire(import.meta.url);
890
+ try {
891
+ return req("ollama-ai-provider");
892
+ } catch {
893
+ throw new Error(
894
+ "[eidentic/model] createOllamaModel requires the `ollama-ai-provider` package.\nInstall it in your project:\n npm install ollama-ai-provider\n # or\n pnpm add ollama-ai-provider"
895
+ );
896
+ }
897
+ }
898
+ function createOllamaModel(modelId, opts) {
899
+ const mod = opts?._factory ?? loadOllamaModule();
900
+ const provider = mod.createOllama(opts?.baseURL ? { baseURL: opts.baseURL } : void 0);
901
+ return provider(modelId);
902
+ }
903
+
904
+ // src/fallback.ts
905
+ function isAbortError(err) {
906
+ if (err instanceof DOMException && err.name === "AbortError") return true;
907
+ if (err instanceof Error && err.name === "AbortError") return true;
908
+ return false;
909
+ }
910
+ function shouldTryNext(err, opts) {
911
+ if (isAbortError(err)) return false;
912
+ if (opts?.shouldFallback) return opts.shouldFallback(err);
913
+ return true;
914
+ }
915
+ function withFallback(primary, fallbacks, opts) {
916
+ const chain = [primary, ...fallbacks];
917
+ return {
918
+ // Expose the primary's modelId so AgentConfig can read it.
919
+ get modelId() {
920
+ return primary.modelId;
921
+ },
922
+ async complete(request) {
923
+ let lastErr;
924
+ for (let i = 0; i < chain.length; i++) {
925
+ try {
926
+ return await chain[i].complete(request);
927
+ } catch (err) {
928
+ lastErr = err;
929
+ if (i < chain.length - 1 && shouldTryNext(err, opts)) {
930
+ opts?.onFallback?.(err, i, i + 1);
931
+ continue;
932
+ }
933
+ throw err;
934
+ }
935
+ }
936
+ throw lastErr;
937
+ },
938
+ async *stream(request) {
939
+ let lastErr;
940
+ for (let i = 0; i < chain.length; i++) {
941
+ const model = chain[i];
942
+ const streamFn = model.stream?.bind(model);
943
+ if (!streamFn) {
944
+ lastErr = new Error(`model at index ${i} does not implement stream()`);
945
+ if (i < chain.length - 1 && shouldTryNext(lastErr, opts)) {
946
+ opts?.onFallback?.(lastErr, i, i + 1);
947
+ continue;
948
+ }
949
+ throw lastErr;
950
+ }
951
+ let deltasSeen = 0;
952
+ try {
953
+ for await (const part of streamFn(request)) {
954
+ if (part.type === "delta") deltasSeen++;
955
+ yield part;
956
+ }
957
+ return;
958
+ } catch (err) {
959
+ lastErr = err;
960
+ if (deltasSeen > 0) throw err;
961
+ if (i < chain.length - 1 && shouldTryNext(err, opts)) {
962
+ opts?.onFallback?.(err, i, i + 1);
963
+ continue;
964
+ }
965
+ throw err;
966
+ }
967
+ }
968
+ throw lastErr;
969
+ }
970
+ };
971
+ }
972
+
973
+ // src/route.ts
974
+ function estimateTokens(req) {
975
+ let chars = 0;
976
+ for (const msg of req.messages) {
977
+ if (typeof msg.content === "string") {
978
+ chars += msg.content.length;
979
+ } else {
980
+ for (const block of msg.content) {
981
+ if ("text" in block && typeof block.text === "string") chars += block.text.length;
982
+ }
983
+ }
984
+ }
985
+ return Math.ceil(chars / 4);
986
+ }
987
+ function byTokenEstimate(thresholds, fallbackTier) {
988
+ const sorted = [...thresholds].sort((a, b) => a.upTo - b.upTo);
989
+ return (req) => {
990
+ const tokens = estimateTokens(req);
991
+ for (const t of sorted) {
992
+ if (tokens <= t.upTo) return t.tier;
993
+ }
994
+ return fallbackTier;
995
+ };
996
+ }
997
+ function routeModel(selector, tiers) {
998
+ function resolve(req) {
999
+ const tier = selector(req);
1000
+ const model = tiers[tier];
1001
+ if (!model) {
1002
+ const known = Object.keys(tiers).join(", ");
1003
+ throw new Error(
1004
+ `routeModel: unknown tier "${tier}". Known tiers: ${known || "(none)"}`
1005
+ );
1006
+ }
1007
+ return model;
1008
+ }
1009
+ return {
1010
+ get modelId() {
1011
+ return void 0;
1012
+ },
1013
+ async complete(request) {
1014
+ return resolve(request).complete(request);
1015
+ },
1016
+ async *stream(request) {
1017
+ const model = resolve(request);
1018
+ if (!model.stream) {
1019
+ throw new Error(
1020
+ `routeModel: resolved model for tier does not implement stream()`
1021
+ );
1022
+ }
1023
+ yield* model.stream(request);
1024
+ }
1025
+ };
1026
+ }
1027
+
1028
+ // src/cache.ts
1029
+ function stableJson(value) {
1030
+ if (value === null || typeof value !== "object") return JSON.stringify(value);
1031
+ if (Array.isArray(value)) return `[${value.map(stableJson).join(",")}]`;
1032
+ const sorted = Object.keys(value).sort();
1033
+ return `{${sorted.map((k) => `${JSON.stringify(k)}:${stableJson(value[k])}`).join(",")}}`;
1034
+ }
1035
+ function defaultKeyFn(req) {
1036
+ return stableJson({
1037
+ messages: req.messages,
1038
+ tools: req.tools,
1039
+ model: req.model ?? null,
1040
+ outputSchema: req.outputSchema ?? null
1041
+ });
1042
+ }
1043
+ var LRUCache = class {
1044
+ constructor(maxEntries) {
1045
+ this.maxEntries = maxEntries;
1046
+ }
1047
+ maxEntries;
1048
+ map = /* @__PURE__ */ new Map();
1049
+ get(key) {
1050
+ const entry = this.map.get(key);
1051
+ if (!entry) return void 0;
1052
+ this.map.delete(key);
1053
+ this.map.set(key, entry);
1054
+ return entry;
1055
+ }
1056
+ set(key, entry) {
1057
+ if (this.map.has(key)) this.map.delete(key);
1058
+ this.map.set(key, entry);
1059
+ if (this.map.size > this.maxEntries) {
1060
+ const oldest = this.map.keys().next().value;
1061
+ if (oldest !== void 0) this.map.delete(oldest);
1062
+ }
1063
+ }
1064
+ get size() {
1065
+ return this.map.size;
1066
+ }
1067
+ };
1068
+ function cachedModel(model, opts = {}) {
1069
+ const ttlMs = opts.ttlMs ?? 5 * 6e4;
1070
+ const maxEntries = opts.maxEntries ?? 500;
1071
+ const keyFn = opts.keyFn ?? defaultKeyFn;
1072
+ const shouldCache = opts.shouldCache ?? (() => true);
1073
+ const clock = opts.clock ?? Date.now;
1074
+ const lru = new LRUCache(maxEntries);
1075
+ let hits = 0;
1076
+ let misses = 0;
1077
+ async function getFromCache(key) {
1078
+ const now = clock();
1079
+ const local = lru.get(key);
1080
+ if (local) {
1081
+ if (local.expiresAt > now) return local.value;
1082
+ }
1083
+ if (opts.store) {
1084
+ const stored = await opts.store.get(key);
1085
+ if (stored !== void 0) {
1086
+ lru.set(key, { value: stored, expiresAt: now + ttlMs });
1087
+ return stored;
1088
+ }
1089
+ }
1090
+ return void 0;
1091
+ }
1092
+ async function setInCache(key, value) {
1093
+ const expiresAt = ttlMs === Infinity ? Infinity : clock() + ttlMs;
1094
+ lru.set(key, { value, expiresAt });
1095
+ if (opts.store) {
1096
+ await opts.store.set(key, value, ttlMs === Infinity ? void 0 : ttlMs);
1097
+ }
1098
+ }
1099
+ const port = {
1100
+ get modelId() {
1101
+ return model.modelId;
1102
+ },
1103
+ async complete(request) {
1104
+ const key = keyFn(request);
1105
+ const cached = await getFromCache(key);
1106
+ if (cached !== void 0) {
1107
+ hits++;
1108
+ opts.onCacheHit?.(key, cached);
1109
+ return cached;
1110
+ }
1111
+ misses++;
1112
+ const result = await model.complete(request);
1113
+ if (shouldCache(request, result)) {
1114
+ await setInCache(key, result);
1115
+ }
1116
+ return result;
1117
+ },
1118
+ async *stream(request) {
1119
+ if (!model.stream) {
1120
+ throw new Error("cachedModel: wrapped model does not implement stream()");
1121
+ }
1122
+ yield* model.stream(request);
1123
+ },
1124
+ stats() {
1125
+ return { hits, misses, size: lru.size };
1126
+ }
1127
+ };
1128
+ return port;
1129
+ }
1130
+ export {
1131
+ AIEmbedder,
1132
+ AIModel,
1133
+ LITELLM_URL,
1134
+ byTokenEstimate,
1135
+ cachedModel,
1136
+ createOllamaModel,
1137
+ defaultPrices,
1138
+ fetchLatestPrices,
1139
+ mapLiteLLM,
1140
+ pricesUpdatedAt,
1141
+ routeModel,
1142
+ withFallback
1143
+ };