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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -361,7 +361,7 @@ var OpenAIChatLanguageModel = class {
361
361
  "image/*": [/^https?:\/\/.*$/]
362
362
  };
363
363
  }
364
- getArgs({
364
+ async getArgs({
365
365
  prompt,
366
366
  maxOutputTokens,
367
367
  temperature,
@@ -378,7 +378,7 @@ var OpenAIChatLanguageModel = class {
378
378
  }) {
379
379
  var _a, _b, _c;
380
380
  const warnings = [];
381
- const openaiOptions = (_a = (0, import_provider_utils3.parseProviderOptions)({
381
+ const openaiOptions = (_a = await (0, import_provider_utils3.parseProviderOptions)({
382
382
  provider: "openai",
383
383
  providerOptions,
384
384
  schema: openaiProviderOptions
@@ -516,7 +516,7 @@ var OpenAIChatLanguageModel = class {
516
516
  }
517
517
  async doGenerate(options) {
518
518
  var _a, _b, _c, _d, _e, _f, _g, _h;
519
- const { args: body, warnings } = this.getArgs(options);
519
+ const { args: body, warnings } = await this.getArgs(options);
520
520
  const {
521
521
  responseHeaders,
522
522
  value: response,
@@ -583,7 +583,7 @@ var OpenAIChatLanguageModel = class {
583
583
  };
584
584
  }
585
585
  async doStream(options) {
586
- const { args, warnings } = this.getArgs(options);
586
+ const { args, warnings } = await this.getArgs(options);
587
587
  const body = {
588
588
  ...args,
589
589
  stream: true,
@@ -873,7 +873,7 @@ var reasoningModels = {
873
873
 
874
874
  // src/openai-completion-language-model.ts
875
875
  var import_provider_utils4 = require("@ai-sdk/provider-utils");
876
- var import_zod4 = require("zod");
876
+ var import_zod5 = require("zod");
877
877
 
878
878
  // src/convert-to-openai-completion-prompt.ts
879
879
  var import_provider4 = require("@ai-sdk/provider");
@@ -954,14 +954,49 @@ ${user}:`]
954
954
  };
955
955
  }
956
956
 
957
+ // src/openai-completion-options.ts
958
+ var import_zod4 = require("zod");
959
+ var openaiCompletionProviderOptions = import_zod4.z.object({
960
+ /**
961
+ Echo back the prompt in addition to the completion.
962
+ */
963
+ echo: import_zod4.z.boolean().optional(),
964
+ /**
965
+ Modify the likelihood of specified tokens appearing in the completion.
966
+
967
+ Accepts a JSON object that maps tokens (specified by their token ID in
968
+ the GPT tokenizer) to an associated bias value from -100 to 100. You
969
+ can use this tokenizer tool to convert text to token IDs. Mathematically,
970
+ the bias is added to the logits generated by the model prior to sampling.
971
+ The exact effect will vary per model, but values between -1 and 1 should
972
+ decrease or increase likelihood of selection; values like -100 or 100
973
+ should result in a ban or exclusive selection of the relevant token.
974
+
975
+ As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
976
+ token from being generated.
977
+ */
978
+ logitBias: import_zod4.z.record(import_zod4.z.string(), import_zod4.z.number()).optional(),
979
+ /**
980
+ The suffix that comes after a completion of inserted text.
981
+ */
982
+ suffix: import_zod4.z.string().optional(),
983
+ /**
984
+ A unique identifier representing your end-user, which can help OpenAI to
985
+ monitor and detect abuse. Learn more.
986
+ */
987
+ user: import_zod4.z.string().optional()
988
+ });
989
+
957
990
  // src/openai-completion-language-model.ts
958
991
  var OpenAICompletionLanguageModel = class {
959
- constructor(modelId, settings, config) {
992
+ constructor(modelId, config) {
960
993
  this.specificationVersion = "v2";
961
994
  this.modelId = modelId;
962
- this.settings = settings;
963
995
  this.config = config;
964
996
  }
997
+ get providerOptionsName() {
998
+ return this.config.provider.split(".")[0].trim();
999
+ }
965
1000
  get provider() {
966
1001
  return this.config.provider;
967
1002
  }
@@ -970,7 +1005,7 @@ var OpenAICompletionLanguageModel = class {
970
1005
  // no supported urls for completion models
971
1006
  };
972
1007
  }
973
- getArgs({
1008
+ async getArgs({
974
1009
  inputFormat,
975
1010
  prompt,
976
1011
  maxOutputTokens,
@@ -983,9 +1018,22 @@ var OpenAICompletionLanguageModel = class {
983
1018
  responseFormat,
984
1019
  tools,
985
1020
  toolChoice,
986
- seed
1021
+ seed,
1022
+ providerOptions
987
1023
  }) {
988
1024
  const warnings = [];
1025
+ const openaiOptions = {
1026
+ ...await (0, import_provider_utils4.parseProviderOptions)({
1027
+ provider: "openai",
1028
+ providerOptions,
1029
+ schema: openaiCompletionProviderOptions
1030
+ }),
1031
+ ...await (0, import_provider_utils4.parseProviderOptions)({
1032
+ provider: this.providerOptionsName,
1033
+ providerOptions,
1034
+ schema: openaiCompletionProviderOptions
1035
+ })
1036
+ };
989
1037
  if (topK != null) {
990
1038
  warnings.push({ type: "unsupported-setting", setting: "topK" });
991
1039
  }
@@ -1009,10 +1057,10 @@ var OpenAICompletionLanguageModel = class {
1009
1057
  // model id:
1010
1058
  model: this.modelId,
1011
1059
  // model specific settings:
1012
- echo: this.settings.echo,
1013
- logit_bias: this.settings.logitBias,
1014
- suffix: this.settings.suffix,
1015
- user: this.settings.user,
1060
+ echo: openaiOptions.echo,
1061
+ logit_bias: openaiOptions.logitBias,
1062
+ suffix: openaiOptions.suffix,
1063
+ user: openaiOptions.user,
1016
1064
  // standardized settings:
1017
1065
  max_tokens: maxOutputTokens,
1018
1066
  temperature,
@@ -1029,7 +1077,7 @@ var OpenAICompletionLanguageModel = class {
1029
1077
  };
1030
1078
  }
1031
1079
  async doGenerate(options) {
1032
- const { args, warnings } = this.getArgs(options);
1080
+ const { args, warnings } = await this.getArgs(options);
1033
1081
  const {
1034
1082
  responseHeaders,
1035
1083
  value: response,
@@ -1066,7 +1114,7 @@ var OpenAICompletionLanguageModel = class {
1066
1114
  };
1067
1115
  }
1068
1116
  async doStream(options) {
1069
- const { args, warnings } = this.getArgs(options);
1117
+ const { args, warnings } = await this.getArgs(options);
1070
1118
  const body = {
1071
1119
  ...args,
1072
1120
  stream: true,
@@ -1147,36 +1195,36 @@ var OpenAICompletionLanguageModel = class {
1147
1195
  };
1148
1196
  }
1149
1197
  };
1150
- var openaiCompletionResponseSchema = import_zod4.z.object({
1151
- id: import_zod4.z.string().nullish(),
1152
- created: import_zod4.z.number().nullish(),
1153
- model: import_zod4.z.string().nullish(),
1154
- choices: import_zod4.z.array(
1155
- import_zod4.z.object({
1156
- text: import_zod4.z.string(),
1157
- finish_reason: import_zod4.z.string()
1198
+ var openaiCompletionResponseSchema = import_zod5.z.object({
1199
+ id: import_zod5.z.string().nullish(),
1200
+ created: import_zod5.z.number().nullish(),
1201
+ model: import_zod5.z.string().nullish(),
1202
+ choices: import_zod5.z.array(
1203
+ import_zod5.z.object({
1204
+ text: import_zod5.z.string(),
1205
+ finish_reason: import_zod5.z.string()
1158
1206
  })
1159
1207
  ),
1160
- usage: import_zod4.z.object({
1161
- prompt_tokens: import_zod4.z.number(),
1162
- completion_tokens: import_zod4.z.number()
1208
+ usage: import_zod5.z.object({
1209
+ prompt_tokens: import_zod5.z.number(),
1210
+ completion_tokens: import_zod5.z.number()
1163
1211
  })
1164
1212
  });
1165
- var openaiCompletionChunkSchema = import_zod4.z.union([
1166
- import_zod4.z.object({
1167
- id: import_zod4.z.string().nullish(),
1168
- created: import_zod4.z.number().nullish(),
1169
- model: import_zod4.z.string().nullish(),
1170
- choices: import_zod4.z.array(
1171
- import_zod4.z.object({
1172
- text: import_zod4.z.string(),
1173
- finish_reason: import_zod4.z.string().nullish(),
1174
- index: import_zod4.z.number()
1213
+ var openaiCompletionChunkSchema = import_zod5.z.union([
1214
+ import_zod5.z.object({
1215
+ id: import_zod5.z.string().nullish(),
1216
+ created: import_zod5.z.number().nullish(),
1217
+ model: import_zod5.z.string().nullish(),
1218
+ choices: import_zod5.z.array(
1219
+ import_zod5.z.object({
1220
+ text: import_zod5.z.string(),
1221
+ finish_reason: import_zod5.z.string().nullish(),
1222
+ index: import_zod5.z.number()
1175
1223
  })
1176
1224
  ),
1177
- usage: import_zod4.z.object({
1178
- prompt_tokens: import_zod4.z.number(),
1179
- completion_tokens: import_zod4.z.number()
1225
+ usage: import_zod5.z.object({
1226
+ prompt_tokens: import_zod5.z.number(),
1227
+ completion_tokens: import_zod5.z.number()
1180
1228
  }).nullish()
1181
1229
  }),
1182
1230
  openaiErrorDataSchema
@@ -1185,21 +1233,21 @@ var openaiCompletionChunkSchema = import_zod4.z.union([
1185
1233
  // src/openai-embedding-model.ts
1186
1234
  var import_provider5 = require("@ai-sdk/provider");
1187
1235
  var import_provider_utils5 = require("@ai-sdk/provider-utils");
1188
- var import_zod6 = require("zod");
1236
+ var import_zod7 = require("zod");
1189
1237
 
1190
1238
  // src/openai-embedding-options.ts
1191
- var import_zod5 = require("zod");
1192
- var openaiEmbeddingProviderOptions = import_zod5.z.object({
1239
+ var import_zod6 = require("zod");
1240
+ var openaiEmbeddingProviderOptions = import_zod6.z.object({
1193
1241
  /**
1194
1242
  The number of dimensions the resulting output embeddings should have.
1195
1243
  Only supported in text-embedding-3 and later models.
1196
1244
  */
1197
- dimensions: import_zod5.z.number().optional(),
1245
+ dimensions: import_zod6.z.number().optional(),
1198
1246
  /**
1199
1247
  A unique identifier representing your end-user, which can help OpenAI to
1200
1248
  monitor and detect abuse. Learn more.
1201
1249
  */
1202
- user: import_zod5.z.string().optional()
1250
+ user: import_zod6.z.string().optional()
1203
1251
  });
1204
1252
 
1205
1253
  // src/openai-embedding-model.ts
@@ -1236,7 +1284,7 @@ var OpenAIEmbeddingModel = class {
1236
1284
  values
1237
1285
  });
1238
1286
  }
1239
- const openaiOptions = (_a = (0, import_provider_utils5.parseProviderOptions)({
1287
+ const openaiOptions = (_a = await (0, import_provider_utils5.parseProviderOptions)({
1240
1288
  provider: "openai",
1241
1289
  providerOptions,
1242
1290
  schema: openaiEmbeddingProviderOptions
@@ -1272,20 +1320,22 @@ var OpenAIEmbeddingModel = class {
1272
1320
  };
1273
1321
  }
1274
1322
  };
1275
- var openaiTextEmbeddingResponseSchema = import_zod6.z.object({
1276
- data: import_zod6.z.array(import_zod6.z.object({ embedding: import_zod6.z.array(import_zod6.z.number()) })),
1277
- usage: import_zod6.z.object({ prompt_tokens: import_zod6.z.number() }).nullish()
1323
+ var openaiTextEmbeddingResponseSchema = import_zod7.z.object({
1324
+ data: import_zod7.z.array(import_zod7.z.object({ embedding: import_zod7.z.array(import_zod7.z.number()) })),
1325
+ usage: import_zod7.z.object({ prompt_tokens: import_zod7.z.number() }).nullish()
1278
1326
  });
1279
1327
 
1280
1328
  // src/openai-image-model.ts
1281
1329
  var import_provider_utils6 = require("@ai-sdk/provider-utils");
1282
- var import_zod7 = require("zod");
1330
+ var import_zod8 = require("zod");
1283
1331
 
1284
1332
  // src/openai-image-settings.ts
1285
1333
  var modelMaxImagesPerCall = {
1286
1334
  "dall-e-3": 1,
1287
- "dall-e-2": 10
1335
+ "dall-e-2": 10,
1336
+ "gpt-image-1": 10
1288
1337
  };
1338
+ var hasDefaultResponseFormat = /* @__PURE__ */ new Set(["gpt-image-1"]);
1289
1339
 
1290
1340
  // src/openai-image-model.ts
1291
1341
  var OpenAIImageModel = class {
@@ -1337,7 +1387,7 @@ var OpenAIImageModel = class {
1337
1387
  n,
1338
1388
  size,
1339
1389
  ...(_d = providerOptions.openai) != null ? _d : {},
1340
- response_format: "b64_json"
1390
+ ...!hasDefaultResponseFormat.has(this.modelId) ? { response_format: "b64_json" } : {}
1341
1391
  },
1342
1392
  failedResponseHandler: openaiFailedResponseHandler,
1343
1393
  successfulResponseHandler: (0, import_provider_utils6.createJsonResponseHandler)(
@@ -1357,13 +1407,13 @@ var OpenAIImageModel = class {
1357
1407
  };
1358
1408
  }
1359
1409
  };
1360
- var openaiImageResponseSchema = import_zod7.z.object({
1361
- data: import_zod7.z.array(import_zod7.z.object({ b64_json: import_zod7.z.string() }))
1410
+ var openaiImageResponseSchema = import_zod8.z.object({
1411
+ data: import_zod8.z.array(import_zod8.z.object({ b64_json: import_zod8.z.string() }))
1362
1412
  });
1363
1413
 
1364
1414
  // src/openai-tools.ts
1365
- var import_zod8 = require("zod");
1366
- var WebSearchPreviewParameters = import_zod8.z.object({});
1415
+ var import_zod9 = require("zod");
1416
+ var WebSearchPreviewParameters = import_zod9.z.object({});
1367
1417
  function webSearchPreviewTool({
1368
1418
  searchContextSize,
1369
1419
  userLocation
@@ -1384,13 +1434,13 @@ var openaiTools = {
1384
1434
 
1385
1435
  // src/openai-transcription-model.ts
1386
1436
  var import_provider_utils7 = require("@ai-sdk/provider-utils");
1387
- var import_zod9 = require("zod");
1388
- var openAIProviderOptionsSchema = import_zod9.z.object({
1389
- include: import_zod9.z.array(import_zod9.z.string()).nullish(),
1390
- language: import_zod9.z.string().nullish(),
1391
- prompt: import_zod9.z.string().nullish(),
1392
- temperature: import_zod9.z.number().min(0).max(1).nullish().default(0),
1393
- timestampGranularities: import_zod9.z.array(import_zod9.z.enum(["word", "segment"])).nullish().default(["segment"])
1437
+ var import_zod10 = require("zod");
1438
+ var openAIProviderOptionsSchema = import_zod10.z.object({
1439
+ include: import_zod10.z.array(import_zod10.z.string()).nullish(),
1440
+ language: import_zod10.z.string().nullish(),
1441
+ prompt: import_zod10.z.string().nullish(),
1442
+ temperature: import_zod10.z.number().min(0).max(1).nullish().default(0),
1443
+ timestampGranularities: import_zod10.z.array(import_zod10.z.enum(["word", "segment"])).nullish().default(["segment"])
1394
1444
  });
1395
1445
  var languageMap = {
1396
1446
  afrikaans: "af",
@@ -1460,14 +1510,14 @@ var OpenAITranscriptionModel = class {
1460
1510
  get provider() {
1461
1511
  return this.config.provider;
1462
1512
  }
1463
- getArgs({
1513
+ async getArgs({
1464
1514
  audio,
1465
1515
  mediaType,
1466
1516
  providerOptions
1467
1517
  }) {
1468
1518
  var _a, _b, _c, _d, _e;
1469
1519
  const warnings = [];
1470
- const openAIOptions = (0, import_provider_utils7.parseProviderOptions)({
1520
+ const openAIOptions = await (0, import_provider_utils7.parseProviderOptions)({
1471
1521
  provider: "openai",
1472
1522
  providerOptions,
1473
1523
  schema: openAIProviderOptionsSchema
@@ -1499,7 +1549,7 @@ var OpenAITranscriptionModel = class {
1499
1549
  async doGenerate(options) {
1500
1550
  var _a, _b, _c, _d, _e, _f;
1501
1551
  const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
1502
- const { formData, warnings } = this.getArgs(options);
1552
+ const { formData, warnings } = await this.getArgs(options);
1503
1553
  const {
1504
1554
  value: response,
1505
1555
  responseHeaders,
@@ -1538,22 +1588,22 @@ var OpenAITranscriptionModel = class {
1538
1588
  };
1539
1589
  }
1540
1590
  };
1541
- var openaiTranscriptionResponseSchema = import_zod9.z.object({
1542
- text: import_zod9.z.string(),
1543
- language: import_zod9.z.string().nullish(),
1544
- duration: import_zod9.z.number().nullish(),
1545
- words: import_zod9.z.array(
1546
- import_zod9.z.object({
1547
- word: import_zod9.z.string(),
1548
- start: import_zod9.z.number(),
1549
- end: import_zod9.z.number()
1591
+ var openaiTranscriptionResponseSchema = import_zod10.z.object({
1592
+ text: import_zod10.z.string(),
1593
+ language: import_zod10.z.string().nullish(),
1594
+ duration: import_zod10.z.number().nullish(),
1595
+ words: import_zod10.z.array(
1596
+ import_zod10.z.object({
1597
+ word: import_zod10.z.string(),
1598
+ start: import_zod10.z.number(),
1599
+ end: import_zod10.z.number()
1550
1600
  })
1551
1601
  ).nullish()
1552
1602
  });
1553
1603
 
1554
1604
  // src/responses/openai-responses-language-model.ts
1555
1605
  var import_provider_utils8 = require("@ai-sdk/provider-utils");
1556
- var import_zod10 = require("zod");
1606
+ var import_zod11 = require("zod");
1557
1607
 
1558
1608
  // src/responses/convert-to-openai-responses-messages.ts
1559
1609
  var import_provider6 = require("@ai-sdk/provider");
@@ -1773,7 +1823,7 @@ var OpenAIResponsesLanguageModel = class {
1773
1823
  get provider() {
1774
1824
  return this.config.provider;
1775
1825
  }
1776
- getArgs({
1826
+ async getArgs({
1777
1827
  maxOutputTokens,
1778
1828
  temperature,
1779
1829
  stopSequences,
@@ -1817,7 +1867,7 @@ var OpenAIResponsesLanguageModel = class {
1817
1867
  systemMessageMode: modelConfig.systemMessageMode
1818
1868
  });
1819
1869
  warnings.push(...messageWarnings);
1820
- const openaiOptions = (0, import_provider_utils8.parseProviderOptions)({
1870
+ const openaiOptions = await (0, import_provider_utils8.parseProviderOptions)({
1821
1871
  provider: "openai",
1822
1872
  providerOptions,
1823
1873
  schema: openaiResponsesProviderOptionsSchema
@@ -1900,7 +1950,7 @@ var OpenAIResponsesLanguageModel = class {
1900
1950
  }
1901
1951
  async doGenerate(options) {
1902
1952
  var _a, _b, _c, _d, _e, _f, _g, _h;
1903
- const { args: body, warnings } = this.getArgs(options);
1953
+ const { args: body, warnings } = await this.getArgs(options);
1904
1954
  const {
1905
1955
  responseHeaders,
1906
1956
  value: response,
@@ -1914,55 +1964,55 @@ var OpenAIResponsesLanguageModel = class {
1914
1964
  body,
1915
1965
  failedResponseHandler: openaiFailedResponseHandler,
1916
1966
  successfulResponseHandler: (0, import_provider_utils8.createJsonResponseHandler)(
1917
- import_zod10.z.object({
1918
- id: import_zod10.z.string(),
1919
- created_at: import_zod10.z.number(),
1920
- model: import_zod10.z.string(),
1921
- output: import_zod10.z.array(
1922
- import_zod10.z.discriminatedUnion("type", [
1923
- import_zod10.z.object({
1924
- type: import_zod10.z.literal("message"),
1925
- role: import_zod10.z.literal("assistant"),
1926
- content: import_zod10.z.array(
1927
- import_zod10.z.object({
1928
- type: import_zod10.z.literal("output_text"),
1929
- text: import_zod10.z.string(),
1930
- annotations: import_zod10.z.array(
1931
- import_zod10.z.object({
1932
- type: import_zod10.z.literal("url_citation"),
1933
- start_index: import_zod10.z.number(),
1934
- end_index: import_zod10.z.number(),
1935
- url: import_zod10.z.string(),
1936
- title: import_zod10.z.string()
1967
+ import_zod11.z.object({
1968
+ id: import_zod11.z.string(),
1969
+ created_at: import_zod11.z.number(),
1970
+ model: import_zod11.z.string(),
1971
+ output: import_zod11.z.array(
1972
+ import_zod11.z.discriminatedUnion("type", [
1973
+ import_zod11.z.object({
1974
+ type: import_zod11.z.literal("message"),
1975
+ role: import_zod11.z.literal("assistant"),
1976
+ content: import_zod11.z.array(
1977
+ import_zod11.z.object({
1978
+ type: import_zod11.z.literal("output_text"),
1979
+ text: import_zod11.z.string(),
1980
+ annotations: import_zod11.z.array(
1981
+ import_zod11.z.object({
1982
+ type: import_zod11.z.literal("url_citation"),
1983
+ start_index: import_zod11.z.number(),
1984
+ end_index: import_zod11.z.number(),
1985
+ url: import_zod11.z.string(),
1986
+ title: import_zod11.z.string()
1937
1987
  })
1938
1988
  )
1939
1989
  })
1940
1990
  )
1941
1991
  }),
1942
- import_zod10.z.object({
1943
- type: import_zod10.z.literal("function_call"),
1944
- call_id: import_zod10.z.string(),
1945
- name: import_zod10.z.string(),
1946
- arguments: import_zod10.z.string()
1992
+ import_zod11.z.object({
1993
+ type: import_zod11.z.literal("function_call"),
1994
+ call_id: import_zod11.z.string(),
1995
+ name: import_zod11.z.string(),
1996
+ arguments: import_zod11.z.string()
1947
1997
  }),
1948
- import_zod10.z.object({
1949
- type: import_zod10.z.literal("web_search_call")
1998
+ import_zod11.z.object({
1999
+ type: import_zod11.z.literal("web_search_call")
1950
2000
  }),
1951
- import_zod10.z.object({
1952
- type: import_zod10.z.literal("computer_call")
2001
+ import_zod11.z.object({
2002
+ type: import_zod11.z.literal("computer_call")
1953
2003
  }),
1954
- import_zod10.z.object({
1955
- type: import_zod10.z.literal("reasoning"),
1956
- summary: import_zod10.z.array(
1957
- import_zod10.z.object({
1958
- type: import_zod10.z.literal("summary_text"),
1959
- text: import_zod10.z.string()
2004
+ import_zod11.z.object({
2005
+ type: import_zod11.z.literal("reasoning"),
2006
+ summary: import_zod11.z.array(
2007
+ import_zod11.z.object({
2008
+ type: import_zod11.z.literal("summary_text"),
2009
+ text: import_zod11.z.string()
1960
2010
  })
1961
2011
  )
1962
2012
  })
1963
2013
  ])
1964
2014
  ),
1965
- incomplete_details: import_zod10.z.object({ reason: import_zod10.z.string() }).nullable(),
2015
+ incomplete_details: import_zod11.z.object({ reason: import_zod11.z.string() }).nullable(),
1966
2016
  usage: usageSchema
1967
2017
  })
1968
2018
  ),
@@ -1975,7 +2025,6 @@ var OpenAIResponsesLanguageModel = class {
1975
2025
  case "reasoning": {
1976
2026
  content.push({
1977
2027
  type: "reasoning",
1978
- reasoningType: "text",
1979
2028
  text: part.summary.map((summary) => summary.text).join()
1980
2029
  });
1981
2030
  break;
@@ -2039,7 +2088,7 @@ var OpenAIResponsesLanguageModel = class {
2039
2088
  };
2040
2089
  }
2041
2090
  async doStream(options) {
2042
- const { args: body, warnings } = this.getArgs(options);
2091
+ const { args: body, warnings } = await this.getArgs(options);
2043
2092
  const { responseHeaders, value: response } = await (0, import_provider_utils8.postJsonToApi)({
2044
2093
  url: this.config.url({
2045
2094
  path: "/responses",
@@ -2123,7 +2172,6 @@ var OpenAIResponsesLanguageModel = class {
2123
2172
  } else if (isResponseReasoningSummaryTextDeltaChunk(value)) {
2124
2173
  controller.enqueue({
2125
2174
  type: "reasoning",
2126
- reasoningType: "text",
2127
2175
  text: value.delta
2128
2176
  });
2129
2177
  } else if (isResponseOutputItemDoneChunk(value) && value.item.type === "function_call") {
@@ -2178,86 +2226,86 @@ var OpenAIResponsesLanguageModel = class {
2178
2226
  };
2179
2227
  }
2180
2228
  };
2181
- var usageSchema = import_zod10.z.object({
2182
- input_tokens: import_zod10.z.number(),
2183
- input_tokens_details: import_zod10.z.object({ cached_tokens: import_zod10.z.number().nullish() }).nullish(),
2184
- output_tokens: import_zod10.z.number(),
2185
- output_tokens_details: import_zod10.z.object({ reasoning_tokens: import_zod10.z.number().nullish() }).nullish()
2229
+ var usageSchema = import_zod11.z.object({
2230
+ input_tokens: import_zod11.z.number(),
2231
+ input_tokens_details: import_zod11.z.object({ cached_tokens: import_zod11.z.number().nullish() }).nullish(),
2232
+ output_tokens: import_zod11.z.number(),
2233
+ output_tokens_details: import_zod11.z.object({ reasoning_tokens: import_zod11.z.number().nullish() }).nullish()
2186
2234
  });
2187
- var textDeltaChunkSchema = import_zod10.z.object({
2188
- type: import_zod10.z.literal("response.output_text.delta"),
2189
- delta: import_zod10.z.string()
2235
+ var textDeltaChunkSchema = import_zod11.z.object({
2236
+ type: import_zod11.z.literal("response.output_text.delta"),
2237
+ delta: import_zod11.z.string()
2190
2238
  });
2191
- var responseFinishedChunkSchema = import_zod10.z.object({
2192
- type: import_zod10.z.enum(["response.completed", "response.incomplete"]),
2193
- response: import_zod10.z.object({
2194
- incomplete_details: import_zod10.z.object({ reason: import_zod10.z.string() }).nullish(),
2239
+ var responseFinishedChunkSchema = import_zod11.z.object({
2240
+ type: import_zod11.z.enum(["response.completed", "response.incomplete"]),
2241
+ response: import_zod11.z.object({
2242
+ incomplete_details: import_zod11.z.object({ reason: import_zod11.z.string() }).nullish(),
2195
2243
  usage: usageSchema
2196
2244
  })
2197
2245
  });
2198
- var responseCreatedChunkSchema = import_zod10.z.object({
2199
- type: import_zod10.z.literal("response.created"),
2200
- response: import_zod10.z.object({
2201
- id: import_zod10.z.string(),
2202
- created_at: import_zod10.z.number(),
2203
- model: import_zod10.z.string()
2246
+ var responseCreatedChunkSchema = import_zod11.z.object({
2247
+ type: import_zod11.z.literal("response.created"),
2248
+ response: import_zod11.z.object({
2249
+ id: import_zod11.z.string(),
2250
+ created_at: import_zod11.z.number(),
2251
+ model: import_zod11.z.string()
2204
2252
  })
2205
2253
  });
2206
- var responseOutputItemDoneSchema = import_zod10.z.object({
2207
- type: import_zod10.z.literal("response.output_item.done"),
2208
- output_index: import_zod10.z.number(),
2209
- item: import_zod10.z.discriminatedUnion("type", [
2210
- import_zod10.z.object({
2211
- type: import_zod10.z.literal("message")
2254
+ var responseOutputItemDoneSchema = import_zod11.z.object({
2255
+ type: import_zod11.z.literal("response.output_item.done"),
2256
+ output_index: import_zod11.z.number(),
2257
+ item: import_zod11.z.discriminatedUnion("type", [
2258
+ import_zod11.z.object({
2259
+ type: import_zod11.z.literal("message")
2212
2260
  }),
2213
- import_zod10.z.object({
2214
- type: import_zod10.z.literal("function_call"),
2215
- id: import_zod10.z.string(),
2216
- call_id: import_zod10.z.string(),
2217
- name: import_zod10.z.string(),
2218
- arguments: import_zod10.z.string(),
2219
- status: import_zod10.z.literal("completed")
2261
+ import_zod11.z.object({
2262
+ type: import_zod11.z.literal("function_call"),
2263
+ id: import_zod11.z.string(),
2264
+ call_id: import_zod11.z.string(),
2265
+ name: import_zod11.z.string(),
2266
+ arguments: import_zod11.z.string(),
2267
+ status: import_zod11.z.literal("completed")
2220
2268
  })
2221
2269
  ])
2222
2270
  });
2223
- var responseFunctionCallArgumentsDeltaSchema = import_zod10.z.object({
2224
- type: import_zod10.z.literal("response.function_call_arguments.delta"),
2225
- item_id: import_zod10.z.string(),
2226
- output_index: import_zod10.z.number(),
2227
- delta: import_zod10.z.string()
2271
+ var responseFunctionCallArgumentsDeltaSchema = import_zod11.z.object({
2272
+ type: import_zod11.z.literal("response.function_call_arguments.delta"),
2273
+ item_id: import_zod11.z.string(),
2274
+ output_index: import_zod11.z.number(),
2275
+ delta: import_zod11.z.string()
2228
2276
  });
2229
- var responseOutputItemAddedSchema = import_zod10.z.object({
2230
- type: import_zod10.z.literal("response.output_item.added"),
2231
- output_index: import_zod10.z.number(),
2232
- item: import_zod10.z.discriminatedUnion("type", [
2233
- import_zod10.z.object({
2234
- type: import_zod10.z.literal("message")
2277
+ var responseOutputItemAddedSchema = import_zod11.z.object({
2278
+ type: import_zod11.z.literal("response.output_item.added"),
2279
+ output_index: import_zod11.z.number(),
2280
+ item: import_zod11.z.discriminatedUnion("type", [
2281
+ import_zod11.z.object({
2282
+ type: import_zod11.z.literal("message")
2235
2283
  }),
2236
- import_zod10.z.object({
2237
- type: import_zod10.z.literal("function_call"),
2238
- id: import_zod10.z.string(),
2239
- call_id: import_zod10.z.string(),
2240
- name: import_zod10.z.string(),
2241
- arguments: import_zod10.z.string()
2284
+ import_zod11.z.object({
2285
+ type: import_zod11.z.literal("function_call"),
2286
+ id: import_zod11.z.string(),
2287
+ call_id: import_zod11.z.string(),
2288
+ name: import_zod11.z.string(),
2289
+ arguments: import_zod11.z.string()
2242
2290
  })
2243
2291
  ])
2244
2292
  });
2245
- var responseAnnotationAddedSchema = import_zod10.z.object({
2246
- type: import_zod10.z.literal("response.output_text.annotation.added"),
2247
- annotation: import_zod10.z.object({
2248
- type: import_zod10.z.literal("url_citation"),
2249
- url: import_zod10.z.string(),
2250
- title: import_zod10.z.string()
2293
+ var responseAnnotationAddedSchema = import_zod11.z.object({
2294
+ type: import_zod11.z.literal("response.output_text.annotation.added"),
2295
+ annotation: import_zod11.z.object({
2296
+ type: import_zod11.z.literal("url_citation"),
2297
+ url: import_zod11.z.string(),
2298
+ title: import_zod11.z.string()
2251
2299
  })
2252
2300
  });
2253
- var responseReasoningSummaryTextDeltaSchema = import_zod10.z.object({
2254
- type: import_zod10.z.literal("response.reasoning_summary_text.delta"),
2255
- item_id: import_zod10.z.string(),
2256
- output_index: import_zod10.z.number(),
2257
- summary_index: import_zod10.z.number(),
2258
- delta: import_zod10.z.string()
2301
+ var responseReasoningSummaryTextDeltaSchema = import_zod11.z.object({
2302
+ type: import_zod11.z.literal("response.reasoning_summary_text.delta"),
2303
+ item_id: import_zod11.z.string(),
2304
+ output_index: import_zod11.z.number(),
2305
+ summary_index: import_zod11.z.number(),
2306
+ delta: import_zod11.z.string()
2259
2307
  });
2260
- var openaiResponsesChunkSchema = import_zod10.z.union([
2308
+ var openaiResponsesChunkSchema = import_zod11.z.union([
2261
2309
  textDeltaChunkSchema,
2262
2310
  responseFinishedChunkSchema,
2263
2311
  responseCreatedChunkSchema,
@@ -2266,7 +2314,7 @@ var openaiResponsesChunkSchema = import_zod10.z.union([
2266
2314
  responseOutputItemAddedSchema,
2267
2315
  responseAnnotationAddedSchema,
2268
2316
  responseReasoningSummaryTextDeltaSchema,
2269
- import_zod10.z.object({ type: import_zod10.z.string() }).passthrough()
2317
+ import_zod11.z.object({ type: import_zod11.z.string() }).passthrough()
2270
2318
  // fallback for unknown chunks
2271
2319
  ]);
2272
2320
  function isTextDeltaChunk(chunk) {
@@ -2314,24 +2362,24 @@ function getResponsesModelConfig(modelId) {
2314
2362
  requiredAutoTruncation: false
2315
2363
  };
2316
2364
  }
2317
- var openaiResponsesProviderOptionsSchema = import_zod10.z.object({
2318
- metadata: import_zod10.z.any().nullish(),
2319
- parallelToolCalls: import_zod10.z.boolean().nullish(),
2320
- previousResponseId: import_zod10.z.string().nullish(),
2321
- store: import_zod10.z.boolean().nullish(),
2322
- user: import_zod10.z.string().nullish(),
2323
- reasoningEffort: import_zod10.z.string().nullish(),
2324
- strictSchemas: import_zod10.z.boolean().nullish(),
2325
- instructions: import_zod10.z.string().nullish(),
2326
- reasoningSummary: import_zod10.z.string().nullish()
2365
+ var openaiResponsesProviderOptionsSchema = import_zod11.z.object({
2366
+ metadata: import_zod11.z.any().nullish(),
2367
+ parallelToolCalls: import_zod11.z.boolean().nullish(),
2368
+ previousResponseId: import_zod11.z.string().nullish(),
2369
+ store: import_zod11.z.boolean().nullish(),
2370
+ user: import_zod11.z.string().nullish(),
2371
+ reasoningEffort: import_zod11.z.string().nullish(),
2372
+ strictSchemas: import_zod11.z.boolean().nullish(),
2373
+ instructions: import_zod11.z.string().nullish(),
2374
+ reasoningSummary: import_zod11.z.string().nullish()
2327
2375
  });
2328
2376
 
2329
2377
  // src/openai-speech-model.ts
2330
2378
  var import_provider_utils9 = require("@ai-sdk/provider-utils");
2331
- var import_zod11 = require("zod");
2332
- var OpenAIProviderOptionsSchema = import_zod11.z.object({
2333
- instructions: import_zod11.z.string().nullish(),
2334
- speed: import_zod11.z.number().min(0.25).max(4).default(1).nullish()
2379
+ var import_zod12 = require("zod");
2380
+ var OpenAIProviderOptionsSchema = import_zod12.z.object({
2381
+ instructions: import_zod12.z.string().nullish(),
2382
+ speed: import_zod12.z.number().min(0.25).max(4).default(1).nullish()
2335
2383
  });
2336
2384
  var OpenAISpeechModel = class {
2337
2385
  constructor(modelId, config) {
@@ -2342,7 +2390,7 @@ var OpenAISpeechModel = class {
2342
2390
  get provider() {
2343
2391
  return this.config.provider;
2344
2392
  }
2345
- getArgs({
2393
+ async getArgs({
2346
2394
  text,
2347
2395
  voice = "alloy",
2348
2396
  outputFormat = "mp3",
@@ -2351,7 +2399,7 @@ var OpenAISpeechModel = class {
2351
2399
  providerOptions
2352
2400
  }) {
2353
2401
  const warnings = [];
2354
- const openAIOptions = (0, import_provider_utils9.parseProviderOptions)({
2402
+ const openAIOptions = await (0, import_provider_utils9.parseProviderOptions)({
2355
2403
  provider: "openai",
2356
2404
  providerOptions,
2357
2405
  schema: OpenAIProviderOptionsSchema
@@ -2392,7 +2440,7 @@ var OpenAISpeechModel = class {
2392
2440
  async doGenerate(options) {
2393
2441
  var _a, _b, _c;
2394
2442
  const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
2395
- const { requestBody, warnings } = this.getArgs(options);
2443
+ const { requestBody, warnings } = await this.getArgs(options);
2396
2444
  const {
2397
2445
  value: audio,
2398
2446
  responseHeaders,
@@ -2448,7 +2496,7 @@ function createOpenAI(options = {}) {
2448
2496
  compatibility,
2449
2497
  fetch: options.fetch
2450
2498
  });
2451
- const createCompletionModel = (modelId, settings = {}) => new OpenAICompletionLanguageModel(modelId, settings, {
2499
+ const createCompletionModel = (modelId) => new OpenAICompletionLanguageModel(modelId, {
2452
2500
  provider: `${providerName}.completion`,
2453
2501
  url: ({ path }) => `${baseURL}${path}`,
2454
2502
  headers: getHeaders,
@@ -2486,10 +2534,7 @@ function createOpenAI(options = {}) {
2486
2534
  );
2487
2535
  }
2488
2536
  if (modelId === "gpt-3.5-turbo-instruct") {
2489
- return createCompletionModel(
2490
- modelId,
2491
- settings
2492
- );
2537
+ return createCompletionModel(modelId);
2493
2538
  }
2494
2539
  return createChatModel(modelId, settings);
2495
2540
  };