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