@discomedia/utils 1.0.67 → 1.0.69

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.
Files changed (34) hide show
  1. package/dist/index-frontend.cjs +90 -438
  2. package/dist/index-frontend.cjs.map +1 -1
  3. package/dist/index-frontend.mjs +88 -439
  4. package/dist/index-frontend.mjs.map +1 -1
  5. package/dist/index.cjs +90 -438
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.mjs +88 -439
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/package.json +4 -4
  10. package/dist/test.js +663 -3568
  11. package/dist/test.js.map +1 -1
  12. package/dist/types/index-frontend.d.ts +1 -0
  13. package/dist/types/index-frontend.d.ts.map +1 -1
  14. package/dist/types/index.d.ts +1 -0
  15. package/dist/types/index.d.ts.map +1 -1
  16. package/dist/types/llm-config.d.ts +2 -2
  17. package/dist/types/llm-config.d.ts.map +1 -1
  18. package/dist/types/llm-images.d.ts.map +1 -1
  19. package/dist/types/llm-openai.d.ts +4 -16
  20. package/dist/types/llm-openai.d.ts.map +1 -1
  21. package/dist/types/types/llm-types.d.ts +7 -2
  22. package/dist/types/types/llm-types.d.ts.map +1 -1
  23. package/dist/types-frontend/index-frontend.d.ts +1 -0
  24. package/dist/types-frontend/index-frontend.d.ts.map +1 -1
  25. package/dist/types-frontend/index.d.ts +1 -0
  26. package/dist/types-frontend/index.d.ts.map +1 -1
  27. package/dist/types-frontend/llm-config.d.ts +2 -2
  28. package/dist/types-frontend/llm-config.d.ts.map +1 -1
  29. package/dist/types-frontend/llm-images.d.ts.map +1 -1
  30. package/dist/types-frontend/llm-openai.d.ts +4 -16
  31. package/dist/types-frontend/llm-openai.d.ts.map +1 -1
  32. package/dist/types-frontend/types/llm-types.d.ts +7 -2
  33. package/dist/types-frontend/types/llm-types.d.ts.map +1 -1
  34. package/package.json +4 -4
package/dist/index.mjs CHANGED
@@ -1139,6 +1139,29 @@ function dateTimeForGS(date) {
1139
1139
  .replace(/\./g, '/');
1140
1140
  }
1141
1141
 
1142
+ /**
1143
+ * Represents OpenAI models
1144
+ */
1145
+ const OPENAI_MODELS = [
1146
+ 'gpt-5',
1147
+ 'gpt-5-mini',
1148
+ 'gpt-5.4-mini',
1149
+ 'gpt-5-nano',
1150
+ 'gpt-5.1',
1151
+ 'gpt-5.4',
1152
+ 'gpt-5.5',
1153
+ 'gpt-5.5-pro',
1154
+ 'gpt-5.2',
1155
+ 'gpt-5.2-pro',
1156
+ 'gpt-5.1-codex',
1157
+ 'gpt-5.1-codex-max',
1158
+ ];
1159
+ /**
1160
+ * Type guard to check if a model is a supported direct OpenAI model.
1161
+ */
1162
+ function isOpenAIModel(model) {
1163
+ return OPENAI_MODELS.includes(model);
1164
+ }
1142
1165
  /**
1143
1166
  * Type guard to check if a model is an OpenRouter model
1144
1167
  */
@@ -1151,6 +1174,8 @@ function isOpenRouterModel(model) {
1151
1174
  'openai/gpt-5.1',
1152
1175
  'openai/gpt-5.4',
1153
1176
  'openai/gpt-5.4-pro',
1177
+ 'openai/gpt-5.5',
1178
+ 'openai/gpt-5.5-pro',
1154
1179
  'openai/gpt-5.2',
1155
1180
  'openai/gpt-5.2-pro',
1156
1181
  'openai/gpt-5.1-codex',
@@ -1168,6 +1193,8 @@ function isOpenRouterModel(model) {
1168
1193
 
1169
1194
  var Types = /*#__PURE__*/Object.freeze({
1170
1195
  __proto__: null,
1196
+ OPENAI_MODELS: OPENAI_MODELS,
1197
+ isOpenAIModel: isOpenAIModel,
1171
1198
  isOpenRouterModel: isOpenRouterModel
1172
1199
  });
1173
1200
 
@@ -1646,7 +1673,7 @@ const safeJSON = (text) => {
1646
1673
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
1647
1674
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
1648
1675
 
1649
- const VERSION = '6.34.0'; // x-release-please-version
1676
+ const VERSION = '6.35.0'; // x-release-please-version
1650
1677
 
1651
1678
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
1652
1679
  const isRunningInBrowser = () => {
@@ -4974,8 +5001,8 @@ class Speech extends APIResource {
4974
5001
  * ```ts
4975
5002
  * const speech = await client.audio.speech.create({
4976
5003
  * input: 'input',
4977
- * model: 'string',
4978
- * voice: 'string',
5004
+ * model: 'tts-1',
5005
+ * voice: 'alloy',
4979
5006
  * });
4980
5007
  *
4981
5008
  * const content = await speech.blob();
@@ -5453,10 +5480,10 @@ const toFloat32Array = (base64Str) => {
5453
5480
  */
5454
5481
  const readEnv = (env) => {
5455
5482
  if (typeof globalThis.process !== 'undefined') {
5456
- return globalThis.process.env?.[env]?.trim() ?? undefined;
5483
+ return globalThis.process.env?.[env]?.trim() || undefined;
5457
5484
  }
5458
5485
  if (typeof globalThis.Deno !== 'undefined') {
5459
- return globalThis.Deno.env?.get?.(env)?.trim();
5486
+ return globalThis.Deno.env?.get?.(env)?.trim() || undefined;
5460
5487
  }
5461
5488
  return undefined;
5462
5489
  };
@@ -9042,7 +9069,6 @@ OpenAI.Containers = Containers;
9042
9069
  OpenAI.Skills = Skills;
9043
9070
  OpenAI.Videos = Videos;
9044
9071
 
9045
- // functions
9046
9072
  function getEnumValues(entries) {
9047
9073
  const numericValues = Object.values(entries).filter((v) => typeof v === "number");
9048
9074
  const values = Object.entries(entries)
@@ -9188,7 +9214,7 @@ function process$1(schema, ctx, _params = { path: [], schemaPath: [] }) {
9188
9214
  delete result.schema.default;
9189
9215
  }
9190
9216
  // set prefault as default
9191
- if (ctx.io === "input" && result.schema._prefault)
9217
+ if (ctx.io === "input" && "_prefault" in result.schema)
9192
9218
  (_a = result.schema).default ?? (_a.default = result.schema._prefault);
9193
9219
  delete result.schema._prefault;
9194
9220
  // pulling fresh from ctx.seen in case it was overwritten
@@ -9416,11 +9442,20 @@ function finalize(ctx, schema) {
9416
9442
  result.$id = ctx.external.uri(id);
9417
9443
  }
9418
9444
  Object.assign(result, root.def ?? root.schema);
9445
+ // The `id` in `.meta()` is a Zod-specific registration tag used to extract
9446
+ // schemas into $defs — it is not user-facing JSON Schema metadata. Strip it
9447
+ // from the output body where it would otherwise leak. The id is preserved
9448
+ // implicitly via the $defs key (and via $ref paths).
9449
+ const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
9450
+ if (rootMetaId !== undefined && result.id === rootMetaId)
9451
+ delete result.id;
9419
9452
  // build defs object
9420
9453
  const defs = ctx.external?.defs ?? {};
9421
9454
  for (const entry of ctx.seen.entries()) {
9422
9455
  const seen = entry[1];
9423
9456
  if (seen.def && seen.defId) {
9457
+ if (seen.def.id === seen.defId)
9458
+ delete seen.def.id;
9424
9459
  defs[seen.defId] = seen.def;
9425
9460
  }
9426
9461
  }
@@ -9488,6 +9523,8 @@ function isTransforming(_schema, _ctx) {
9488
9523
  return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
9489
9524
  }
9490
9525
  if (def.type === "pipe") {
9526
+ if (_schema._zod.traits.has("$ZodCodec"))
9527
+ return true;
9491
9528
  return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
9492
9529
  }
9493
9530
  if (def.type === "object") {
@@ -9576,8 +9613,12 @@ const numberProcessor = (schema, ctx, _json, _params) => {
9576
9613
  json.type = "integer";
9577
9614
  else
9578
9615
  json.type = "number";
9579
- if (typeof exclusiveMinimum === "number") {
9580
- if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
9616
+ // when both minimum and exclusiveMinimum exist, pick the more restrictive one
9617
+ const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
9618
+ const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
9619
+ const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
9620
+ if (exMin) {
9621
+ if (legacy) {
9581
9622
  json.minimum = exclusiveMinimum;
9582
9623
  json.exclusiveMinimum = true;
9583
9624
  }
@@ -9585,17 +9626,11 @@ const numberProcessor = (schema, ctx, _json, _params) => {
9585
9626
  json.exclusiveMinimum = exclusiveMinimum;
9586
9627
  }
9587
9628
  }
9588
- if (typeof minimum === "number") {
9629
+ else if (typeof minimum === "number") {
9589
9630
  json.minimum = minimum;
9590
- if (typeof exclusiveMinimum === "number" && ctx.target !== "draft-04") {
9591
- if (exclusiveMinimum >= minimum)
9592
- delete json.minimum;
9593
- else
9594
- delete json.exclusiveMinimum;
9595
- }
9596
9631
  }
9597
- if (typeof exclusiveMaximum === "number") {
9598
- if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
9632
+ if (exMax) {
9633
+ if (legacy) {
9599
9634
  json.maximum = exclusiveMaximum;
9600
9635
  json.exclusiveMaximum = true;
9601
9636
  }
@@ -9603,14 +9638,8 @@ const numberProcessor = (schema, ctx, _json, _params) => {
9603
9638
  json.exclusiveMaximum = exclusiveMaximum;
9604
9639
  }
9605
9640
  }
9606
- if (typeof maximum === "number") {
9641
+ else if (typeof maximum === "number") {
9607
9642
  json.maximum = maximum;
9608
- if (typeof exclusiveMaximum === "number" && ctx.target !== "draft-04") {
9609
- if (exclusiveMaximum <= maximum)
9610
- delete json.maximum;
9611
- else
9612
- delete json.exclusiveMaximum;
9613
- }
9614
9643
  }
9615
9644
  if (typeof multipleOf === "number")
9616
9645
  json.multipleOf = multipleOf;
@@ -9793,7 +9822,10 @@ const arrayProcessor = (schema, ctx, _json, params) => {
9793
9822
  if (typeof maximum === "number")
9794
9823
  json.maxItems = maximum;
9795
9824
  json.type = "array";
9796
- json.items = process$1(def.element, ctx, { ...params, path: [...params.path, "items"] });
9825
+ json.items = process$1(def.element, ctx, {
9826
+ ...params,
9827
+ path: [...params.path, "items"],
9828
+ });
9797
9829
  };
9798
9830
  const objectProcessor = (schema, ctx, _json, params) => {
9799
9831
  const json = _json;
@@ -10010,7 +10042,8 @@ const catchProcessor = (schema, ctx, json, params) => {
10010
10042
  };
10011
10043
  const pipeProcessor = (schema, ctx, _json, params) => {
10012
10044
  const def = schema._zod.def;
10013
- const innerType = ctx.io === "input" ? (def.in._zod.def.type === "transform" ? def.out : def.in) : def.out;
10045
+ const inIsTransform = def.in._zod.traits.has("$ZodTransform");
10046
+ const innerType = ctx.io === "input" ? (inIsTransform ? def.out : def.in) : def.out;
10014
10047
  process$1(innerType, ctx, params);
10015
10048
  const seen = ctx.seen.get(schema);
10016
10049
  seen.ref = innerType;
@@ -10208,235 +10241,6 @@ function setResponseValueAndErrors(res, key, value, errorMessage, refs) {
10208
10241
  addErrorMessage(res, key, errorMessage, refs);
10209
10242
  }
10210
10243
 
10211
- var util;
10212
- (function (util) {
10213
- util.assertEqual = (_) => { };
10214
- function assertIs(_arg) { }
10215
- util.assertIs = assertIs;
10216
- function assertNever(_x) {
10217
- throw new Error();
10218
- }
10219
- util.assertNever = assertNever;
10220
- util.arrayToEnum = (items) => {
10221
- const obj = {};
10222
- for (const item of items) {
10223
- obj[item] = item;
10224
- }
10225
- return obj;
10226
- };
10227
- util.getValidEnumValues = (obj) => {
10228
- const validKeys = util.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
10229
- const filtered = {};
10230
- for (const k of validKeys) {
10231
- filtered[k] = obj[k];
10232
- }
10233
- return util.objectValues(filtered);
10234
- };
10235
- util.objectValues = (obj) => {
10236
- return util.objectKeys(obj).map(function (e) {
10237
- return obj[e];
10238
- });
10239
- };
10240
- util.objectKeys = typeof Object.keys === "function" // eslint-disable-line ban/ban
10241
- ? (obj) => Object.keys(obj) // eslint-disable-line ban/ban
10242
- : (object) => {
10243
- const keys = [];
10244
- for (const key in object) {
10245
- if (Object.prototype.hasOwnProperty.call(object, key)) {
10246
- keys.push(key);
10247
- }
10248
- }
10249
- return keys;
10250
- };
10251
- util.find = (arr, checker) => {
10252
- for (const item of arr) {
10253
- if (checker(item))
10254
- return item;
10255
- }
10256
- return undefined;
10257
- };
10258
- util.isInteger = typeof Number.isInteger === "function"
10259
- ? (val) => Number.isInteger(val) // eslint-disable-line ban/ban
10260
- : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
10261
- function joinValues(array, separator = " | ") {
10262
- return array.map((val) => (typeof val === "string" ? `'${val}'` : val)).join(separator);
10263
- }
10264
- util.joinValues = joinValues;
10265
- util.jsonStringifyReplacer = (_, value) => {
10266
- if (typeof value === "bigint") {
10267
- return value.toString();
10268
- }
10269
- return value;
10270
- };
10271
- })(util || (util = {}));
10272
- var objectUtil;
10273
- (function (objectUtil) {
10274
- objectUtil.mergeShapes = (first, second) => {
10275
- return {
10276
- ...first,
10277
- ...second, // second overwrites first
10278
- };
10279
- };
10280
- })(objectUtil || (objectUtil = {}));
10281
- util.arrayToEnum([
10282
- "string",
10283
- "nan",
10284
- "number",
10285
- "integer",
10286
- "float",
10287
- "boolean",
10288
- "date",
10289
- "bigint",
10290
- "symbol",
10291
- "function",
10292
- "undefined",
10293
- "null",
10294
- "array",
10295
- "object",
10296
- "unknown",
10297
- "promise",
10298
- "void",
10299
- "never",
10300
- "map",
10301
- "set",
10302
- ]);
10303
-
10304
- util.arrayToEnum([
10305
- "invalid_type",
10306
- "invalid_literal",
10307
- "custom",
10308
- "invalid_union",
10309
- "invalid_union_discriminator",
10310
- "invalid_enum_value",
10311
- "unrecognized_keys",
10312
- "invalid_arguments",
10313
- "invalid_return_type",
10314
- "invalid_date",
10315
- "invalid_string",
10316
- "too_small",
10317
- "too_big",
10318
- "invalid_intersection_types",
10319
- "not_multiple_of",
10320
- "not_finite",
10321
- ]);
10322
- class ZodError extends Error {
10323
- get errors() {
10324
- return this.issues;
10325
- }
10326
- constructor(issues) {
10327
- super();
10328
- this.issues = [];
10329
- this.addIssue = (sub) => {
10330
- this.issues = [...this.issues, sub];
10331
- };
10332
- this.addIssues = (subs = []) => {
10333
- this.issues = [...this.issues, ...subs];
10334
- };
10335
- const actualProto = new.target.prototype;
10336
- if (Object.setPrototypeOf) {
10337
- // eslint-disable-next-line ban/ban
10338
- Object.setPrototypeOf(this, actualProto);
10339
- }
10340
- else {
10341
- this.__proto__ = actualProto;
10342
- }
10343
- this.name = "ZodError";
10344
- this.issues = issues;
10345
- }
10346
- format(_mapper) {
10347
- const mapper = _mapper ||
10348
- function (issue) {
10349
- return issue.message;
10350
- };
10351
- const fieldErrors = { _errors: [] };
10352
- const processError = (error) => {
10353
- for (const issue of error.issues) {
10354
- if (issue.code === "invalid_union") {
10355
- issue.unionErrors.map(processError);
10356
- }
10357
- else if (issue.code === "invalid_return_type") {
10358
- processError(issue.returnTypeError);
10359
- }
10360
- else if (issue.code === "invalid_arguments") {
10361
- processError(issue.argumentsError);
10362
- }
10363
- else if (issue.path.length === 0) {
10364
- fieldErrors._errors.push(mapper(issue));
10365
- }
10366
- else {
10367
- let curr = fieldErrors;
10368
- let i = 0;
10369
- while (i < issue.path.length) {
10370
- const el = issue.path[i];
10371
- const terminal = i === issue.path.length - 1;
10372
- if (!terminal) {
10373
- curr[el] = curr[el] || { _errors: [] };
10374
- // if (typeof el === "string") {
10375
- // curr[el] = curr[el] || { _errors: [] };
10376
- // } else if (typeof el === "number") {
10377
- // const errorArray: any = [];
10378
- // errorArray._errors = [];
10379
- // curr[el] = curr[el] || errorArray;
10380
- // }
10381
- }
10382
- else {
10383
- curr[el] = curr[el] || { _errors: [] };
10384
- curr[el]._errors.push(mapper(issue));
10385
- }
10386
- curr = curr[el];
10387
- i++;
10388
- }
10389
- }
10390
- }
10391
- };
10392
- processError(this);
10393
- return fieldErrors;
10394
- }
10395
- static assert(value) {
10396
- if (!(value instanceof ZodError)) {
10397
- throw new Error(`Not a ZodError: ${value}`);
10398
- }
10399
- }
10400
- toString() {
10401
- return this.message;
10402
- }
10403
- get message() {
10404
- return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
10405
- }
10406
- get isEmpty() {
10407
- return this.issues.length === 0;
10408
- }
10409
- flatten(mapper = (issue) => issue.message) {
10410
- const fieldErrors = Object.create(null);
10411
- const formErrors = [];
10412
- for (const sub of this.issues) {
10413
- if (sub.path.length > 0) {
10414
- const firstEl = sub.path[0];
10415
- fieldErrors[firstEl] = fieldErrors[firstEl] || [];
10416
- fieldErrors[firstEl].push(mapper(sub));
10417
- }
10418
- else {
10419
- formErrors.push(mapper(sub));
10420
- }
10421
- }
10422
- return { formErrors, fieldErrors };
10423
- }
10424
- get formErrors() {
10425
- return this.flatten();
10426
- }
10427
- }
10428
- ZodError.create = (issues) => {
10429
- const error = new ZodError(issues);
10430
- return error;
10431
- };
10432
-
10433
- var errorUtil;
10434
- (function (errorUtil) {
10435
- errorUtil.errToObj = (message) => typeof message === "string" ? { message } : message || {};
10436
- // biome-ignore lint:
10437
- errorUtil.toString = (message) => typeof message === "string" ? message : message?.message;
10438
- })(errorUtil || (errorUtil = {}));
10439
-
10440
10244
  var ZodFirstPartyTypeKind;
10441
10245
  (function (ZodFirstPartyTypeKind) {
10442
10246
  ZodFirstPartyTypeKind["ZodString"] = "ZodString";
@@ -11817,57 +11621,12 @@ function zodTextFormat(zodObject, name, props) {
11817
11621
  }
11818
11622
 
11819
11623
  // llm-openai-config.ts
11820
- const DEFAULT_MODEL = 'gpt-4.1-mini';
11821
- const GPT_5_4_HIGH_CONTEXT_THRESHOLD_TOKENS = 272_000;
11822
- const GPT_5_4_HIGH_CONTEXT_INPUT_MULTIPLIER = 2;
11823
- const GPT_5_4_HIGH_CONTEXT_OUTPUT_MULTIPLIER = 1.5;
11824
- /** Token costs in USD per 1M tokens. Last updated Mar 2026. */
11624
+ const DEFAULT_MODEL = 'gpt-5-mini';
11625
+ const GPT_5_HIGH_CONTEXT_THRESHOLD_TOKENS = 272_000;
11626
+ const GPT_5_HIGH_CONTEXT_INPUT_MULTIPLIER = 2;
11627
+ const GPT_5_HIGH_CONTEXT_OUTPUT_MULTIPLIER = 1.5;
11628
+ /** Token costs in USD per 1M tokens. Last updated May 2026. */
11825
11629
  const openAiModelCosts = {
11826
- 'gpt-4o': {
11827
- inputCost: 2.5 / 1_000_000,
11828
- cacheHitCost: 1.25 / 1_000_000,
11829
- outputCost: 10 / 1_000_000,
11830
- },
11831
- 'gpt-4o-mini': {
11832
- inputCost: 0.15 / 1_000_000,
11833
- cacheHitCost: 0.075 / 1_000_000,
11834
- outputCost: 0.6 / 1_000_000,
11835
- },
11836
- 'o1-mini': {
11837
- inputCost: 1.1 / 1_000_000,
11838
- cacheHitCost: 0.55 / 1_000_000,
11839
- outputCost: 4.4 / 1_000_000,
11840
- },
11841
- 'o1': {
11842
- inputCost: 15 / 1_000_000,
11843
- cacheHitCost: 7.5 / 1_000_000,
11844
- outputCost: 60 / 1_000_000,
11845
- },
11846
- 'o3-mini': {
11847
- inputCost: 1.1 / 1_000_000,
11848
- cacheHitCost: 0.55 / 1_000_000,
11849
- outputCost: 4.4 / 1_000_000,
11850
- },
11851
- 'o3': {
11852
- inputCost: 2 / 1_000_000,
11853
- cacheHitCost: 0.5 / 1_000_000,
11854
- outputCost: 8 / 1_000_000,
11855
- },
11856
- 'gpt-4.1': {
11857
- inputCost: 2 / 1_000_000,
11858
- cacheHitCost: 0.5 / 1_000_000,
11859
- outputCost: 8 / 1_000_000,
11860
- },
11861
- 'gpt-4.1-mini': {
11862
- inputCost: 0.4 / 1_000_000,
11863
- cacheHitCost: 0.1 / 1_000_000,
11864
- outputCost: 1.6 / 1_000_000,
11865
- },
11866
- 'gpt-4.1-nano': {
11867
- inputCost: 0.1 / 1_000_000,
11868
- cacheHitCost: 0.025 / 1_000_000,
11869
- outputCost: 0.4 / 1_000_000,
11870
- },
11871
11630
  'gpt-5': {
11872
11631
  inputCost: 1.25 / 1_000_000,
11873
11632
  cacheHitCost: 0.125 / 1_000_000,
@@ -11898,7 +11657,12 @@ const openAiModelCosts = {
11898
11657
  cacheHitCost: 0.25 / 1_000_000,
11899
11658
  outputCost: 15 / 1_000_000,
11900
11659
  },
11901
- 'gpt-5.4-pro': {
11660
+ 'gpt-5.5': {
11661
+ inputCost: 5 / 1_000_000,
11662
+ cacheHitCost: 0.5 / 1_000_000,
11663
+ outputCost: 30 / 1_000_000,
11664
+ },
11665
+ 'gpt-5.5-pro': {
11902
11666
  inputCost: 30 / 1_000_000,
11903
11667
  outputCost: 180 / 1_000_000,
11904
11668
  },
@@ -11921,11 +11685,6 @@ const openAiModelCosts = {
11921
11685
  cacheHitCost: 0.125 / 1_000_000,
11922
11686
  outputCost: 10 / 1_000_000,
11923
11687
  },
11924
- 'o4-mini': {
11925
- inputCost: 1.1 / 1_000_000,
11926
- cacheHitCost: 0.275 / 1_000_000,
11927
- outputCost: 4.4 / 1_000_000,
11928
- },
11929
11688
  };
11930
11689
  const deepseekModelCosts = {
11931
11690
  'deepseek-chat': {
@@ -11939,8 +11698,8 @@ const deepseekModelCosts = {
11939
11698
  outputCost: 2.19 / 1_000_000, // $2.19 per 1M tokens
11940
11699
  },
11941
11700
  };
11942
- function shouldUseGPT54HighContextPricing(model, inputTokens) {
11943
- return (model === 'gpt-5.4' || model === 'gpt-5.4-pro') && inputTokens > GPT_5_4_HIGH_CONTEXT_THRESHOLD_TOKENS;
11701
+ function shouldUseGPT5HighContextPricing(model, inputTokens) {
11702
+ return (model === 'gpt-5.4' || model === 'gpt-5.5') && inputTokens > GPT_5_HIGH_CONTEXT_THRESHOLD_TOKENS;
11944
11703
  }
11945
11704
  /** Image generation costs in USD per image. Based on OpenAI pricing as of Feb 2025. */
11946
11705
  const openAiImageCosts = {
@@ -11993,10 +11752,10 @@ function calculateCost(provider, model, inputTokens, outputTokens, reasoningToke
11993
11752
  }
11994
11753
  let outputCost = outputTokens * modelCosts.outputCost;
11995
11754
  let reasoningCost = (reasoningTokens || 0) * modelCosts.outputCost;
11996
- if (provider === 'openai' && shouldUseGPT54HighContextPricing(model, inputTokens)) {
11997
- inputCost *= GPT_5_4_HIGH_CONTEXT_INPUT_MULTIPLIER;
11998
- outputCost *= GPT_5_4_HIGH_CONTEXT_OUTPUT_MULTIPLIER;
11999
- reasoningCost *= GPT_5_4_HIGH_CONTEXT_OUTPUT_MULTIPLIER;
11755
+ if (provider === 'openai' && shouldUseGPT5HighContextPricing(model, inputTokens)) {
11756
+ inputCost *= GPT_5_HIGH_CONTEXT_INPUT_MULTIPLIER;
11757
+ outputCost *= GPT_5_HIGH_CONTEXT_OUTPUT_MULTIPLIER;
11758
+ reasoningCost *= GPT_5_HIGH_CONTEXT_OUTPUT_MULTIPLIER;
12000
11759
  }
12001
11760
  return inputCost + outputCost + reasoningCost;
12002
11761
  }
@@ -12381,94 +12140,13 @@ async function parseResponse(content, responseFormat) {
12381
12140
  }
12382
12141
 
12383
12142
  // llm-openai.ts
12384
- const isSupportedModel = (model) => {
12385
- return [
12386
- 'gpt-4o-mini',
12387
- 'gpt-4o',
12388
- 'o1-mini',
12389
- 'o1',
12390
- 'o3-mini',
12391
- 'gpt-4.1',
12392
- 'gpt-4.1-mini',
12393
- 'gpt-4.1-nano',
12394
- 'gpt-5',
12395
- 'gpt-5-mini',
12396
- 'gpt-5.4-mini',
12397
- 'gpt-5-nano',
12398
- 'gpt-5.1',
12399
- 'gpt-5.4',
12400
- 'gpt-5.4-pro',
12401
- 'gpt-5.2',
12402
- 'gpt-5.2-pro',
12403
- 'gpt-5.1-codex',
12404
- 'gpt-5.1-codex-max',
12405
- 'o4-mini',
12406
- 'o3',
12407
- ].includes(model);
12408
- };
12409
12143
  /**
12410
- * Checks if the given model supports the temperature parameter. Reasoning models (o1*, o3*, o4*) do not support temperature.
12144
+ * Checks if the given direct OpenAI model supports the temperature parameter.
12411
12145
  * @param model The model to check.
12412
12146
  * @returns True if the model supports the temperature parameter, false otherwise.
12413
12147
  */
12414
- function supportsTemperature(model) {
12415
- // Reasoning models don't support temperature
12416
- // GPT-5 models also do not support temperature
12417
- const reasoningAndGPT5Models = [
12418
- 'o1',
12419
- 'o1-mini',
12420
- 'o3-mini',
12421
- 'o4-mini',
12422
- 'o3',
12423
- 'gpt-5',
12424
- 'gpt-5-mini',
12425
- 'gpt-5.4-mini',
12426
- 'gpt-5-nano',
12427
- 'gpt-5.1',
12428
- 'gpt-5.4',
12429
- 'gpt-5.4-pro',
12430
- 'gpt-5.2',
12431
- 'gpt-5.2-pro',
12432
- 'gpt-5.1-codex',
12433
- 'gpt-5.1-codex-max',
12434
- ];
12435
- return !reasoningAndGPT5Models.includes(model);
12436
- }
12437
- /**
12438
- * Checks if the given model is a reasoning model. Reasoning models have different tool choice constraints.
12439
- * @param model The model to check.
12440
- * @returns True if the model is a reasoning model, false otherwise.
12441
- */
12442
- function isReasoningModel(model) {
12443
- const reasoningModels = ['o1', 'o1-mini', 'o3-mini', 'o4-mini', 'o3'];
12444
- return reasoningModels.includes(model);
12445
- }
12446
- /**
12447
- * Checks if the given model is a GPT-5 model. GPT-5 models don't support tool_choice other than 'auto'.
12448
- * @param model The model to check.
12449
- * @returns True if the model is a GPT-5 model, false otherwise.
12450
- */
12451
- function isGPT5Model(model) {
12452
- const gpt5Models = [
12453
- 'gpt-5',
12454
- 'gpt-5-mini',
12455
- 'gpt-5.4-mini',
12456
- 'gpt-5-nano',
12457
- 'gpt-5.1',
12458
- 'gpt-5.4',
12459
- 'gpt-5.4-pro',
12460
- 'gpt-5.2',
12461
- 'gpt-5.2-pro',
12462
- 'gpt-5.1-codex',
12463
- 'gpt-5.1-codex-max',
12464
- ];
12465
- return gpt5Models.includes(model);
12466
- }
12467
- function supportsStructuredOutputs(model) {
12468
- return normalizeModelName(model) !== 'gpt-5.4-pro';
12469
- }
12470
- function supportsDistillation(model) {
12471
- return normalizeModelName(model) !== 'gpt-5.4-pro';
12148
+ function supportsTemperature(_model) {
12149
+ return false;
12472
12150
  }
12473
12151
  function isZodSchema(schema) {
12474
12152
  return typeof schema === 'object' && schema !== null && 'safeParse' in schema;
@@ -12503,7 +12181,7 @@ function buildJsonSchemaFormat(schema, schemaName, schemaDescription, schemaStri
12503
12181
  * - Built-in tools (web search, file search, computer use, code interpreter, image generation)
12504
12182
  * - Background processing
12505
12183
  * - Conversation state management
12506
- * - Reasoning support for o-series models
12184
+ * - GPT-5 reasoning controls
12507
12185
  *
12508
12186
  * @example
12509
12187
  * // Basic text response
@@ -12524,6 +12202,9 @@ function buildJsonSchemaFormat(schema, schemaName, schemaDescription, schemaStri
12524
12202
  */
12525
12203
  const makeResponsesAPICall = async (input, options = {}) => {
12526
12204
  const normalizedModel = normalizeModelName(options.model || DEFAULT_MODEL);
12205
+ if (!isOpenAIModel(normalizedModel)) {
12206
+ throw new Error(`Unsupported OpenAI model: ${normalizedModel}. Please use a supported GPT-5 model.`);
12207
+ }
12527
12208
  const apiKey = options.apiKey || process.env.OPENAI_API_KEY;
12528
12209
  if (!apiKey) {
12529
12210
  throw new Error('OpenAI API key is not provided and OPENAI_API_KEY environment variable is not set');
@@ -12538,12 +12219,6 @@ const makeResponsesAPICall = async (input, options = {}) => {
12538
12219
  input,
12539
12220
  ...cleanOptions,
12540
12221
  };
12541
- if (requestBody.text?.format?.type === 'json_schema' && !supportsStructuredOutputs(normalizedModel)) {
12542
- throw new Error(`Model ${normalizedModel} does not support structured outputs`);
12543
- }
12544
- if (requestBody.store && !supportsDistillation(normalizedModel)) {
12545
- throw new Error(`Model ${normalizedModel} does not support distillation`);
12546
- }
12547
12222
  // Make the API call to the Responses endpoint
12548
12223
  const response = await openai.responses.create(requestBody);
12549
12224
  const cacheHitTokens = response.usage?.input_tokens_details?.cached_tokens || 0;
@@ -12650,8 +12325,8 @@ async function makeLLMCall(input, options = {}) {
12650
12325
  const { apiKey, model = DEFAULT_MODEL, responseFormat = 'text', schema, schemaName = 'response', schemaDescription, schemaStrict, tools, useCodeInterpreter = false, useWebSearch = false, imageBase64, imageDetail = 'high', context, } = options;
12651
12326
  // Validate model
12652
12327
  const normalizedModel = normalizeModelName(model);
12653
- if (!isSupportedModel(normalizedModel)) {
12654
- throw new Error(`Unsupported model: ${normalizedModel}. Please use one of the supported models.`);
12328
+ if (!isOpenAIModel(normalizedModel)) {
12329
+ throw new Error(`Unsupported OpenAI model: ${normalizedModel}. Please use a supported GPT-5 model.`);
12655
12330
  }
12656
12331
  // Process input for conversation context and image analysis
12657
12332
  let processedInput;
@@ -12720,10 +12395,6 @@ async function makeLLMCall(input, options = {}) {
12720
12395
  parallel_tool_calls: false,
12721
12396
  tools,
12722
12397
  };
12723
- // Only include temperature if the model supports it
12724
- if (supportsTemperature(normalizedModel)) {
12725
- responsesOptions.temperature = 0.2;
12726
- }
12727
12398
  // Configure response format
12728
12399
  if (schema) {
12729
12400
  responsesOptions.text = {
@@ -12739,39 +12410,17 @@ async function makeLLMCall(input, options = {}) {
12739
12410
  // Configure built-in tools
12740
12411
  if (useCodeInterpreter) {
12741
12412
  responsesOptions.tools = [{ type: 'code_interpreter', container: { type: 'auto' } }];
12742
- // For reasoning models, we can't force tool choice - they only support 'auto'
12743
- if (!isReasoningModel(normalizedModel)) {
12744
- responsesOptions.tool_choice = { type: 'code_interpreter' };
12745
- }
12746
12413
  responsesOptions.include = ['code_interpreter_call.outputs'];
12747
12414
  }
12748
12415
  if (useWebSearch) {
12749
12416
  responsesOptions.tools = [{ type: 'web_search_preview' }];
12750
- // For reasoning models and GPT-5 models, we can't force tool choice - they only support 'auto'
12751
- if (!isReasoningModel(normalizedModel) && !isGPT5Model(normalizedModel)) {
12752
- responsesOptions.tool_choice = { type: 'web_search_preview' };
12753
- }
12754
12417
  }
12755
12418
  return await makeResponsesAPICall(processedInput, responsesOptions);
12756
12419
  }
12757
12420
 
12758
12421
  const DEFAULT_IMAGE_MODEL = 'gpt-image-1.5';
12759
12422
  const resolveImageModel = (model) => model ?? DEFAULT_IMAGE_MODEL;
12760
- const MULTIMODAL_VISION_MODELS = new Set([
12761
- 'gpt-4o-mini',
12762
- 'gpt-4o',
12763
- 'gpt-5',
12764
- 'gpt-5-mini',
12765
- 'gpt-5.4-mini',
12766
- 'gpt-5-nano',
12767
- 'gpt-5.1',
12768
- 'gpt-5.4',
12769
- 'gpt-5.4-pro',
12770
- 'gpt-5.2',
12771
- 'gpt-5.2-pro',
12772
- 'gpt-5.1-codex',
12773
- 'gpt-5.1-codex-max',
12774
- ]);
12423
+ const MULTIMODAL_VISION_MODELS = new Set(OPENAI_MODELS);
12775
12424
  /**
12776
12425
  * Makes a call to the OpenAI Images API to generate images based on a text prompt.
12777
12426
  *
@@ -21913,5 +21562,5 @@ const disco = {
21913
21562
  },
21914
21563
  };
21915
21564
 
21916
- export { AlpacaMarketDataAPI, AlpacaTradingAPI, disco, isOpenRouterModel };
21565
+ export { AlpacaMarketDataAPI, AlpacaTradingAPI, OPENAI_MODELS, disco, isOpenAIModel, isOpenRouterModel, supportsTemperature };
21917
21566
  //# sourceMappingURL=index.mjs.map