@discomedia/utils 1.0.67 → 1.0.68
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-frontend.cjs +63 -266
- package/dist/index-frontend.cjs.map +1 -1
- package/dist/index-frontend.mjs +63 -266
- package/dist/index-frontend.mjs.map +1 -1
- package/dist/index.cjs +63 -266
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +63 -266
- package/dist/index.mjs.map +1 -1
- package/dist/package.json +4 -4
- package/dist/test.js +615 -3408
- package/dist/test.js.map +1 -1
- package/dist/types/llm-config.d.ts +1 -1
- package/dist/types/llm-config.d.ts.map +1 -1
- package/dist/types/llm-images.d.ts.map +1 -1
- package/dist/types/llm-openai.d.ts.map +1 -1
- package/dist/types/types/llm-types.d.ts +2 -2
- package/dist/types/types/llm-types.d.ts.map +1 -1
- package/dist/types-frontend/llm-config.d.ts +1 -1
- package/dist/types-frontend/llm-config.d.ts.map +1 -1
- package/dist/types-frontend/llm-images.d.ts.map +1 -1
- package/dist/types-frontend/llm-openai.d.ts.map +1 -1
- package/dist/types-frontend/types/llm-types.d.ts +2 -2
- package/dist/types-frontend/types/llm-types.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -1153,6 +1153,8 @@ function isOpenRouterModel(model) {
|
|
|
1153
1153
|
'openai/gpt-5.1',
|
|
1154
1154
|
'openai/gpt-5.4',
|
|
1155
1155
|
'openai/gpt-5.4-pro',
|
|
1156
|
+
'openai/gpt-5.5',
|
|
1157
|
+
'openai/gpt-5.5-pro',
|
|
1156
1158
|
'openai/gpt-5.2',
|
|
1157
1159
|
'openai/gpt-5.2-pro',
|
|
1158
1160
|
'openai/gpt-5.1-codex',
|
|
@@ -1648,7 +1650,7 @@ const safeJSON = (text) => {
|
|
|
1648
1650
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
1649
1651
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
1650
1652
|
|
|
1651
|
-
const VERSION = '6.
|
|
1653
|
+
const VERSION = '6.35.0'; // x-release-please-version
|
|
1652
1654
|
|
|
1653
1655
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
1654
1656
|
const isRunningInBrowser = () => {
|
|
@@ -4976,8 +4978,8 @@ class Speech extends APIResource {
|
|
|
4976
4978
|
* ```ts
|
|
4977
4979
|
* const speech = await client.audio.speech.create({
|
|
4978
4980
|
* input: 'input',
|
|
4979
|
-
* model: '
|
|
4980
|
-
* voice: '
|
|
4981
|
+
* model: 'tts-1',
|
|
4982
|
+
* voice: 'alloy',
|
|
4981
4983
|
* });
|
|
4982
4984
|
*
|
|
4983
4985
|
* const content = await speech.blob();
|
|
@@ -5455,10 +5457,10 @@ const toFloat32Array = (base64Str) => {
|
|
|
5455
5457
|
*/
|
|
5456
5458
|
const readEnv = (env) => {
|
|
5457
5459
|
if (typeof globalThis.process !== 'undefined') {
|
|
5458
|
-
return globalThis.process.env?.[env]?.trim()
|
|
5460
|
+
return globalThis.process.env?.[env]?.trim() || undefined;
|
|
5459
5461
|
}
|
|
5460
5462
|
if (typeof globalThis.Deno !== 'undefined') {
|
|
5461
|
-
return globalThis.Deno.env?.get?.(env)?.trim();
|
|
5463
|
+
return globalThis.Deno.env?.get?.(env)?.trim() || undefined;
|
|
5462
5464
|
}
|
|
5463
5465
|
return undefined;
|
|
5464
5466
|
};
|
|
@@ -9044,7 +9046,6 @@ OpenAI.Containers = Containers;
|
|
|
9044
9046
|
OpenAI.Skills = Skills;
|
|
9045
9047
|
OpenAI.Videos = Videos;
|
|
9046
9048
|
|
|
9047
|
-
// functions
|
|
9048
9049
|
function getEnumValues(entries) {
|
|
9049
9050
|
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
9050
9051
|
const values = Object.entries(entries)
|
|
@@ -9190,7 +9191,7 @@ function process$1(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
|
9190
9191
|
delete result.schema.default;
|
|
9191
9192
|
}
|
|
9192
9193
|
// set prefault as default
|
|
9193
|
-
if (ctx.io === "input" && result.schema
|
|
9194
|
+
if (ctx.io === "input" && "_prefault" in result.schema)
|
|
9194
9195
|
(_a = result.schema).default ?? (_a.default = result.schema._prefault);
|
|
9195
9196
|
delete result.schema._prefault;
|
|
9196
9197
|
// pulling fresh from ctx.seen in case it was overwritten
|
|
@@ -9418,11 +9419,20 @@ function finalize(ctx, schema) {
|
|
|
9418
9419
|
result.$id = ctx.external.uri(id);
|
|
9419
9420
|
}
|
|
9420
9421
|
Object.assign(result, root.def ?? root.schema);
|
|
9422
|
+
// The `id` in `.meta()` is a Zod-specific registration tag used to extract
|
|
9423
|
+
// schemas into $defs — it is not user-facing JSON Schema metadata. Strip it
|
|
9424
|
+
// from the output body where it would otherwise leak. The id is preserved
|
|
9425
|
+
// implicitly via the $defs key (and via $ref paths).
|
|
9426
|
+
const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
|
|
9427
|
+
if (rootMetaId !== undefined && result.id === rootMetaId)
|
|
9428
|
+
delete result.id;
|
|
9421
9429
|
// build defs object
|
|
9422
9430
|
const defs = ctx.external?.defs ?? {};
|
|
9423
9431
|
for (const entry of ctx.seen.entries()) {
|
|
9424
9432
|
const seen = entry[1];
|
|
9425
9433
|
if (seen.def && seen.defId) {
|
|
9434
|
+
if (seen.def.id === seen.defId)
|
|
9435
|
+
delete seen.def.id;
|
|
9426
9436
|
defs[seen.defId] = seen.def;
|
|
9427
9437
|
}
|
|
9428
9438
|
}
|
|
@@ -9490,6 +9500,8 @@ function isTransforming(_schema, _ctx) {
|
|
|
9490
9500
|
return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
|
|
9491
9501
|
}
|
|
9492
9502
|
if (def.type === "pipe") {
|
|
9503
|
+
if (_schema._zod.traits.has("$ZodCodec"))
|
|
9504
|
+
return true;
|
|
9493
9505
|
return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
|
|
9494
9506
|
}
|
|
9495
9507
|
if (def.type === "object") {
|
|
@@ -9578,8 +9590,12 @@ const numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
9578
9590
|
json.type = "integer";
|
|
9579
9591
|
else
|
|
9580
9592
|
json.type = "number";
|
|
9581
|
-
|
|
9582
|
-
|
|
9593
|
+
// when both minimum and exclusiveMinimum exist, pick the more restrictive one
|
|
9594
|
+
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
9595
|
+
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
9596
|
+
const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
|
|
9597
|
+
if (exMin) {
|
|
9598
|
+
if (legacy) {
|
|
9583
9599
|
json.minimum = exclusiveMinimum;
|
|
9584
9600
|
json.exclusiveMinimum = true;
|
|
9585
9601
|
}
|
|
@@ -9587,17 +9603,11 @@ const numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
9587
9603
|
json.exclusiveMinimum = exclusiveMinimum;
|
|
9588
9604
|
}
|
|
9589
9605
|
}
|
|
9590
|
-
if (typeof minimum === "number") {
|
|
9606
|
+
else if (typeof minimum === "number") {
|
|
9591
9607
|
json.minimum = minimum;
|
|
9592
|
-
if (typeof exclusiveMinimum === "number" && ctx.target !== "draft-04") {
|
|
9593
|
-
if (exclusiveMinimum >= minimum)
|
|
9594
|
-
delete json.minimum;
|
|
9595
|
-
else
|
|
9596
|
-
delete json.exclusiveMinimum;
|
|
9597
|
-
}
|
|
9598
9608
|
}
|
|
9599
|
-
if (
|
|
9600
|
-
if (
|
|
9609
|
+
if (exMax) {
|
|
9610
|
+
if (legacy) {
|
|
9601
9611
|
json.maximum = exclusiveMaximum;
|
|
9602
9612
|
json.exclusiveMaximum = true;
|
|
9603
9613
|
}
|
|
@@ -9605,14 +9615,8 @@ const numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
9605
9615
|
json.exclusiveMaximum = exclusiveMaximum;
|
|
9606
9616
|
}
|
|
9607
9617
|
}
|
|
9608
|
-
if (typeof maximum === "number") {
|
|
9618
|
+
else if (typeof maximum === "number") {
|
|
9609
9619
|
json.maximum = maximum;
|
|
9610
|
-
if (typeof exclusiveMaximum === "number" && ctx.target !== "draft-04") {
|
|
9611
|
-
if (exclusiveMaximum <= maximum)
|
|
9612
|
-
delete json.maximum;
|
|
9613
|
-
else
|
|
9614
|
-
delete json.exclusiveMaximum;
|
|
9615
|
-
}
|
|
9616
9620
|
}
|
|
9617
9621
|
if (typeof multipleOf === "number")
|
|
9618
9622
|
json.multipleOf = multipleOf;
|
|
@@ -9795,7 +9799,10 @@ const arrayProcessor = (schema, ctx, _json, params) => {
|
|
|
9795
9799
|
if (typeof maximum === "number")
|
|
9796
9800
|
json.maxItems = maximum;
|
|
9797
9801
|
json.type = "array";
|
|
9798
|
-
json.items = process$1(def.element, ctx, {
|
|
9802
|
+
json.items = process$1(def.element, ctx, {
|
|
9803
|
+
...params,
|
|
9804
|
+
path: [...params.path, "items"],
|
|
9805
|
+
});
|
|
9799
9806
|
};
|
|
9800
9807
|
const objectProcessor = (schema, ctx, _json, params) => {
|
|
9801
9808
|
const json = _json;
|
|
@@ -10012,7 +10019,8 @@ const catchProcessor = (schema, ctx, json, params) => {
|
|
|
10012
10019
|
};
|
|
10013
10020
|
const pipeProcessor = (schema, ctx, _json, params) => {
|
|
10014
10021
|
const def = schema._zod.def;
|
|
10015
|
-
const
|
|
10022
|
+
const inIsTransform = def.in._zod.traits.has("$ZodTransform");
|
|
10023
|
+
const innerType = ctx.io === "input" ? (inIsTransform ? def.out : def.in) : def.out;
|
|
10016
10024
|
process$1(innerType, ctx, params);
|
|
10017
10025
|
const seen = ctx.seen.get(schema);
|
|
10018
10026
|
seen.ref = innerType;
|
|
@@ -10210,235 +10218,6 @@ function setResponseValueAndErrors(res, key, value, errorMessage, refs) {
|
|
|
10210
10218
|
addErrorMessage(res, key, errorMessage, refs);
|
|
10211
10219
|
}
|
|
10212
10220
|
|
|
10213
|
-
var util;
|
|
10214
|
-
(function (util) {
|
|
10215
|
-
util.assertEqual = (_) => { };
|
|
10216
|
-
function assertIs(_arg) { }
|
|
10217
|
-
util.assertIs = assertIs;
|
|
10218
|
-
function assertNever(_x) {
|
|
10219
|
-
throw new Error();
|
|
10220
|
-
}
|
|
10221
|
-
util.assertNever = assertNever;
|
|
10222
|
-
util.arrayToEnum = (items) => {
|
|
10223
|
-
const obj = {};
|
|
10224
|
-
for (const item of items) {
|
|
10225
|
-
obj[item] = item;
|
|
10226
|
-
}
|
|
10227
|
-
return obj;
|
|
10228
|
-
};
|
|
10229
|
-
util.getValidEnumValues = (obj) => {
|
|
10230
|
-
const validKeys = util.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
|
|
10231
|
-
const filtered = {};
|
|
10232
|
-
for (const k of validKeys) {
|
|
10233
|
-
filtered[k] = obj[k];
|
|
10234
|
-
}
|
|
10235
|
-
return util.objectValues(filtered);
|
|
10236
|
-
};
|
|
10237
|
-
util.objectValues = (obj) => {
|
|
10238
|
-
return util.objectKeys(obj).map(function (e) {
|
|
10239
|
-
return obj[e];
|
|
10240
|
-
});
|
|
10241
|
-
};
|
|
10242
|
-
util.objectKeys = typeof Object.keys === "function" // eslint-disable-line ban/ban
|
|
10243
|
-
? (obj) => Object.keys(obj) // eslint-disable-line ban/ban
|
|
10244
|
-
: (object) => {
|
|
10245
|
-
const keys = [];
|
|
10246
|
-
for (const key in object) {
|
|
10247
|
-
if (Object.prototype.hasOwnProperty.call(object, key)) {
|
|
10248
|
-
keys.push(key);
|
|
10249
|
-
}
|
|
10250
|
-
}
|
|
10251
|
-
return keys;
|
|
10252
|
-
};
|
|
10253
|
-
util.find = (arr, checker) => {
|
|
10254
|
-
for (const item of arr) {
|
|
10255
|
-
if (checker(item))
|
|
10256
|
-
return item;
|
|
10257
|
-
}
|
|
10258
|
-
return undefined;
|
|
10259
|
-
};
|
|
10260
|
-
util.isInteger = typeof Number.isInteger === "function"
|
|
10261
|
-
? (val) => Number.isInteger(val) // eslint-disable-line ban/ban
|
|
10262
|
-
: (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
|
|
10263
|
-
function joinValues(array, separator = " | ") {
|
|
10264
|
-
return array.map((val) => (typeof val === "string" ? `'${val}'` : val)).join(separator);
|
|
10265
|
-
}
|
|
10266
|
-
util.joinValues = joinValues;
|
|
10267
|
-
util.jsonStringifyReplacer = (_, value) => {
|
|
10268
|
-
if (typeof value === "bigint") {
|
|
10269
|
-
return value.toString();
|
|
10270
|
-
}
|
|
10271
|
-
return value;
|
|
10272
|
-
};
|
|
10273
|
-
})(util || (util = {}));
|
|
10274
|
-
var objectUtil;
|
|
10275
|
-
(function (objectUtil) {
|
|
10276
|
-
objectUtil.mergeShapes = (first, second) => {
|
|
10277
|
-
return {
|
|
10278
|
-
...first,
|
|
10279
|
-
...second, // second overwrites first
|
|
10280
|
-
};
|
|
10281
|
-
};
|
|
10282
|
-
})(objectUtil || (objectUtil = {}));
|
|
10283
|
-
util.arrayToEnum([
|
|
10284
|
-
"string",
|
|
10285
|
-
"nan",
|
|
10286
|
-
"number",
|
|
10287
|
-
"integer",
|
|
10288
|
-
"float",
|
|
10289
|
-
"boolean",
|
|
10290
|
-
"date",
|
|
10291
|
-
"bigint",
|
|
10292
|
-
"symbol",
|
|
10293
|
-
"function",
|
|
10294
|
-
"undefined",
|
|
10295
|
-
"null",
|
|
10296
|
-
"array",
|
|
10297
|
-
"object",
|
|
10298
|
-
"unknown",
|
|
10299
|
-
"promise",
|
|
10300
|
-
"void",
|
|
10301
|
-
"never",
|
|
10302
|
-
"map",
|
|
10303
|
-
"set",
|
|
10304
|
-
]);
|
|
10305
|
-
|
|
10306
|
-
util.arrayToEnum([
|
|
10307
|
-
"invalid_type",
|
|
10308
|
-
"invalid_literal",
|
|
10309
|
-
"custom",
|
|
10310
|
-
"invalid_union",
|
|
10311
|
-
"invalid_union_discriminator",
|
|
10312
|
-
"invalid_enum_value",
|
|
10313
|
-
"unrecognized_keys",
|
|
10314
|
-
"invalid_arguments",
|
|
10315
|
-
"invalid_return_type",
|
|
10316
|
-
"invalid_date",
|
|
10317
|
-
"invalid_string",
|
|
10318
|
-
"too_small",
|
|
10319
|
-
"too_big",
|
|
10320
|
-
"invalid_intersection_types",
|
|
10321
|
-
"not_multiple_of",
|
|
10322
|
-
"not_finite",
|
|
10323
|
-
]);
|
|
10324
|
-
class ZodError extends Error {
|
|
10325
|
-
get errors() {
|
|
10326
|
-
return this.issues;
|
|
10327
|
-
}
|
|
10328
|
-
constructor(issues) {
|
|
10329
|
-
super();
|
|
10330
|
-
this.issues = [];
|
|
10331
|
-
this.addIssue = (sub) => {
|
|
10332
|
-
this.issues = [...this.issues, sub];
|
|
10333
|
-
};
|
|
10334
|
-
this.addIssues = (subs = []) => {
|
|
10335
|
-
this.issues = [...this.issues, ...subs];
|
|
10336
|
-
};
|
|
10337
|
-
const actualProto = new.target.prototype;
|
|
10338
|
-
if (Object.setPrototypeOf) {
|
|
10339
|
-
// eslint-disable-next-line ban/ban
|
|
10340
|
-
Object.setPrototypeOf(this, actualProto);
|
|
10341
|
-
}
|
|
10342
|
-
else {
|
|
10343
|
-
this.__proto__ = actualProto;
|
|
10344
|
-
}
|
|
10345
|
-
this.name = "ZodError";
|
|
10346
|
-
this.issues = issues;
|
|
10347
|
-
}
|
|
10348
|
-
format(_mapper) {
|
|
10349
|
-
const mapper = _mapper ||
|
|
10350
|
-
function (issue) {
|
|
10351
|
-
return issue.message;
|
|
10352
|
-
};
|
|
10353
|
-
const fieldErrors = { _errors: [] };
|
|
10354
|
-
const processError = (error) => {
|
|
10355
|
-
for (const issue of error.issues) {
|
|
10356
|
-
if (issue.code === "invalid_union") {
|
|
10357
|
-
issue.unionErrors.map(processError);
|
|
10358
|
-
}
|
|
10359
|
-
else if (issue.code === "invalid_return_type") {
|
|
10360
|
-
processError(issue.returnTypeError);
|
|
10361
|
-
}
|
|
10362
|
-
else if (issue.code === "invalid_arguments") {
|
|
10363
|
-
processError(issue.argumentsError);
|
|
10364
|
-
}
|
|
10365
|
-
else if (issue.path.length === 0) {
|
|
10366
|
-
fieldErrors._errors.push(mapper(issue));
|
|
10367
|
-
}
|
|
10368
|
-
else {
|
|
10369
|
-
let curr = fieldErrors;
|
|
10370
|
-
let i = 0;
|
|
10371
|
-
while (i < issue.path.length) {
|
|
10372
|
-
const el = issue.path[i];
|
|
10373
|
-
const terminal = i === issue.path.length - 1;
|
|
10374
|
-
if (!terminal) {
|
|
10375
|
-
curr[el] = curr[el] || { _errors: [] };
|
|
10376
|
-
// if (typeof el === "string") {
|
|
10377
|
-
// curr[el] = curr[el] || { _errors: [] };
|
|
10378
|
-
// } else if (typeof el === "number") {
|
|
10379
|
-
// const errorArray: any = [];
|
|
10380
|
-
// errorArray._errors = [];
|
|
10381
|
-
// curr[el] = curr[el] || errorArray;
|
|
10382
|
-
// }
|
|
10383
|
-
}
|
|
10384
|
-
else {
|
|
10385
|
-
curr[el] = curr[el] || { _errors: [] };
|
|
10386
|
-
curr[el]._errors.push(mapper(issue));
|
|
10387
|
-
}
|
|
10388
|
-
curr = curr[el];
|
|
10389
|
-
i++;
|
|
10390
|
-
}
|
|
10391
|
-
}
|
|
10392
|
-
}
|
|
10393
|
-
};
|
|
10394
|
-
processError(this);
|
|
10395
|
-
return fieldErrors;
|
|
10396
|
-
}
|
|
10397
|
-
static assert(value) {
|
|
10398
|
-
if (!(value instanceof ZodError)) {
|
|
10399
|
-
throw new Error(`Not a ZodError: ${value}`);
|
|
10400
|
-
}
|
|
10401
|
-
}
|
|
10402
|
-
toString() {
|
|
10403
|
-
return this.message;
|
|
10404
|
-
}
|
|
10405
|
-
get message() {
|
|
10406
|
-
return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
|
|
10407
|
-
}
|
|
10408
|
-
get isEmpty() {
|
|
10409
|
-
return this.issues.length === 0;
|
|
10410
|
-
}
|
|
10411
|
-
flatten(mapper = (issue) => issue.message) {
|
|
10412
|
-
const fieldErrors = Object.create(null);
|
|
10413
|
-
const formErrors = [];
|
|
10414
|
-
for (const sub of this.issues) {
|
|
10415
|
-
if (sub.path.length > 0) {
|
|
10416
|
-
const firstEl = sub.path[0];
|
|
10417
|
-
fieldErrors[firstEl] = fieldErrors[firstEl] || [];
|
|
10418
|
-
fieldErrors[firstEl].push(mapper(sub));
|
|
10419
|
-
}
|
|
10420
|
-
else {
|
|
10421
|
-
formErrors.push(mapper(sub));
|
|
10422
|
-
}
|
|
10423
|
-
}
|
|
10424
|
-
return { formErrors, fieldErrors };
|
|
10425
|
-
}
|
|
10426
|
-
get formErrors() {
|
|
10427
|
-
return this.flatten();
|
|
10428
|
-
}
|
|
10429
|
-
}
|
|
10430
|
-
ZodError.create = (issues) => {
|
|
10431
|
-
const error = new ZodError(issues);
|
|
10432
|
-
return error;
|
|
10433
|
-
};
|
|
10434
|
-
|
|
10435
|
-
var errorUtil;
|
|
10436
|
-
(function (errorUtil) {
|
|
10437
|
-
errorUtil.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
10438
|
-
// biome-ignore lint:
|
|
10439
|
-
errorUtil.toString = (message) => typeof message === "string" ? message : message?.message;
|
|
10440
|
-
})(errorUtil || (errorUtil = {}));
|
|
10441
|
-
|
|
10442
10221
|
var ZodFirstPartyTypeKind;
|
|
10443
10222
|
(function (ZodFirstPartyTypeKind) {
|
|
10444
10223
|
ZodFirstPartyTypeKind["ZodString"] = "ZodString";
|
|
@@ -11820,10 +11599,10 @@ function zodTextFormat(zodObject, name, props) {
|
|
|
11820
11599
|
|
|
11821
11600
|
// llm-openai-config.ts
|
|
11822
11601
|
const DEFAULT_MODEL = 'gpt-4.1-mini';
|
|
11823
|
-
const
|
|
11824
|
-
const
|
|
11825
|
-
const
|
|
11826
|
-
/** Token costs in USD per 1M tokens. Last updated
|
|
11602
|
+
const GPT_5_HIGH_CONTEXT_THRESHOLD_TOKENS = 272_000;
|
|
11603
|
+
const GPT_5_HIGH_CONTEXT_INPUT_MULTIPLIER = 2;
|
|
11604
|
+
const GPT_5_HIGH_CONTEXT_OUTPUT_MULTIPLIER = 1.5;
|
|
11605
|
+
/** Token costs in USD per 1M tokens. Last updated May 2026. */
|
|
11827
11606
|
const openAiModelCosts = {
|
|
11828
11607
|
'gpt-4o': {
|
|
11829
11608
|
inputCost: 2.5 / 1_000_000,
|
|
@@ -11904,6 +11683,15 @@ const openAiModelCosts = {
|
|
|
11904
11683
|
inputCost: 30 / 1_000_000,
|
|
11905
11684
|
outputCost: 180 / 1_000_000,
|
|
11906
11685
|
},
|
|
11686
|
+
'gpt-5.5': {
|
|
11687
|
+
inputCost: 5 / 1_000_000,
|
|
11688
|
+
cacheHitCost: 0.5 / 1_000_000,
|
|
11689
|
+
outputCost: 30 / 1_000_000,
|
|
11690
|
+
},
|
|
11691
|
+
'gpt-5.5-pro': {
|
|
11692
|
+
inputCost: 30 / 1_000_000,
|
|
11693
|
+
outputCost: 180 / 1_000_000,
|
|
11694
|
+
},
|
|
11907
11695
|
'gpt-5.2': {
|
|
11908
11696
|
inputCost: 1.75 / 1_000_000,
|
|
11909
11697
|
cacheHitCost: 0.175 / 1_000_000,
|
|
@@ -11941,8 +11729,9 @@ const deepseekModelCosts = {
|
|
|
11941
11729
|
outputCost: 2.19 / 1_000_000, // $2.19 per 1M tokens
|
|
11942
11730
|
},
|
|
11943
11731
|
};
|
|
11944
|
-
function
|
|
11945
|
-
return (model === 'gpt-5.4' || model === 'gpt-5.4-pro'
|
|
11732
|
+
function shouldUseGPT5HighContextPricing(model, inputTokens) {
|
|
11733
|
+
return ((model === 'gpt-5.4' || model === 'gpt-5.4-pro' || model === 'gpt-5.5') &&
|
|
11734
|
+
inputTokens > GPT_5_HIGH_CONTEXT_THRESHOLD_TOKENS);
|
|
11946
11735
|
}
|
|
11947
11736
|
/** Image generation costs in USD per image. Based on OpenAI pricing as of Feb 2025. */
|
|
11948
11737
|
const openAiImageCosts = {
|
|
@@ -11995,10 +11784,10 @@ function calculateCost(provider, model, inputTokens, outputTokens, reasoningToke
|
|
|
11995
11784
|
}
|
|
11996
11785
|
let outputCost = outputTokens * modelCosts.outputCost;
|
|
11997
11786
|
let reasoningCost = (reasoningTokens || 0) * modelCosts.outputCost;
|
|
11998
|
-
if (provider === 'openai' &&
|
|
11999
|
-
inputCost *=
|
|
12000
|
-
outputCost *=
|
|
12001
|
-
reasoningCost *=
|
|
11787
|
+
if (provider === 'openai' && shouldUseGPT5HighContextPricing(model, inputTokens)) {
|
|
11788
|
+
inputCost *= GPT_5_HIGH_CONTEXT_INPUT_MULTIPLIER;
|
|
11789
|
+
outputCost *= GPT_5_HIGH_CONTEXT_OUTPUT_MULTIPLIER;
|
|
11790
|
+
reasoningCost *= GPT_5_HIGH_CONTEXT_OUTPUT_MULTIPLIER;
|
|
12002
11791
|
}
|
|
12003
11792
|
return inputCost + outputCost + reasoningCost;
|
|
12004
11793
|
}
|
|
@@ -12400,6 +12189,8 @@ const isSupportedModel = (model) => {
|
|
|
12400
12189
|
'gpt-5.1',
|
|
12401
12190
|
'gpt-5.4',
|
|
12402
12191
|
'gpt-5.4-pro',
|
|
12192
|
+
'gpt-5.5',
|
|
12193
|
+
'gpt-5.5-pro',
|
|
12403
12194
|
'gpt-5.2',
|
|
12404
12195
|
'gpt-5.2-pro',
|
|
12405
12196
|
'gpt-5.1-codex',
|
|
@@ -12429,6 +12220,8 @@ function supportsTemperature(model) {
|
|
|
12429
12220
|
'gpt-5.1',
|
|
12430
12221
|
'gpt-5.4',
|
|
12431
12222
|
'gpt-5.4-pro',
|
|
12223
|
+
'gpt-5.5',
|
|
12224
|
+
'gpt-5.5-pro',
|
|
12432
12225
|
'gpt-5.2',
|
|
12433
12226
|
'gpt-5.2-pro',
|
|
12434
12227
|
'gpt-5.1-codex',
|
|
@@ -12459,6 +12252,8 @@ function isGPT5Model(model) {
|
|
|
12459
12252
|
'gpt-5.1',
|
|
12460
12253
|
'gpt-5.4',
|
|
12461
12254
|
'gpt-5.4-pro',
|
|
12255
|
+
'gpt-5.5',
|
|
12256
|
+
'gpt-5.5-pro',
|
|
12462
12257
|
'gpt-5.2',
|
|
12463
12258
|
'gpt-5.2-pro',
|
|
12464
12259
|
'gpt-5.1-codex',
|
|
@@ -12769,6 +12564,8 @@ const MULTIMODAL_VISION_MODELS = new Set([
|
|
|
12769
12564
|
'gpt-5.1',
|
|
12770
12565
|
'gpt-5.4',
|
|
12771
12566
|
'gpt-5.4-pro',
|
|
12567
|
+
'gpt-5.5',
|
|
12568
|
+
'gpt-5.5-pro',
|
|
12772
12569
|
'gpt-5.2',
|
|
12773
12570
|
'gpt-5.2-pro',
|
|
12774
12571
|
'gpt-5.1-codex',
|