@ai-sdk/openai 2.0.0-canary.11 → 2.0.0-canary.13

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.
@@ -27,7 +27,10 @@ __export(internal_exports, {
27
27
  OpenAIResponsesLanguageModel: () => OpenAIResponsesLanguageModel,
28
28
  OpenAISpeechModel: () => OpenAISpeechModel,
29
29
  OpenAITranscriptionModel: () => OpenAITranscriptionModel,
30
+ hasDefaultResponseFormat: () => hasDefaultResponseFormat,
30
31
  modelMaxImagesPerCall: () => modelMaxImagesPerCall,
32
+ openAITranscriptionProviderOptions: () => openAITranscriptionProviderOptions,
33
+ openaiCompletionProviderOptions: () => openaiCompletionProviderOptions,
31
34
  openaiEmbeddingProviderOptions: () => openaiEmbeddingProviderOptions,
32
35
  openaiProviderOptions: () => openaiProviderOptions
33
36
  });
@@ -271,7 +274,13 @@ var openaiProviderOptions = import_zod.z.object({
271
274
  /**
272
275
  * Parameters for prediction mode.
273
276
  */
274
- prediction: import_zod.z.record(import_zod.z.any()).optional()
277
+ prediction: import_zod.z.record(import_zod.z.any()).optional(),
278
+ /**
279
+ * Whether to use structured outputs.
280
+ *
281
+ * @default true
282
+ */
283
+ structuredOutputs: import_zod.z.boolean().optional()
275
284
  });
276
285
 
277
286
  // src/openai-error.ts
@@ -352,10 +361,9 @@ function prepareTools({
352
361
 
353
362
  // src/openai-chat-language-model.ts
354
363
  var OpenAIChatLanguageModel = class {
355
- constructor(modelId, settings, config) {
364
+ constructor(modelId, config) {
356
365
  this.specificationVersion = "v2";
357
366
  this.modelId = modelId;
358
- this.settings = settings;
359
367
  this.config = config;
360
368
  }
361
369
  get provider() {
@@ -366,7 +374,7 @@ var OpenAIChatLanguageModel = class {
366
374
  "image/*": [/^https?:\/\/.*$/]
367
375
  };
368
376
  }
369
- getArgs({
377
+ async getArgs({
370
378
  prompt,
371
379
  maxOutputTokens,
372
380
  temperature,
@@ -383,18 +391,19 @@ var OpenAIChatLanguageModel = class {
383
391
  }) {
384
392
  var _a, _b, _c;
385
393
  const warnings = [];
386
- const openaiOptions = (_a = (0, import_provider_utils3.parseProviderOptions)({
394
+ const openaiOptions = (_a = await (0, import_provider_utils3.parseProviderOptions)({
387
395
  provider: "openai",
388
396
  providerOptions,
389
397
  schema: openaiProviderOptions
390
398
  })) != null ? _a : {};
399
+ const structuredOutputs = (_b = openaiOptions.structuredOutputs) != null ? _b : true;
391
400
  if (topK != null) {
392
401
  warnings.push({
393
402
  type: "unsupported-setting",
394
403
  setting: "topK"
395
404
  });
396
405
  }
397
- if ((responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !this.settings.structuredOutputs) {
406
+ if ((responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !structuredOutputs) {
398
407
  warnings.push({
399
408
  type: "unsupported-setting",
400
409
  setting: "responseFormat",
@@ -423,12 +432,12 @@ var OpenAIChatLanguageModel = class {
423
432
  presence_penalty: presencePenalty,
424
433
  response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? (
425
434
  // TODO convert into provider option
426
- this.settings.structuredOutputs && responseFormat.schema != null ? {
435
+ structuredOutputs && responseFormat.schema != null ? {
427
436
  type: "json_schema",
428
437
  json_schema: {
429
438
  schema: responseFormat.schema,
430
439
  strict: true,
431
- name: (_b = responseFormat.name) != null ? _b : "response",
440
+ name: (_c = responseFormat.name) != null ? _c : "response",
432
441
  description: responseFormat.description
433
442
  }
434
443
  } : { type: "json_object" }
@@ -508,7 +517,7 @@ var OpenAIChatLanguageModel = class {
508
517
  } = prepareTools({
509
518
  tools,
510
519
  toolChoice,
511
- structuredOutputs: (_c = this.settings.structuredOutputs) != null ? _c : false
520
+ structuredOutputs
512
521
  });
513
522
  return {
514
523
  args: {
@@ -521,7 +530,7 @@ var OpenAIChatLanguageModel = class {
521
530
  }
522
531
  async doGenerate(options) {
523
532
  var _a, _b, _c, _d, _e, _f, _g, _h;
524
- const { args: body, warnings } = this.getArgs(options);
533
+ const { args: body, warnings } = await this.getArgs(options);
525
534
  const {
526
535
  responseHeaders,
527
536
  value: response,
@@ -588,7 +597,7 @@ var OpenAIChatLanguageModel = class {
588
597
  };
589
598
  }
590
599
  async doStream(options) {
591
- const { args, warnings } = this.getArgs(options);
600
+ const { args, warnings } = await this.getArgs(options);
592
601
  const body = {
593
602
  ...args,
594
603
  stream: true,
@@ -878,19 +887,15 @@ var reasoningModels = {
878
887
 
879
888
  // src/openai-completion-language-model.ts
880
889
  var import_provider_utils4 = require("@ai-sdk/provider-utils");
881
- var import_zod4 = require("zod");
890
+ var import_zod5 = require("zod");
882
891
 
883
892
  // src/convert-to-openai-completion-prompt.ts
884
893
  var import_provider4 = require("@ai-sdk/provider");
885
894
  function convertToOpenAICompletionPrompt({
886
895
  prompt,
887
- inputFormat,
888
896
  user = "user",
889
897
  assistant = "assistant"
890
898
  }) {
891
- if (inputFormat === "prompt" && prompt.length === 1 && prompt[0].role === "user" && prompt[0].content.length === 1 && prompt[0].content[0].type === "text") {
892
- return { prompt: prompt[0].content[0].text };
893
- }
894
899
  let text = "";
895
900
  if (prompt[0].role === "system") {
896
901
  text += `${prompt[0].content}
@@ -959,14 +964,49 @@ ${user}:`]
959
964
  };
960
965
  }
961
966
 
967
+ // src/openai-completion-options.ts
968
+ var import_zod4 = require("zod");
969
+ var openaiCompletionProviderOptions = import_zod4.z.object({
970
+ /**
971
+ Echo back the prompt in addition to the completion.
972
+ */
973
+ echo: import_zod4.z.boolean().optional(),
974
+ /**
975
+ Modify the likelihood of specified tokens appearing in the completion.
976
+
977
+ Accepts a JSON object that maps tokens (specified by their token ID in
978
+ the GPT tokenizer) to an associated bias value from -100 to 100. You
979
+ can use this tokenizer tool to convert text to token IDs. Mathematically,
980
+ the bias is added to the logits generated by the model prior to sampling.
981
+ The exact effect will vary per model, but values between -1 and 1 should
982
+ decrease or increase likelihood of selection; values like -100 or 100
983
+ should result in a ban or exclusive selection of the relevant token.
984
+
985
+ As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
986
+ token from being generated.
987
+ */
988
+ logitBias: import_zod4.z.record(import_zod4.z.string(), import_zod4.z.number()).optional(),
989
+ /**
990
+ The suffix that comes after a completion of inserted text.
991
+ */
992
+ suffix: import_zod4.z.string().optional(),
993
+ /**
994
+ A unique identifier representing your end-user, which can help OpenAI to
995
+ monitor and detect abuse. Learn more.
996
+ */
997
+ user: import_zod4.z.string().optional()
998
+ });
999
+
962
1000
  // src/openai-completion-language-model.ts
963
1001
  var OpenAICompletionLanguageModel = class {
964
- constructor(modelId, settings, config) {
1002
+ constructor(modelId, config) {
965
1003
  this.specificationVersion = "v2";
966
1004
  this.modelId = modelId;
967
- this.settings = settings;
968
1005
  this.config = config;
969
1006
  }
1007
+ get providerOptionsName() {
1008
+ return this.config.provider.split(".")[0].trim();
1009
+ }
970
1010
  get provider() {
971
1011
  return this.config.provider;
972
1012
  }
@@ -975,8 +1015,7 @@ var OpenAICompletionLanguageModel = class {
975
1015
  // no supported urls for completion models
976
1016
  };
977
1017
  }
978
- getArgs({
979
- inputFormat,
1018
+ async getArgs({
980
1019
  prompt,
981
1020
  maxOutputTokens,
982
1021
  temperature,
@@ -988,9 +1027,22 @@ var OpenAICompletionLanguageModel = class {
988
1027
  responseFormat,
989
1028
  tools,
990
1029
  toolChoice,
991
- seed
1030
+ seed,
1031
+ providerOptions
992
1032
  }) {
993
1033
  const warnings = [];
1034
+ const openaiOptions = {
1035
+ ...await (0, import_provider_utils4.parseProviderOptions)({
1036
+ provider: "openai",
1037
+ providerOptions,
1038
+ schema: openaiCompletionProviderOptions
1039
+ }),
1040
+ ...await (0, import_provider_utils4.parseProviderOptions)({
1041
+ provider: this.providerOptionsName,
1042
+ providerOptions,
1043
+ schema: openaiCompletionProviderOptions
1044
+ })
1045
+ };
994
1046
  if (topK != null) {
995
1047
  warnings.push({ type: "unsupported-setting", setting: "topK" });
996
1048
  }
@@ -1007,17 +1059,17 @@ var OpenAICompletionLanguageModel = class {
1007
1059
  details: "JSON response format is not supported."
1008
1060
  });
1009
1061
  }
1010
- const { prompt: completionPrompt, stopSequences } = convertToOpenAICompletionPrompt({ prompt, inputFormat });
1062
+ const { prompt: completionPrompt, stopSequences } = convertToOpenAICompletionPrompt({ prompt });
1011
1063
  const stop = [...stopSequences != null ? stopSequences : [], ...userStopSequences != null ? userStopSequences : []];
1012
1064
  return {
1013
1065
  args: {
1014
1066
  // model id:
1015
1067
  model: this.modelId,
1016
1068
  // model specific settings:
1017
- echo: this.settings.echo,
1018
- logit_bias: this.settings.logitBias,
1019
- suffix: this.settings.suffix,
1020
- user: this.settings.user,
1069
+ echo: openaiOptions.echo,
1070
+ logit_bias: openaiOptions.logitBias,
1071
+ suffix: openaiOptions.suffix,
1072
+ user: openaiOptions.user,
1021
1073
  // standardized settings:
1022
1074
  max_tokens: maxOutputTokens,
1023
1075
  temperature,
@@ -1034,7 +1086,7 @@ var OpenAICompletionLanguageModel = class {
1034
1086
  };
1035
1087
  }
1036
1088
  async doGenerate(options) {
1037
- const { args, warnings } = this.getArgs(options);
1089
+ const { args, warnings } = await this.getArgs(options);
1038
1090
  const {
1039
1091
  responseHeaders,
1040
1092
  value: response,
@@ -1071,7 +1123,7 @@ var OpenAICompletionLanguageModel = class {
1071
1123
  };
1072
1124
  }
1073
1125
  async doStream(options) {
1074
- const { args, warnings } = this.getArgs(options);
1126
+ const { args, warnings } = await this.getArgs(options);
1075
1127
  const body = {
1076
1128
  ...args,
1077
1129
  stream: true,
@@ -1152,36 +1204,36 @@ var OpenAICompletionLanguageModel = class {
1152
1204
  };
1153
1205
  }
1154
1206
  };
1155
- var openaiCompletionResponseSchema = import_zod4.z.object({
1156
- id: import_zod4.z.string().nullish(),
1157
- created: import_zod4.z.number().nullish(),
1158
- model: import_zod4.z.string().nullish(),
1159
- choices: import_zod4.z.array(
1160
- import_zod4.z.object({
1161
- text: import_zod4.z.string(),
1162
- finish_reason: import_zod4.z.string()
1207
+ var openaiCompletionResponseSchema = import_zod5.z.object({
1208
+ id: import_zod5.z.string().nullish(),
1209
+ created: import_zod5.z.number().nullish(),
1210
+ model: import_zod5.z.string().nullish(),
1211
+ choices: import_zod5.z.array(
1212
+ import_zod5.z.object({
1213
+ text: import_zod5.z.string(),
1214
+ finish_reason: import_zod5.z.string()
1163
1215
  })
1164
1216
  ),
1165
- usage: import_zod4.z.object({
1166
- prompt_tokens: import_zod4.z.number(),
1167
- completion_tokens: import_zod4.z.number()
1217
+ usage: import_zod5.z.object({
1218
+ prompt_tokens: import_zod5.z.number(),
1219
+ completion_tokens: import_zod5.z.number()
1168
1220
  })
1169
1221
  });
1170
- var openaiCompletionChunkSchema = import_zod4.z.union([
1171
- import_zod4.z.object({
1172
- id: import_zod4.z.string().nullish(),
1173
- created: import_zod4.z.number().nullish(),
1174
- model: import_zod4.z.string().nullish(),
1175
- choices: import_zod4.z.array(
1176
- import_zod4.z.object({
1177
- text: import_zod4.z.string(),
1178
- finish_reason: import_zod4.z.string().nullish(),
1179
- index: import_zod4.z.number()
1222
+ var openaiCompletionChunkSchema = import_zod5.z.union([
1223
+ import_zod5.z.object({
1224
+ id: import_zod5.z.string().nullish(),
1225
+ created: import_zod5.z.number().nullish(),
1226
+ model: import_zod5.z.string().nullish(),
1227
+ choices: import_zod5.z.array(
1228
+ import_zod5.z.object({
1229
+ text: import_zod5.z.string(),
1230
+ finish_reason: import_zod5.z.string().nullish(),
1231
+ index: import_zod5.z.number()
1180
1232
  })
1181
1233
  ),
1182
- usage: import_zod4.z.object({
1183
- prompt_tokens: import_zod4.z.number(),
1184
- completion_tokens: import_zod4.z.number()
1234
+ usage: import_zod5.z.object({
1235
+ prompt_tokens: import_zod5.z.number(),
1236
+ completion_tokens: import_zod5.z.number()
1185
1237
  }).nullish()
1186
1238
  }),
1187
1239
  openaiErrorDataSchema
@@ -1190,42 +1242,35 @@ var openaiCompletionChunkSchema = import_zod4.z.union([
1190
1242
  // src/openai-embedding-model.ts
1191
1243
  var import_provider5 = require("@ai-sdk/provider");
1192
1244
  var import_provider_utils5 = require("@ai-sdk/provider-utils");
1193
- var import_zod6 = require("zod");
1245
+ var import_zod7 = require("zod");
1194
1246
 
1195
1247
  // src/openai-embedding-options.ts
1196
- var import_zod5 = require("zod");
1197
- var openaiEmbeddingProviderOptions = import_zod5.z.object({
1248
+ var import_zod6 = require("zod");
1249
+ var openaiEmbeddingProviderOptions = import_zod6.z.object({
1198
1250
  /**
1199
1251
  The number of dimensions the resulting output embeddings should have.
1200
1252
  Only supported in text-embedding-3 and later models.
1201
1253
  */
1202
- dimensions: import_zod5.z.number().optional(),
1254
+ dimensions: import_zod6.z.number().optional(),
1203
1255
  /**
1204
1256
  A unique identifier representing your end-user, which can help OpenAI to
1205
1257
  monitor and detect abuse. Learn more.
1206
1258
  */
1207
- user: import_zod5.z.string().optional()
1259
+ user: import_zod6.z.string().optional()
1208
1260
  });
1209
1261
 
1210
1262
  // src/openai-embedding-model.ts
1211
1263
  var OpenAIEmbeddingModel = class {
1212
- constructor(modelId, settings, config) {
1264
+ constructor(modelId, config) {
1213
1265
  this.specificationVersion = "v2";
1266
+ this.maxEmbeddingsPerCall = 2048;
1267
+ this.supportsParallelCalls = true;
1214
1268
  this.modelId = modelId;
1215
- this.settings = settings;
1216
1269
  this.config = config;
1217
1270
  }
1218
1271
  get provider() {
1219
1272
  return this.config.provider;
1220
1273
  }
1221
- get maxEmbeddingsPerCall() {
1222
- var _a;
1223
- return (_a = this.settings.maxEmbeddingsPerCall) != null ? _a : 2048;
1224
- }
1225
- get supportsParallelCalls() {
1226
- var _a;
1227
- return (_a = this.settings.supportsParallelCalls) != null ? _a : true;
1228
- }
1229
1274
  async doEmbed({
1230
1275
  values,
1231
1276
  headers,
@@ -1241,7 +1286,7 @@ var OpenAIEmbeddingModel = class {
1241
1286
  values
1242
1287
  });
1243
1288
  }
1244
- const openaiOptions = (_a = (0, import_provider_utils5.parseProviderOptions)({
1289
+ const openaiOptions = (_a = await (0, import_provider_utils5.parseProviderOptions)({
1245
1290
  provider: "openai",
1246
1291
  providerOptions,
1247
1292
  schema: openaiEmbeddingProviderOptions
@@ -1277,20 +1322,22 @@ var OpenAIEmbeddingModel = class {
1277
1322
  };
1278
1323
  }
1279
1324
  };
1280
- var openaiTextEmbeddingResponseSchema = import_zod6.z.object({
1281
- data: import_zod6.z.array(import_zod6.z.object({ embedding: import_zod6.z.array(import_zod6.z.number()) })),
1282
- usage: import_zod6.z.object({ prompt_tokens: import_zod6.z.number() }).nullish()
1325
+ var openaiTextEmbeddingResponseSchema = import_zod7.z.object({
1326
+ data: import_zod7.z.array(import_zod7.z.object({ embedding: import_zod7.z.array(import_zod7.z.number()) })),
1327
+ usage: import_zod7.z.object({ prompt_tokens: import_zod7.z.number() }).nullish()
1283
1328
  });
1284
1329
 
1285
1330
  // src/openai-image-model.ts
1286
1331
  var import_provider_utils6 = require("@ai-sdk/provider-utils");
1287
- var import_zod7 = require("zod");
1332
+ var import_zod8 = require("zod");
1288
1333
 
1289
1334
  // src/openai-image-settings.ts
1290
1335
  var modelMaxImagesPerCall = {
1291
1336
  "dall-e-3": 1,
1292
- "dall-e-2": 10
1337
+ "dall-e-2": 10,
1338
+ "gpt-image-1": 10
1293
1339
  };
1340
+ var hasDefaultResponseFormat = /* @__PURE__ */ new Set(["gpt-image-1"]);
1294
1341
 
1295
1342
  // src/openai-image-model.ts
1296
1343
  var OpenAIImageModel = class {
@@ -1342,7 +1389,7 @@ var OpenAIImageModel = class {
1342
1389
  n,
1343
1390
  size,
1344
1391
  ...(_d = providerOptions.openai) != null ? _d : {},
1345
- response_format: "b64_json"
1392
+ ...!hasDefaultResponseFormat.has(this.modelId) ? { response_format: "b64_json" } : {}
1346
1393
  },
1347
1394
  failedResponseHandler: openaiFailedResponseHandler,
1348
1395
  successfulResponseHandler: (0, import_provider_utils6.createJsonResponseHandler)(
@@ -1362,20 +1409,42 @@ var OpenAIImageModel = class {
1362
1409
  };
1363
1410
  }
1364
1411
  };
1365
- var openaiImageResponseSchema = import_zod7.z.object({
1366
- data: import_zod7.z.array(import_zod7.z.object({ b64_json: import_zod7.z.string() }))
1412
+ var openaiImageResponseSchema = import_zod8.z.object({
1413
+ data: import_zod8.z.array(import_zod8.z.object({ b64_json: import_zod8.z.string() }))
1367
1414
  });
1368
1415
 
1369
1416
  // src/openai-transcription-model.ts
1370
1417
  var import_provider_utils7 = require("@ai-sdk/provider-utils");
1371
- var import_zod8 = require("zod");
1372
- var openAIProviderOptionsSchema = import_zod8.z.object({
1373
- include: import_zod8.z.array(import_zod8.z.string()).nullish(),
1374
- language: import_zod8.z.string().nullish(),
1375
- prompt: import_zod8.z.string().nullish(),
1376
- temperature: import_zod8.z.number().min(0).max(1).nullish().default(0),
1377
- timestampGranularities: import_zod8.z.array(import_zod8.z.enum(["word", "segment"])).nullish().default(["segment"])
1418
+ var import_zod10 = require("zod");
1419
+
1420
+ // src/openai-transcription-options.ts
1421
+ var import_zod9 = require("zod");
1422
+ var openAITranscriptionProviderOptions = import_zod9.z.object({
1423
+ /**
1424
+ * Additional information to include in the transcription response.
1425
+ */
1426
+ include: import_zod9.z.array(import_zod9.z.string()).nullish(),
1427
+ /**
1428
+ * The language of the input audio in ISO-639-1 format.
1429
+ */
1430
+ language: import_zod9.z.string().nullish(),
1431
+ /**
1432
+ * An optional text to guide the model's style or continue a previous audio segment.
1433
+ */
1434
+ prompt: import_zod9.z.string().nullish(),
1435
+ /**
1436
+ * The sampling temperature, between 0 and 1.
1437
+ * @default 0
1438
+ */
1439
+ temperature: import_zod9.z.number().min(0).max(1).default(0).nullish(),
1440
+ /**
1441
+ * The timestamp granularities to populate for this transcription.
1442
+ * @default ['segment']
1443
+ */
1444
+ timestampGranularities: import_zod9.z.array(import_zod9.z.enum(["word", "segment"])).default(["segment"]).nullish()
1378
1445
  });
1446
+
1447
+ // src/openai-transcription-model.ts
1379
1448
  var languageMap = {
1380
1449
  afrikaans: "af",
1381
1450
  arabic: "ar",
@@ -1444,17 +1513,16 @@ var OpenAITranscriptionModel = class {
1444
1513
  get provider() {
1445
1514
  return this.config.provider;
1446
1515
  }
1447
- getArgs({
1516
+ async getArgs({
1448
1517
  audio,
1449
1518
  mediaType,
1450
1519
  providerOptions
1451
1520
  }) {
1452
- var _a, _b, _c, _d, _e;
1453
1521
  const warnings = [];
1454
- const openAIOptions = (0, import_provider_utils7.parseProviderOptions)({
1522
+ const openAIOptions = await (0, import_provider_utils7.parseProviderOptions)({
1455
1523
  provider: "openai",
1456
1524
  providerOptions,
1457
- schema: openAIProviderOptionsSchema
1525
+ schema: openAITranscriptionProviderOptions
1458
1526
  });
1459
1527
  const formData = new FormData();
1460
1528
  const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([(0, import_provider_utils7.convertBase64ToUint8Array)(audio)]);
@@ -1462,15 +1530,14 @@ var OpenAITranscriptionModel = class {
1462
1530
  formData.append("file", new File([blob], "audio", { type: mediaType }));
1463
1531
  if (openAIOptions) {
1464
1532
  const transcriptionModelOptions = {
1465
- include: (_a = openAIOptions.include) != null ? _a : void 0,
1466
- language: (_b = openAIOptions.language) != null ? _b : void 0,
1467
- prompt: (_c = openAIOptions.prompt) != null ? _c : void 0,
1468
- temperature: (_d = openAIOptions.temperature) != null ? _d : void 0,
1469
- timestamp_granularities: (_e = openAIOptions.timestampGranularities) != null ? _e : void 0
1533
+ include: openAIOptions.include,
1534
+ language: openAIOptions.language,
1535
+ prompt: openAIOptions.prompt,
1536
+ temperature: openAIOptions.temperature,
1537
+ timestamp_granularities: openAIOptions.timestampGranularities
1470
1538
  };
1471
- for (const key in transcriptionModelOptions) {
1472
- const value = transcriptionModelOptions[key];
1473
- if (value !== void 0) {
1539
+ for (const [key, value] of Object.entries(transcriptionModelOptions)) {
1540
+ if (value != null) {
1474
1541
  formData.append(key, String(value));
1475
1542
  }
1476
1543
  }
@@ -1483,7 +1550,7 @@ var OpenAITranscriptionModel = class {
1483
1550
  async doGenerate(options) {
1484
1551
  var _a, _b, _c, _d, _e, _f;
1485
1552
  const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
1486
- const { formData, warnings } = this.getArgs(options);
1553
+ const { formData, warnings } = await this.getArgs(options);
1487
1554
  const {
1488
1555
  value: response,
1489
1556
  responseHeaders,
@@ -1522,25 +1589,25 @@ var OpenAITranscriptionModel = class {
1522
1589
  };
1523
1590
  }
1524
1591
  };
1525
- var openaiTranscriptionResponseSchema = import_zod8.z.object({
1526
- text: import_zod8.z.string(),
1527
- language: import_zod8.z.string().nullish(),
1528
- duration: import_zod8.z.number().nullish(),
1529
- words: import_zod8.z.array(
1530
- import_zod8.z.object({
1531
- word: import_zod8.z.string(),
1532
- start: import_zod8.z.number(),
1533
- end: import_zod8.z.number()
1592
+ var openaiTranscriptionResponseSchema = import_zod10.z.object({
1593
+ text: import_zod10.z.string(),
1594
+ language: import_zod10.z.string().nullish(),
1595
+ duration: import_zod10.z.number().nullish(),
1596
+ words: import_zod10.z.array(
1597
+ import_zod10.z.object({
1598
+ word: import_zod10.z.string(),
1599
+ start: import_zod10.z.number(),
1600
+ end: import_zod10.z.number()
1534
1601
  })
1535
1602
  ).nullish()
1536
1603
  });
1537
1604
 
1538
1605
  // src/openai-speech-model.ts
1539
1606
  var import_provider_utils8 = require("@ai-sdk/provider-utils");
1540
- var import_zod9 = require("zod");
1541
- var OpenAIProviderOptionsSchema = import_zod9.z.object({
1542
- instructions: import_zod9.z.string().nullish(),
1543
- speed: import_zod9.z.number().min(0.25).max(4).default(1).nullish()
1607
+ var import_zod11 = require("zod");
1608
+ var OpenAIProviderOptionsSchema = import_zod11.z.object({
1609
+ instructions: import_zod11.z.string().nullish(),
1610
+ speed: import_zod11.z.number().min(0.25).max(4).default(1).nullish()
1544
1611
  });
1545
1612
  var OpenAISpeechModel = class {
1546
1613
  constructor(modelId, config) {
@@ -1551,7 +1618,7 @@ var OpenAISpeechModel = class {
1551
1618
  get provider() {
1552
1619
  return this.config.provider;
1553
1620
  }
1554
- getArgs({
1621
+ async getArgs({
1555
1622
  text,
1556
1623
  voice = "alloy",
1557
1624
  outputFormat = "mp3",
@@ -1560,7 +1627,7 @@ var OpenAISpeechModel = class {
1560
1627
  providerOptions
1561
1628
  }) {
1562
1629
  const warnings = [];
1563
- const openAIOptions = (0, import_provider_utils8.parseProviderOptions)({
1630
+ const openAIOptions = await (0, import_provider_utils8.parseProviderOptions)({
1564
1631
  provider: "openai",
1565
1632
  providerOptions,
1566
1633
  schema: OpenAIProviderOptionsSchema
@@ -1601,7 +1668,7 @@ var OpenAISpeechModel = class {
1601
1668
  async doGenerate(options) {
1602
1669
  var _a, _b, _c;
1603
1670
  const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
1604
- const { requestBody, warnings } = this.getArgs(options);
1671
+ const { requestBody, warnings } = await this.getArgs(options);
1605
1672
  const {
1606
1673
  value: audio,
1607
1674
  responseHeaders,
@@ -1636,7 +1703,7 @@ var OpenAISpeechModel = class {
1636
1703
 
1637
1704
  // src/responses/openai-responses-language-model.ts
1638
1705
  var import_provider_utils9 = require("@ai-sdk/provider-utils");
1639
- var import_zod10 = require("zod");
1706
+ var import_zod12 = require("zod");
1640
1707
 
1641
1708
  // src/responses/convert-to-openai-responses-messages.ts
1642
1709
  var import_provider6 = require("@ai-sdk/provider");
@@ -1856,7 +1923,7 @@ var OpenAIResponsesLanguageModel = class {
1856
1923
  get provider() {
1857
1924
  return this.config.provider;
1858
1925
  }
1859
- getArgs({
1926
+ async getArgs({
1860
1927
  maxOutputTokens,
1861
1928
  temperature,
1862
1929
  stopSequences,
@@ -1900,7 +1967,7 @@ var OpenAIResponsesLanguageModel = class {
1900
1967
  systemMessageMode: modelConfig.systemMessageMode
1901
1968
  });
1902
1969
  warnings.push(...messageWarnings);
1903
- const openaiOptions = (0, import_provider_utils9.parseProviderOptions)({
1970
+ const openaiOptions = await (0, import_provider_utils9.parseProviderOptions)({
1904
1971
  provider: "openai",
1905
1972
  providerOptions,
1906
1973
  schema: openaiResponsesProviderOptionsSchema
@@ -1983,7 +2050,7 @@ var OpenAIResponsesLanguageModel = class {
1983
2050
  }
1984
2051
  async doGenerate(options) {
1985
2052
  var _a, _b, _c, _d, _e, _f, _g, _h;
1986
- const { args: body, warnings } = this.getArgs(options);
2053
+ const { args: body, warnings } = await this.getArgs(options);
1987
2054
  const {
1988
2055
  responseHeaders,
1989
2056
  value: response,
@@ -1997,55 +2064,55 @@ var OpenAIResponsesLanguageModel = class {
1997
2064
  body,
1998
2065
  failedResponseHandler: openaiFailedResponseHandler,
1999
2066
  successfulResponseHandler: (0, import_provider_utils9.createJsonResponseHandler)(
2000
- import_zod10.z.object({
2001
- id: import_zod10.z.string(),
2002
- created_at: import_zod10.z.number(),
2003
- model: import_zod10.z.string(),
2004
- output: import_zod10.z.array(
2005
- import_zod10.z.discriminatedUnion("type", [
2006
- import_zod10.z.object({
2007
- type: import_zod10.z.literal("message"),
2008
- role: import_zod10.z.literal("assistant"),
2009
- content: import_zod10.z.array(
2010
- import_zod10.z.object({
2011
- type: import_zod10.z.literal("output_text"),
2012
- text: import_zod10.z.string(),
2013
- annotations: import_zod10.z.array(
2014
- import_zod10.z.object({
2015
- type: import_zod10.z.literal("url_citation"),
2016
- start_index: import_zod10.z.number(),
2017
- end_index: import_zod10.z.number(),
2018
- url: import_zod10.z.string(),
2019
- title: import_zod10.z.string()
2067
+ import_zod12.z.object({
2068
+ id: import_zod12.z.string(),
2069
+ created_at: import_zod12.z.number(),
2070
+ model: import_zod12.z.string(),
2071
+ output: import_zod12.z.array(
2072
+ import_zod12.z.discriminatedUnion("type", [
2073
+ import_zod12.z.object({
2074
+ type: import_zod12.z.literal("message"),
2075
+ role: import_zod12.z.literal("assistant"),
2076
+ content: import_zod12.z.array(
2077
+ import_zod12.z.object({
2078
+ type: import_zod12.z.literal("output_text"),
2079
+ text: import_zod12.z.string(),
2080
+ annotations: import_zod12.z.array(
2081
+ import_zod12.z.object({
2082
+ type: import_zod12.z.literal("url_citation"),
2083
+ start_index: import_zod12.z.number(),
2084
+ end_index: import_zod12.z.number(),
2085
+ url: import_zod12.z.string(),
2086
+ title: import_zod12.z.string()
2020
2087
  })
2021
2088
  )
2022
2089
  })
2023
2090
  )
2024
2091
  }),
2025
- import_zod10.z.object({
2026
- type: import_zod10.z.literal("function_call"),
2027
- call_id: import_zod10.z.string(),
2028
- name: import_zod10.z.string(),
2029
- arguments: import_zod10.z.string()
2092
+ import_zod12.z.object({
2093
+ type: import_zod12.z.literal("function_call"),
2094
+ call_id: import_zod12.z.string(),
2095
+ name: import_zod12.z.string(),
2096
+ arguments: import_zod12.z.string()
2030
2097
  }),
2031
- import_zod10.z.object({
2032
- type: import_zod10.z.literal("web_search_call")
2098
+ import_zod12.z.object({
2099
+ type: import_zod12.z.literal("web_search_call")
2033
2100
  }),
2034
- import_zod10.z.object({
2035
- type: import_zod10.z.literal("computer_call")
2101
+ import_zod12.z.object({
2102
+ type: import_zod12.z.literal("computer_call")
2036
2103
  }),
2037
- import_zod10.z.object({
2038
- type: import_zod10.z.literal("reasoning"),
2039
- summary: import_zod10.z.array(
2040
- import_zod10.z.object({
2041
- type: import_zod10.z.literal("summary_text"),
2042
- text: import_zod10.z.string()
2104
+ import_zod12.z.object({
2105
+ type: import_zod12.z.literal("reasoning"),
2106
+ summary: import_zod12.z.array(
2107
+ import_zod12.z.object({
2108
+ type: import_zod12.z.literal("summary_text"),
2109
+ text: import_zod12.z.string()
2043
2110
  })
2044
2111
  )
2045
2112
  })
2046
2113
  ])
2047
2114
  ),
2048
- incomplete_details: import_zod10.z.object({ reason: import_zod10.z.string() }).nullable(),
2115
+ incomplete_details: import_zod12.z.object({ reason: import_zod12.z.string() }).nullable(),
2049
2116
  usage: usageSchema
2050
2117
  })
2051
2118
  ),
@@ -2058,7 +2125,6 @@ var OpenAIResponsesLanguageModel = class {
2058
2125
  case "reasoning": {
2059
2126
  content.push({
2060
2127
  type: "reasoning",
2061
- reasoningType: "text",
2062
2128
  text: part.summary.map((summary) => summary.text).join()
2063
2129
  });
2064
2130
  break;
@@ -2122,7 +2188,7 @@ var OpenAIResponsesLanguageModel = class {
2122
2188
  };
2123
2189
  }
2124
2190
  async doStream(options) {
2125
- const { args: body, warnings } = this.getArgs(options);
2191
+ const { args: body, warnings } = await this.getArgs(options);
2126
2192
  const { responseHeaders, value: response } = await (0, import_provider_utils9.postJsonToApi)({
2127
2193
  url: this.config.url({
2128
2194
  path: "/responses",
@@ -2206,7 +2272,6 @@ var OpenAIResponsesLanguageModel = class {
2206
2272
  } else if (isResponseReasoningSummaryTextDeltaChunk(value)) {
2207
2273
  controller.enqueue({
2208
2274
  type: "reasoning",
2209
- reasoningType: "text",
2210
2275
  text: value.delta
2211
2276
  });
2212
2277
  } else if (isResponseOutputItemDoneChunk(value) && value.item.type === "function_call") {
@@ -2261,86 +2326,86 @@ var OpenAIResponsesLanguageModel = class {
2261
2326
  };
2262
2327
  }
2263
2328
  };
2264
- var usageSchema = import_zod10.z.object({
2265
- input_tokens: import_zod10.z.number(),
2266
- input_tokens_details: import_zod10.z.object({ cached_tokens: import_zod10.z.number().nullish() }).nullish(),
2267
- output_tokens: import_zod10.z.number(),
2268
- output_tokens_details: import_zod10.z.object({ reasoning_tokens: import_zod10.z.number().nullish() }).nullish()
2329
+ var usageSchema = import_zod12.z.object({
2330
+ input_tokens: import_zod12.z.number(),
2331
+ input_tokens_details: import_zod12.z.object({ cached_tokens: import_zod12.z.number().nullish() }).nullish(),
2332
+ output_tokens: import_zod12.z.number(),
2333
+ output_tokens_details: import_zod12.z.object({ reasoning_tokens: import_zod12.z.number().nullish() }).nullish()
2269
2334
  });
2270
- var textDeltaChunkSchema = import_zod10.z.object({
2271
- type: import_zod10.z.literal("response.output_text.delta"),
2272
- delta: import_zod10.z.string()
2335
+ var textDeltaChunkSchema = import_zod12.z.object({
2336
+ type: import_zod12.z.literal("response.output_text.delta"),
2337
+ delta: import_zod12.z.string()
2273
2338
  });
2274
- var responseFinishedChunkSchema = import_zod10.z.object({
2275
- type: import_zod10.z.enum(["response.completed", "response.incomplete"]),
2276
- response: import_zod10.z.object({
2277
- incomplete_details: import_zod10.z.object({ reason: import_zod10.z.string() }).nullish(),
2339
+ var responseFinishedChunkSchema = import_zod12.z.object({
2340
+ type: import_zod12.z.enum(["response.completed", "response.incomplete"]),
2341
+ response: import_zod12.z.object({
2342
+ incomplete_details: import_zod12.z.object({ reason: import_zod12.z.string() }).nullish(),
2278
2343
  usage: usageSchema
2279
2344
  })
2280
2345
  });
2281
- var responseCreatedChunkSchema = import_zod10.z.object({
2282
- type: import_zod10.z.literal("response.created"),
2283
- response: import_zod10.z.object({
2284
- id: import_zod10.z.string(),
2285
- created_at: import_zod10.z.number(),
2286
- model: import_zod10.z.string()
2346
+ var responseCreatedChunkSchema = import_zod12.z.object({
2347
+ type: import_zod12.z.literal("response.created"),
2348
+ response: import_zod12.z.object({
2349
+ id: import_zod12.z.string(),
2350
+ created_at: import_zod12.z.number(),
2351
+ model: import_zod12.z.string()
2287
2352
  })
2288
2353
  });
2289
- var responseOutputItemDoneSchema = import_zod10.z.object({
2290
- type: import_zod10.z.literal("response.output_item.done"),
2291
- output_index: import_zod10.z.number(),
2292
- item: import_zod10.z.discriminatedUnion("type", [
2293
- import_zod10.z.object({
2294
- type: import_zod10.z.literal("message")
2354
+ var responseOutputItemDoneSchema = import_zod12.z.object({
2355
+ type: import_zod12.z.literal("response.output_item.done"),
2356
+ output_index: import_zod12.z.number(),
2357
+ item: import_zod12.z.discriminatedUnion("type", [
2358
+ import_zod12.z.object({
2359
+ type: import_zod12.z.literal("message")
2295
2360
  }),
2296
- import_zod10.z.object({
2297
- type: import_zod10.z.literal("function_call"),
2298
- id: import_zod10.z.string(),
2299
- call_id: import_zod10.z.string(),
2300
- name: import_zod10.z.string(),
2301
- arguments: import_zod10.z.string(),
2302
- status: import_zod10.z.literal("completed")
2361
+ import_zod12.z.object({
2362
+ type: import_zod12.z.literal("function_call"),
2363
+ id: import_zod12.z.string(),
2364
+ call_id: import_zod12.z.string(),
2365
+ name: import_zod12.z.string(),
2366
+ arguments: import_zod12.z.string(),
2367
+ status: import_zod12.z.literal("completed")
2303
2368
  })
2304
2369
  ])
2305
2370
  });
2306
- var responseFunctionCallArgumentsDeltaSchema = import_zod10.z.object({
2307
- type: import_zod10.z.literal("response.function_call_arguments.delta"),
2308
- item_id: import_zod10.z.string(),
2309
- output_index: import_zod10.z.number(),
2310
- delta: import_zod10.z.string()
2371
+ var responseFunctionCallArgumentsDeltaSchema = import_zod12.z.object({
2372
+ type: import_zod12.z.literal("response.function_call_arguments.delta"),
2373
+ item_id: import_zod12.z.string(),
2374
+ output_index: import_zod12.z.number(),
2375
+ delta: import_zod12.z.string()
2311
2376
  });
2312
- var responseOutputItemAddedSchema = import_zod10.z.object({
2313
- type: import_zod10.z.literal("response.output_item.added"),
2314
- output_index: import_zod10.z.number(),
2315
- item: import_zod10.z.discriminatedUnion("type", [
2316
- import_zod10.z.object({
2317
- type: import_zod10.z.literal("message")
2377
+ var responseOutputItemAddedSchema = import_zod12.z.object({
2378
+ type: import_zod12.z.literal("response.output_item.added"),
2379
+ output_index: import_zod12.z.number(),
2380
+ item: import_zod12.z.discriminatedUnion("type", [
2381
+ import_zod12.z.object({
2382
+ type: import_zod12.z.literal("message")
2318
2383
  }),
2319
- import_zod10.z.object({
2320
- type: import_zod10.z.literal("function_call"),
2321
- id: import_zod10.z.string(),
2322
- call_id: import_zod10.z.string(),
2323
- name: import_zod10.z.string(),
2324
- arguments: import_zod10.z.string()
2384
+ import_zod12.z.object({
2385
+ type: import_zod12.z.literal("function_call"),
2386
+ id: import_zod12.z.string(),
2387
+ call_id: import_zod12.z.string(),
2388
+ name: import_zod12.z.string(),
2389
+ arguments: import_zod12.z.string()
2325
2390
  })
2326
2391
  ])
2327
2392
  });
2328
- var responseAnnotationAddedSchema = import_zod10.z.object({
2329
- type: import_zod10.z.literal("response.output_text.annotation.added"),
2330
- annotation: import_zod10.z.object({
2331
- type: import_zod10.z.literal("url_citation"),
2332
- url: import_zod10.z.string(),
2333
- title: import_zod10.z.string()
2393
+ var responseAnnotationAddedSchema = import_zod12.z.object({
2394
+ type: import_zod12.z.literal("response.output_text.annotation.added"),
2395
+ annotation: import_zod12.z.object({
2396
+ type: import_zod12.z.literal("url_citation"),
2397
+ url: import_zod12.z.string(),
2398
+ title: import_zod12.z.string()
2334
2399
  })
2335
2400
  });
2336
- var responseReasoningSummaryTextDeltaSchema = import_zod10.z.object({
2337
- type: import_zod10.z.literal("response.reasoning_summary_text.delta"),
2338
- item_id: import_zod10.z.string(),
2339
- output_index: import_zod10.z.number(),
2340
- summary_index: import_zod10.z.number(),
2341
- delta: import_zod10.z.string()
2401
+ var responseReasoningSummaryTextDeltaSchema = import_zod12.z.object({
2402
+ type: import_zod12.z.literal("response.reasoning_summary_text.delta"),
2403
+ item_id: import_zod12.z.string(),
2404
+ output_index: import_zod12.z.number(),
2405
+ summary_index: import_zod12.z.number(),
2406
+ delta: import_zod12.z.string()
2342
2407
  });
2343
- var openaiResponsesChunkSchema = import_zod10.z.union([
2408
+ var openaiResponsesChunkSchema = import_zod12.z.union([
2344
2409
  textDeltaChunkSchema,
2345
2410
  responseFinishedChunkSchema,
2346
2411
  responseCreatedChunkSchema,
@@ -2349,7 +2414,7 @@ var openaiResponsesChunkSchema = import_zod10.z.union([
2349
2414
  responseOutputItemAddedSchema,
2350
2415
  responseAnnotationAddedSchema,
2351
2416
  responseReasoningSummaryTextDeltaSchema,
2352
- import_zod10.z.object({ type: import_zod10.z.string() }).passthrough()
2417
+ import_zod12.z.object({ type: import_zod12.z.string() }).passthrough()
2353
2418
  // fallback for unknown chunks
2354
2419
  ]);
2355
2420
  function isTextDeltaChunk(chunk) {
@@ -2397,16 +2462,16 @@ function getResponsesModelConfig(modelId) {
2397
2462
  requiredAutoTruncation: false
2398
2463
  };
2399
2464
  }
2400
- var openaiResponsesProviderOptionsSchema = import_zod10.z.object({
2401
- metadata: import_zod10.z.any().nullish(),
2402
- parallelToolCalls: import_zod10.z.boolean().nullish(),
2403
- previousResponseId: import_zod10.z.string().nullish(),
2404
- store: import_zod10.z.boolean().nullish(),
2405
- user: import_zod10.z.string().nullish(),
2406
- reasoningEffort: import_zod10.z.string().nullish(),
2407
- strictSchemas: import_zod10.z.boolean().nullish(),
2408
- instructions: import_zod10.z.string().nullish(),
2409
- reasoningSummary: import_zod10.z.string().nullish()
2465
+ var openaiResponsesProviderOptionsSchema = import_zod12.z.object({
2466
+ metadata: import_zod12.z.any().nullish(),
2467
+ parallelToolCalls: import_zod12.z.boolean().nullish(),
2468
+ previousResponseId: import_zod12.z.string().nullish(),
2469
+ store: import_zod12.z.boolean().nullish(),
2470
+ user: import_zod12.z.string().nullish(),
2471
+ reasoningEffort: import_zod12.z.string().nullish(),
2472
+ strictSchemas: import_zod12.z.boolean().nullish(),
2473
+ instructions: import_zod12.z.string().nullish(),
2474
+ reasoningSummary: import_zod12.z.string().nullish()
2410
2475
  });
2411
2476
  // Annotate the CommonJS export names for ESM import in node:
2412
2477
  0 && (module.exports = {
@@ -2417,7 +2482,10 @@ var openaiResponsesProviderOptionsSchema = import_zod10.z.object({
2417
2482
  OpenAIResponsesLanguageModel,
2418
2483
  OpenAISpeechModel,
2419
2484
  OpenAITranscriptionModel,
2485
+ hasDefaultResponseFormat,
2420
2486
  modelMaxImagesPerCall,
2487
+ openAITranscriptionProviderOptions,
2488
+ openaiCompletionProviderOptions,
2421
2489
  openaiEmbeddingProviderOptions,
2422
2490
  openaiProviderOptions
2423
2491
  });