@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.mjs CHANGED
@@ -351,7 +351,7 @@ var OpenAIChatLanguageModel = class {
351
351
  "image/*": [/^https?:\/\/.*$/]
352
352
  };
353
353
  }
354
- getArgs({
354
+ async getArgs({
355
355
  prompt,
356
356
  maxOutputTokens,
357
357
  temperature,
@@ -368,7 +368,7 @@ var OpenAIChatLanguageModel = class {
368
368
  }) {
369
369
  var _a, _b, _c;
370
370
  const warnings = [];
371
- const openaiOptions = (_a = parseProviderOptions({
371
+ const openaiOptions = (_a = await parseProviderOptions({
372
372
  provider: "openai",
373
373
  providerOptions,
374
374
  schema: openaiProviderOptions
@@ -506,7 +506,7 @@ var OpenAIChatLanguageModel = class {
506
506
  }
507
507
  async doGenerate(options) {
508
508
  var _a, _b, _c, _d, _e, _f, _g, _h;
509
- const { args: body, warnings } = this.getArgs(options);
509
+ const { args: body, warnings } = await this.getArgs(options);
510
510
  const {
511
511
  responseHeaders,
512
512
  value: response,
@@ -573,7 +573,7 @@ var OpenAIChatLanguageModel = class {
573
573
  };
574
574
  }
575
575
  async doStream(options) {
576
- const { args, warnings } = this.getArgs(options);
576
+ const { args, warnings } = await this.getArgs(options);
577
577
  const body = {
578
578
  ...args,
579
579
  stream: true,
@@ -866,9 +866,10 @@ import {
866
866
  combineHeaders as combineHeaders2,
867
867
  createEventSourceResponseHandler as createEventSourceResponseHandler2,
868
868
  createJsonResponseHandler as createJsonResponseHandler2,
869
+ parseProviderOptions as parseProviderOptions2,
869
870
  postJsonToApi as postJsonToApi2
870
871
  } from "@ai-sdk/provider-utils";
871
- import { z as z4 } from "zod";
872
+ import { z as z5 } from "zod";
872
873
 
873
874
  // src/convert-to-openai-completion-prompt.ts
874
875
  import {
@@ -952,14 +953,49 @@ ${user}:`]
952
953
  };
953
954
  }
954
955
 
956
+ // src/openai-completion-options.ts
957
+ import { z as z4 } from "zod";
958
+ var openaiCompletionProviderOptions = z4.object({
959
+ /**
960
+ Echo back the prompt in addition to the completion.
961
+ */
962
+ echo: z4.boolean().optional(),
963
+ /**
964
+ Modify the likelihood of specified tokens appearing in the completion.
965
+
966
+ Accepts a JSON object that maps tokens (specified by their token ID in
967
+ the GPT tokenizer) to an associated bias value from -100 to 100. You
968
+ can use this tokenizer tool to convert text to token IDs. Mathematically,
969
+ the bias is added to the logits generated by the model prior to sampling.
970
+ The exact effect will vary per model, but values between -1 and 1 should
971
+ decrease or increase likelihood of selection; values like -100 or 100
972
+ should result in a ban or exclusive selection of the relevant token.
973
+
974
+ As an example, you can pass {"50256": -100} to prevent the <|endoftext|>
975
+ token from being generated.
976
+ */
977
+ logitBias: z4.record(z4.string(), z4.number()).optional(),
978
+ /**
979
+ The suffix that comes after a completion of inserted text.
980
+ */
981
+ suffix: z4.string().optional(),
982
+ /**
983
+ A unique identifier representing your end-user, which can help OpenAI to
984
+ monitor and detect abuse. Learn more.
985
+ */
986
+ user: z4.string().optional()
987
+ });
988
+
955
989
  // src/openai-completion-language-model.ts
956
990
  var OpenAICompletionLanguageModel = class {
957
- constructor(modelId, settings, config) {
991
+ constructor(modelId, config) {
958
992
  this.specificationVersion = "v2";
959
993
  this.modelId = modelId;
960
- this.settings = settings;
961
994
  this.config = config;
962
995
  }
996
+ get providerOptionsName() {
997
+ return this.config.provider.split(".")[0].trim();
998
+ }
963
999
  get provider() {
964
1000
  return this.config.provider;
965
1001
  }
@@ -968,7 +1004,7 @@ var OpenAICompletionLanguageModel = class {
968
1004
  // no supported urls for completion models
969
1005
  };
970
1006
  }
971
- getArgs({
1007
+ async getArgs({
972
1008
  inputFormat,
973
1009
  prompt,
974
1010
  maxOutputTokens,
@@ -981,9 +1017,22 @@ var OpenAICompletionLanguageModel = class {
981
1017
  responseFormat,
982
1018
  tools,
983
1019
  toolChoice,
984
- seed
1020
+ seed,
1021
+ providerOptions
985
1022
  }) {
986
1023
  const warnings = [];
1024
+ const openaiOptions = {
1025
+ ...await parseProviderOptions2({
1026
+ provider: "openai",
1027
+ providerOptions,
1028
+ schema: openaiCompletionProviderOptions
1029
+ }),
1030
+ ...await parseProviderOptions2({
1031
+ provider: this.providerOptionsName,
1032
+ providerOptions,
1033
+ schema: openaiCompletionProviderOptions
1034
+ })
1035
+ };
987
1036
  if (topK != null) {
988
1037
  warnings.push({ type: "unsupported-setting", setting: "topK" });
989
1038
  }
@@ -1007,10 +1056,10 @@ var OpenAICompletionLanguageModel = class {
1007
1056
  // model id:
1008
1057
  model: this.modelId,
1009
1058
  // model specific settings:
1010
- echo: this.settings.echo,
1011
- logit_bias: this.settings.logitBias,
1012
- suffix: this.settings.suffix,
1013
- user: this.settings.user,
1059
+ echo: openaiOptions.echo,
1060
+ logit_bias: openaiOptions.logitBias,
1061
+ suffix: openaiOptions.suffix,
1062
+ user: openaiOptions.user,
1014
1063
  // standardized settings:
1015
1064
  max_tokens: maxOutputTokens,
1016
1065
  temperature,
@@ -1027,7 +1076,7 @@ var OpenAICompletionLanguageModel = class {
1027
1076
  };
1028
1077
  }
1029
1078
  async doGenerate(options) {
1030
- const { args, warnings } = this.getArgs(options);
1079
+ const { args, warnings } = await this.getArgs(options);
1031
1080
  const {
1032
1081
  responseHeaders,
1033
1082
  value: response,
@@ -1064,7 +1113,7 @@ var OpenAICompletionLanguageModel = class {
1064
1113
  };
1065
1114
  }
1066
1115
  async doStream(options) {
1067
- const { args, warnings } = this.getArgs(options);
1116
+ const { args, warnings } = await this.getArgs(options);
1068
1117
  const body = {
1069
1118
  ...args,
1070
1119
  stream: true,
@@ -1145,36 +1194,36 @@ var OpenAICompletionLanguageModel = class {
1145
1194
  };
1146
1195
  }
1147
1196
  };
1148
- var openaiCompletionResponseSchema = z4.object({
1149
- id: z4.string().nullish(),
1150
- created: z4.number().nullish(),
1151
- model: z4.string().nullish(),
1152
- choices: z4.array(
1153
- z4.object({
1154
- text: z4.string(),
1155
- finish_reason: z4.string()
1197
+ var openaiCompletionResponseSchema = z5.object({
1198
+ id: z5.string().nullish(),
1199
+ created: z5.number().nullish(),
1200
+ model: z5.string().nullish(),
1201
+ choices: z5.array(
1202
+ z5.object({
1203
+ text: z5.string(),
1204
+ finish_reason: z5.string()
1156
1205
  })
1157
1206
  ),
1158
- usage: z4.object({
1159
- prompt_tokens: z4.number(),
1160
- completion_tokens: z4.number()
1207
+ usage: z5.object({
1208
+ prompt_tokens: z5.number(),
1209
+ completion_tokens: z5.number()
1161
1210
  })
1162
1211
  });
1163
- var openaiCompletionChunkSchema = z4.union([
1164
- z4.object({
1165
- id: z4.string().nullish(),
1166
- created: z4.number().nullish(),
1167
- model: z4.string().nullish(),
1168
- choices: z4.array(
1169
- z4.object({
1170
- text: z4.string(),
1171
- finish_reason: z4.string().nullish(),
1172
- index: z4.number()
1212
+ var openaiCompletionChunkSchema = z5.union([
1213
+ z5.object({
1214
+ id: z5.string().nullish(),
1215
+ created: z5.number().nullish(),
1216
+ model: z5.string().nullish(),
1217
+ choices: z5.array(
1218
+ z5.object({
1219
+ text: z5.string(),
1220
+ finish_reason: z5.string().nullish(),
1221
+ index: z5.number()
1173
1222
  })
1174
1223
  ),
1175
- usage: z4.object({
1176
- prompt_tokens: z4.number(),
1177
- completion_tokens: z4.number()
1224
+ usage: z5.object({
1225
+ prompt_tokens: z5.number(),
1226
+ completion_tokens: z5.number()
1178
1227
  }).nullish()
1179
1228
  }),
1180
1229
  openaiErrorDataSchema
@@ -1187,24 +1236,24 @@ import {
1187
1236
  import {
1188
1237
  combineHeaders as combineHeaders3,
1189
1238
  createJsonResponseHandler as createJsonResponseHandler3,
1190
- parseProviderOptions as parseProviderOptions2,
1239
+ parseProviderOptions as parseProviderOptions3,
1191
1240
  postJsonToApi as postJsonToApi3
1192
1241
  } from "@ai-sdk/provider-utils";
1193
- import { z as z6 } from "zod";
1242
+ import { z as z7 } from "zod";
1194
1243
 
1195
1244
  // src/openai-embedding-options.ts
1196
- import { z as z5 } from "zod";
1197
- var openaiEmbeddingProviderOptions = z5.object({
1245
+ import { z as z6 } from "zod";
1246
+ var openaiEmbeddingProviderOptions = z6.object({
1198
1247
  /**
1199
1248
  The number of dimensions the resulting output embeddings should have.
1200
1249
  Only supported in text-embedding-3 and later models.
1201
1250
  */
1202
- dimensions: z5.number().optional(),
1251
+ dimensions: z6.number().optional(),
1203
1252
  /**
1204
1253
  A unique identifier representing your end-user, which can help OpenAI to
1205
1254
  monitor and detect abuse. Learn more.
1206
1255
  */
1207
- user: z5.string().optional()
1256
+ user: z6.string().optional()
1208
1257
  });
1209
1258
 
1210
1259
  // src/openai-embedding-model.ts
@@ -1241,7 +1290,7 @@ var OpenAIEmbeddingModel = class {
1241
1290
  values
1242
1291
  });
1243
1292
  }
1244
- const openaiOptions = (_a = parseProviderOptions2({
1293
+ const openaiOptions = (_a = await parseProviderOptions3({
1245
1294
  provider: "openai",
1246
1295
  providerOptions,
1247
1296
  schema: openaiEmbeddingProviderOptions
@@ -1277,9 +1326,9 @@ var OpenAIEmbeddingModel = class {
1277
1326
  };
1278
1327
  }
1279
1328
  };
1280
- var openaiTextEmbeddingResponseSchema = z6.object({
1281
- data: z6.array(z6.object({ embedding: z6.array(z6.number()) })),
1282
- usage: z6.object({ prompt_tokens: z6.number() }).nullish()
1329
+ var openaiTextEmbeddingResponseSchema = z7.object({
1330
+ data: z7.array(z7.object({ embedding: z7.array(z7.number()) })),
1331
+ usage: z7.object({ prompt_tokens: z7.number() }).nullish()
1283
1332
  });
1284
1333
 
1285
1334
  // src/openai-image-model.ts
@@ -1288,13 +1337,15 @@ import {
1288
1337
  createJsonResponseHandler as createJsonResponseHandler4,
1289
1338
  postJsonToApi as postJsonToApi4
1290
1339
  } from "@ai-sdk/provider-utils";
1291
- import { z as z7 } from "zod";
1340
+ import { z as z8 } from "zod";
1292
1341
 
1293
1342
  // src/openai-image-settings.ts
1294
1343
  var modelMaxImagesPerCall = {
1295
1344
  "dall-e-3": 1,
1296
- "dall-e-2": 10
1345
+ "dall-e-2": 10,
1346
+ "gpt-image-1": 10
1297
1347
  };
1348
+ var hasDefaultResponseFormat = /* @__PURE__ */ new Set(["gpt-image-1"]);
1298
1349
 
1299
1350
  // src/openai-image-model.ts
1300
1351
  var OpenAIImageModel = class {
@@ -1346,7 +1397,7 @@ var OpenAIImageModel = class {
1346
1397
  n,
1347
1398
  size,
1348
1399
  ...(_d = providerOptions.openai) != null ? _d : {},
1349
- response_format: "b64_json"
1400
+ ...!hasDefaultResponseFormat.has(this.modelId) ? { response_format: "b64_json" } : {}
1350
1401
  },
1351
1402
  failedResponseHandler: openaiFailedResponseHandler,
1352
1403
  successfulResponseHandler: createJsonResponseHandler4(
@@ -1366,13 +1417,13 @@ var OpenAIImageModel = class {
1366
1417
  };
1367
1418
  }
1368
1419
  };
1369
- var openaiImageResponseSchema = z7.object({
1370
- data: z7.array(z7.object({ b64_json: z7.string() }))
1420
+ var openaiImageResponseSchema = z8.object({
1421
+ data: z8.array(z8.object({ b64_json: z8.string() }))
1371
1422
  });
1372
1423
 
1373
1424
  // src/openai-tools.ts
1374
- import { z as z8 } from "zod";
1375
- var WebSearchPreviewParameters = z8.object({});
1425
+ import { z as z9 } from "zod";
1426
+ var WebSearchPreviewParameters = z9.object({});
1376
1427
  function webSearchPreviewTool({
1377
1428
  searchContextSize,
1378
1429
  userLocation
@@ -1396,16 +1447,16 @@ import {
1396
1447
  combineHeaders as combineHeaders5,
1397
1448
  convertBase64ToUint8Array,
1398
1449
  createJsonResponseHandler as createJsonResponseHandler5,
1399
- parseProviderOptions as parseProviderOptions3,
1450
+ parseProviderOptions as parseProviderOptions4,
1400
1451
  postFormDataToApi
1401
1452
  } from "@ai-sdk/provider-utils";
1402
- import { z as z9 } from "zod";
1403
- var openAIProviderOptionsSchema = z9.object({
1404
- include: z9.array(z9.string()).nullish(),
1405
- language: z9.string().nullish(),
1406
- prompt: z9.string().nullish(),
1407
- temperature: z9.number().min(0).max(1).nullish().default(0),
1408
- timestampGranularities: z9.array(z9.enum(["word", "segment"])).nullish().default(["segment"])
1453
+ import { z as z10 } from "zod";
1454
+ var openAIProviderOptionsSchema = z10.object({
1455
+ include: z10.array(z10.string()).nullish(),
1456
+ language: z10.string().nullish(),
1457
+ prompt: z10.string().nullish(),
1458
+ temperature: z10.number().min(0).max(1).nullish().default(0),
1459
+ timestampGranularities: z10.array(z10.enum(["word", "segment"])).nullish().default(["segment"])
1409
1460
  });
1410
1461
  var languageMap = {
1411
1462
  afrikaans: "af",
@@ -1475,14 +1526,14 @@ var OpenAITranscriptionModel = class {
1475
1526
  get provider() {
1476
1527
  return this.config.provider;
1477
1528
  }
1478
- getArgs({
1529
+ async getArgs({
1479
1530
  audio,
1480
1531
  mediaType,
1481
1532
  providerOptions
1482
1533
  }) {
1483
1534
  var _a, _b, _c, _d, _e;
1484
1535
  const warnings = [];
1485
- const openAIOptions = parseProviderOptions3({
1536
+ const openAIOptions = await parseProviderOptions4({
1486
1537
  provider: "openai",
1487
1538
  providerOptions,
1488
1539
  schema: openAIProviderOptionsSchema
@@ -1514,7 +1565,7 @@ var OpenAITranscriptionModel = class {
1514
1565
  async doGenerate(options) {
1515
1566
  var _a, _b, _c, _d, _e, _f;
1516
1567
  const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
1517
- const { formData, warnings } = this.getArgs(options);
1568
+ const { formData, warnings } = await this.getArgs(options);
1518
1569
  const {
1519
1570
  value: response,
1520
1571
  responseHeaders,
@@ -1553,15 +1604,15 @@ var OpenAITranscriptionModel = class {
1553
1604
  };
1554
1605
  }
1555
1606
  };
1556
- var openaiTranscriptionResponseSchema = z9.object({
1557
- text: z9.string(),
1558
- language: z9.string().nullish(),
1559
- duration: z9.number().nullish(),
1560
- words: z9.array(
1561
- z9.object({
1562
- word: z9.string(),
1563
- start: z9.number(),
1564
- end: z9.number()
1607
+ var openaiTranscriptionResponseSchema = z10.object({
1608
+ text: z10.string(),
1609
+ language: z10.string().nullish(),
1610
+ duration: z10.number().nullish(),
1611
+ words: z10.array(
1612
+ z10.object({
1613
+ word: z10.string(),
1614
+ start: z10.number(),
1615
+ end: z10.number()
1565
1616
  })
1566
1617
  ).nullish()
1567
1618
  });
@@ -1572,10 +1623,10 @@ import {
1572
1623
  createEventSourceResponseHandler as createEventSourceResponseHandler3,
1573
1624
  createJsonResponseHandler as createJsonResponseHandler6,
1574
1625
  generateId as generateId2,
1575
- parseProviderOptions as parseProviderOptions4,
1626
+ parseProviderOptions as parseProviderOptions5,
1576
1627
  postJsonToApi as postJsonToApi5
1577
1628
  } from "@ai-sdk/provider-utils";
1578
- import { z as z10 } from "zod";
1629
+ import { z as z11 } from "zod";
1579
1630
 
1580
1631
  // src/responses/convert-to-openai-responses-messages.ts
1581
1632
  import {
@@ -1799,7 +1850,7 @@ var OpenAIResponsesLanguageModel = class {
1799
1850
  get provider() {
1800
1851
  return this.config.provider;
1801
1852
  }
1802
- getArgs({
1853
+ async getArgs({
1803
1854
  maxOutputTokens,
1804
1855
  temperature,
1805
1856
  stopSequences,
@@ -1843,7 +1894,7 @@ var OpenAIResponsesLanguageModel = class {
1843
1894
  systemMessageMode: modelConfig.systemMessageMode
1844
1895
  });
1845
1896
  warnings.push(...messageWarnings);
1846
- const openaiOptions = parseProviderOptions4({
1897
+ const openaiOptions = await parseProviderOptions5({
1847
1898
  provider: "openai",
1848
1899
  providerOptions,
1849
1900
  schema: openaiResponsesProviderOptionsSchema
@@ -1926,7 +1977,7 @@ var OpenAIResponsesLanguageModel = class {
1926
1977
  }
1927
1978
  async doGenerate(options) {
1928
1979
  var _a, _b, _c, _d, _e, _f, _g, _h;
1929
- const { args: body, warnings } = this.getArgs(options);
1980
+ const { args: body, warnings } = await this.getArgs(options);
1930
1981
  const {
1931
1982
  responseHeaders,
1932
1983
  value: response,
@@ -1940,55 +1991,55 @@ var OpenAIResponsesLanguageModel = class {
1940
1991
  body,
1941
1992
  failedResponseHandler: openaiFailedResponseHandler,
1942
1993
  successfulResponseHandler: createJsonResponseHandler6(
1943
- z10.object({
1944
- id: z10.string(),
1945
- created_at: z10.number(),
1946
- model: z10.string(),
1947
- output: z10.array(
1948
- z10.discriminatedUnion("type", [
1949
- z10.object({
1950
- type: z10.literal("message"),
1951
- role: z10.literal("assistant"),
1952
- content: z10.array(
1953
- z10.object({
1954
- type: z10.literal("output_text"),
1955
- text: z10.string(),
1956
- annotations: z10.array(
1957
- z10.object({
1958
- type: z10.literal("url_citation"),
1959
- start_index: z10.number(),
1960
- end_index: z10.number(),
1961
- url: z10.string(),
1962
- title: z10.string()
1994
+ z11.object({
1995
+ id: z11.string(),
1996
+ created_at: z11.number(),
1997
+ model: z11.string(),
1998
+ output: z11.array(
1999
+ z11.discriminatedUnion("type", [
2000
+ z11.object({
2001
+ type: z11.literal("message"),
2002
+ role: z11.literal("assistant"),
2003
+ content: z11.array(
2004
+ z11.object({
2005
+ type: z11.literal("output_text"),
2006
+ text: z11.string(),
2007
+ annotations: z11.array(
2008
+ z11.object({
2009
+ type: z11.literal("url_citation"),
2010
+ start_index: z11.number(),
2011
+ end_index: z11.number(),
2012
+ url: z11.string(),
2013
+ title: z11.string()
1963
2014
  })
1964
2015
  )
1965
2016
  })
1966
2017
  )
1967
2018
  }),
1968
- z10.object({
1969
- type: z10.literal("function_call"),
1970
- call_id: z10.string(),
1971
- name: z10.string(),
1972
- arguments: z10.string()
2019
+ z11.object({
2020
+ type: z11.literal("function_call"),
2021
+ call_id: z11.string(),
2022
+ name: z11.string(),
2023
+ arguments: z11.string()
1973
2024
  }),
1974
- z10.object({
1975
- type: z10.literal("web_search_call")
2025
+ z11.object({
2026
+ type: z11.literal("web_search_call")
1976
2027
  }),
1977
- z10.object({
1978
- type: z10.literal("computer_call")
2028
+ z11.object({
2029
+ type: z11.literal("computer_call")
1979
2030
  }),
1980
- z10.object({
1981
- type: z10.literal("reasoning"),
1982
- summary: z10.array(
1983
- z10.object({
1984
- type: z10.literal("summary_text"),
1985
- text: z10.string()
2031
+ z11.object({
2032
+ type: z11.literal("reasoning"),
2033
+ summary: z11.array(
2034
+ z11.object({
2035
+ type: z11.literal("summary_text"),
2036
+ text: z11.string()
1986
2037
  })
1987
2038
  )
1988
2039
  })
1989
2040
  ])
1990
2041
  ),
1991
- incomplete_details: z10.object({ reason: z10.string() }).nullable(),
2042
+ incomplete_details: z11.object({ reason: z11.string() }).nullable(),
1992
2043
  usage: usageSchema
1993
2044
  })
1994
2045
  ),
@@ -2001,7 +2052,6 @@ var OpenAIResponsesLanguageModel = class {
2001
2052
  case "reasoning": {
2002
2053
  content.push({
2003
2054
  type: "reasoning",
2004
- reasoningType: "text",
2005
2055
  text: part.summary.map((summary) => summary.text).join()
2006
2056
  });
2007
2057
  break;
@@ -2065,7 +2115,7 @@ var OpenAIResponsesLanguageModel = class {
2065
2115
  };
2066
2116
  }
2067
2117
  async doStream(options) {
2068
- const { args: body, warnings } = this.getArgs(options);
2118
+ const { args: body, warnings } = await this.getArgs(options);
2069
2119
  const { responseHeaders, value: response } = await postJsonToApi5({
2070
2120
  url: this.config.url({
2071
2121
  path: "/responses",
@@ -2149,7 +2199,6 @@ var OpenAIResponsesLanguageModel = class {
2149
2199
  } else if (isResponseReasoningSummaryTextDeltaChunk(value)) {
2150
2200
  controller.enqueue({
2151
2201
  type: "reasoning",
2152
- reasoningType: "text",
2153
2202
  text: value.delta
2154
2203
  });
2155
2204
  } else if (isResponseOutputItemDoneChunk(value) && value.item.type === "function_call") {
@@ -2204,86 +2253,86 @@ var OpenAIResponsesLanguageModel = class {
2204
2253
  };
2205
2254
  }
2206
2255
  };
2207
- var usageSchema = z10.object({
2208
- input_tokens: z10.number(),
2209
- input_tokens_details: z10.object({ cached_tokens: z10.number().nullish() }).nullish(),
2210
- output_tokens: z10.number(),
2211
- output_tokens_details: z10.object({ reasoning_tokens: z10.number().nullish() }).nullish()
2256
+ var usageSchema = z11.object({
2257
+ input_tokens: z11.number(),
2258
+ input_tokens_details: z11.object({ cached_tokens: z11.number().nullish() }).nullish(),
2259
+ output_tokens: z11.number(),
2260
+ output_tokens_details: z11.object({ reasoning_tokens: z11.number().nullish() }).nullish()
2212
2261
  });
2213
- var textDeltaChunkSchema = z10.object({
2214
- type: z10.literal("response.output_text.delta"),
2215
- delta: z10.string()
2262
+ var textDeltaChunkSchema = z11.object({
2263
+ type: z11.literal("response.output_text.delta"),
2264
+ delta: z11.string()
2216
2265
  });
2217
- var responseFinishedChunkSchema = z10.object({
2218
- type: z10.enum(["response.completed", "response.incomplete"]),
2219
- response: z10.object({
2220
- incomplete_details: z10.object({ reason: z10.string() }).nullish(),
2266
+ var responseFinishedChunkSchema = z11.object({
2267
+ type: z11.enum(["response.completed", "response.incomplete"]),
2268
+ response: z11.object({
2269
+ incomplete_details: z11.object({ reason: z11.string() }).nullish(),
2221
2270
  usage: usageSchema
2222
2271
  })
2223
2272
  });
2224
- var responseCreatedChunkSchema = z10.object({
2225
- type: z10.literal("response.created"),
2226
- response: z10.object({
2227
- id: z10.string(),
2228
- created_at: z10.number(),
2229
- model: z10.string()
2273
+ var responseCreatedChunkSchema = z11.object({
2274
+ type: z11.literal("response.created"),
2275
+ response: z11.object({
2276
+ id: z11.string(),
2277
+ created_at: z11.number(),
2278
+ model: z11.string()
2230
2279
  })
2231
2280
  });
2232
- var responseOutputItemDoneSchema = z10.object({
2233
- type: z10.literal("response.output_item.done"),
2234
- output_index: z10.number(),
2235
- item: z10.discriminatedUnion("type", [
2236
- z10.object({
2237
- type: z10.literal("message")
2281
+ var responseOutputItemDoneSchema = z11.object({
2282
+ type: z11.literal("response.output_item.done"),
2283
+ output_index: z11.number(),
2284
+ item: z11.discriminatedUnion("type", [
2285
+ z11.object({
2286
+ type: z11.literal("message")
2238
2287
  }),
2239
- z10.object({
2240
- type: z10.literal("function_call"),
2241
- id: z10.string(),
2242
- call_id: z10.string(),
2243
- name: z10.string(),
2244
- arguments: z10.string(),
2245
- status: z10.literal("completed")
2288
+ z11.object({
2289
+ type: z11.literal("function_call"),
2290
+ id: z11.string(),
2291
+ call_id: z11.string(),
2292
+ name: z11.string(),
2293
+ arguments: z11.string(),
2294
+ status: z11.literal("completed")
2246
2295
  })
2247
2296
  ])
2248
2297
  });
2249
- var responseFunctionCallArgumentsDeltaSchema = z10.object({
2250
- type: z10.literal("response.function_call_arguments.delta"),
2251
- item_id: z10.string(),
2252
- output_index: z10.number(),
2253
- delta: z10.string()
2298
+ var responseFunctionCallArgumentsDeltaSchema = z11.object({
2299
+ type: z11.literal("response.function_call_arguments.delta"),
2300
+ item_id: z11.string(),
2301
+ output_index: z11.number(),
2302
+ delta: z11.string()
2254
2303
  });
2255
- var responseOutputItemAddedSchema = z10.object({
2256
- type: z10.literal("response.output_item.added"),
2257
- output_index: z10.number(),
2258
- item: z10.discriminatedUnion("type", [
2259
- z10.object({
2260
- type: z10.literal("message")
2304
+ var responseOutputItemAddedSchema = z11.object({
2305
+ type: z11.literal("response.output_item.added"),
2306
+ output_index: z11.number(),
2307
+ item: z11.discriminatedUnion("type", [
2308
+ z11.object({
2309
+ type: z11.literal("message")
2261
2310
  }),
2262
- z10.object({
2263
- type: z10.literal("function_call"),
2264
- id: z10.string(),
2265
- call_id: z10.string(),
2266
- name: z10.string(),
2267
- arguments: z10.string()
2311
+ z11.object({
2312
+ type: z11.literal("function_call"),
2313
+ id: z11.string(),
2314
+ call_id: z11.string(),
2315
+ name: z11.string(),
2316
+ arguments: z11.string()
2268
2317
  })
2269
2318
  ])
2270
2319
  });
2271
- var responseAnnotationAddedSchema = z10.object({
2272
- type: z10.literal("response.output_text.annotation.added"),
2273
- annotation: z10.object({
2274
- type: z10.literal("url_citation"),
2275
- url: z10.string(),
2276
- title: z10.string()
2320
+ var responseAnnotationAddedSchema = z11.object({
2321
+ type: z11.literal("response.output_text.annotation.added"),
2322
+ annotation: z11.object({
2323
+ type: z11.literal("url_citation"),
2324
+ url: z11.string(),
2325
+ title: z11.string()
2277
2326
  })
2278
2327
  });
2279
- var responseReasoningSummaryTextDeltaSchema = z10.object({
2280
- type: z10.literal("response.reasoning_summary_text.delta"),
2281
- item_id: z10.string(),
2282
- output_index: z10.number(),
2283
- summary_index: z10.number(),
2284
- delta: z10.string()
2328
+ var responseReasoningSummaryTextDeltaSchema = z11.object({
2329
+ type: z11.literal("response.reasoning_summary_text.delta"),
2330
+ item_id: z11.string(),
2331
+ output_index: z11.number(),
2332
+ summary_index: z11.number(),
2333
+ delta: z11.string()
2285
2334
  });
2286
- var openaiResponsesChunkSchema = z10.union([
2335
+ var openaiResponsesChunkSchema = z11.union([
2287
2336
  textDeltaChunkSchema,
2288
2337
  responseFinishedChunkSchema,
2289
2338
  responseCreatedChunkSchema,
@@ -2292,7 +2341,7 @@ var openaiResponsesChunkSchema = z10.union([
2292
2341
  responseOutputItemAddedSchema,
2293
2342
  responseAnnotationAddedSchema,
2294
2343
  responseReasoningSummaryTextDeltaSchema,
2295
- z10.object({ type: z10.string() }).passthrough()
2344
+ z11.object({ type: z11.string() }).passthrough()
2296
2345
  // fallback for unknown chunks
2297
2346
  ]);
2298
2347
  function isTextDeltaChunk(chunk) {
@@ -2340,29 +2389,29 @@ function getResponsesModelConfig(modelId) {
2340
2389
  requiredAutoTruncation: false
2341
2390
  };
2342
2391
  }
2343
- var openaiResponsesProviderOptionsSchema = z10.object({
2344
- metadata: z10.any().nullish(),
2345
- parallelToolCalls: z10.boolean().nullish(),
2346
- previousResponseId: z10.string().nullish(),
2347
- store: z10.boolean().nullish(),
2348
- user: z10.string().nullish(),
2349
- reasoningEffort: z10.string().nullish(),
2350
- strictSchemas: z10.boolean().nullish(),
2351
- instructions: z10.string().nullish(),
2352
- reasoningSummary: z10.string().nullish()
2392
+ var openaiResponsesProviderOptionsSchema = z11.object({
2393
+ metadata: z11.any().nullish(),
2394
+ parallelToolCalls: z11.boolean().nullish(),
2395
+ previousResponseId: z11.string().nullish(),
2396
+ store: z11.boolean().nullish(),
2397
+ user: z11.string().nullish(),
2398
+ reasoningEffort: z11.string().nullish(),
2399
+ strictSchemas: z11.boolean().nullish(),
2400
+ instructions: z11.string().nullish(),
2401
+ reasoningSummary: z11.string().nullish()
2353
2402
  });
2354
2403
 
2355
2404
  // src/openai-speech-model.ts
2356
2405
  import {
2357
2406
  combineHeaders as combineHeaders7,
2358
2407
  createBinaryResponseHandler,
2359
- parseProviderOptions as parseProviderOptions5,
2408
+ parseProviderOptions as parseProviderOptions6,
2360
2409
  postJsonToApi as postJsonToApi6
2361
2410
  } from "@ai-sdk/provider-utils";
2362
- import { z as z11 } from "zod";
2363
- var OpenAIProviderOptionsSchema = z11.object({
2364
- instructions: z11.string().nullish(),
2365
- speed: z11.number().min(0.25).max(4).default(1).nullish()
2411
+ import { z as z12 } from "zod";
2412
+ var OpenAIProviderOptionsSchema = z12.object({
2413
+ instructions: z12.string().nullish(),
2414
+ speed: z12.number().min(0.25).max(4).default(1).nullish()
2366
2415
  });
2367
2416
  var OpenAISpeechModel = class {
2368
2417
  constructor(modelId, config) {
@@ -2373,7 +2422,7 @@ var OpenAISpeechModel = class {
2373
2422
  get provider() {
2374
2423
  return this.config.provider;
2375
2424
  }
2376
- getArgs({
2425
+ async getArgs({
2377
2426
  text,
2378
2427
  voice = "alloy",
2379
2428
  outputFormat = "mp3",
@@ -2382,7 +2431,7 @@ var OpenAISpeechModel = class {
2382
2431
  providerOptions
2383
2432
  }) {
2384
2433
  const warnings = [];
2385
- const openAIOptions = parseProviderOptions5({
2434
+ const openAIOptions = await parseProviderOptions6({
2386
2435
  provider: "openai",
2387
2436
  providerOptions,
2388
2437
  schema: OpenAIProviderOptionsSchema
@@ -2423,7 +2472,7 @@ var OpenAISpeechModel = class {
2423
2472
  async doGenerate(options) {
2424
2473
  var _a, _b, _c;
2425
2474
  const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
2426
- const { requestBody, warnings } = this.getArgs(options);
2475
+ const { requestBody, warnings } = await this.getArgs(options);
2427
2476
  const {
2428
2477
  value: audio,
2429
2478
  responseHeaders,
@@ -2479,7 +2528,7 @@ function createOpenAI(options = {}) {
2479
2528
  compatibility,
2480
2529
  fetch: options.fetch
2481
2530
  });
2482
- const createCompletionModel = (modelId, settings = {}) => new OpenAICompletionLanguageModel(modelId, settings, {
2531
+ const createCompletionModel = (modelId) => new OpenAICompletionLanguageModel(modelId, {
2483
2532
  provider: `${providerName}.completion`,
2484
2533
  url: ({ path }) => `${baseURL}${path}`,
2485
2534
  headers: getHeaders,
@@ -2517,10 +2566,7 @@ function createOpenAI(options = {}) {
2517
2566
  );
2518
2567
  }
2519
2568
  if (modelId === "gpt-3.5-turbo-instruct") {
2520
- return createCompletionModel(
2521
- modelId,
2522
- settings
2523
- );
2569
+ return createCompletionModel(modelId);
2524
2570
  }
2525
2571
  return createChatModel(modelId, settings);
2526
2572
  };