@ai-sdk/openai 2.0.8 → 2.0.10

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
@@ -26,16 +26,35 @@ __export(src_exports, {
26
26
  module.exports = __toCommonJS(src_exports);
27
27
 
28
28
  // src/openai-provider.ts
29
- var import_provider_utils14 = require("@ai-sdk/provider-utils");
29
+ var import_provider_utils15 = require("@ai-sdk/provider-utils");
30
30
 
31
- // src/openai-chat-language-model.ts
31
+ // src/chat/openai-chat-language-model.ts
32
32
  var import_provider3 = require("@ai-sdk/provider");
33
33
  var import_provider_utils5 = require("@ai-sdk/provider-utils");
34
34
  var import_v45 = require("zod/v4");
35
35
 
36
- // src/convert-to-openai-chat-messages.ts
37
- var import_provider = require("@ai-sdk/provider");
36
+ // src/openai-error.ts
37
+ var import_v4 = require("zod/v4");
38
38
  var import_provider_utils = require("@ai-sdk/provider-utils");
39
+ var openaiErrorDataSchema = import_v4.z.object({
40
+ error: import_v4.z.object({
41
+ message: import_v4.z.string(),
42
+ // The additional information below is handled loosely to support
43
+ // OpenAI-compatible providers that have slightly different error
44
+ // responses:
45
+ type: import_v4.z.string().nullish(),
46
+ param: import_v4.z.any().nullish(),
47
+ code: import_v4.z.union([import_v4.z.string(), import_v4.z.number()]).nullish()
48
+ })
49
+ });
50
+ var openaiFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
51
+ errorSchema: openaiErrorDataSchema,
52
+ errorToMessage: (data) => data.error.message
53
+ });
54
+
55
+ // src/chat/convert-to-openai-chat-messages.ts
56
+ var import_provider = require("@ai-sdk/provider");
57
+ var import_provider_utils2 = require("@ai-sdk/provider-utils");
39
58
  function convertToOpenAIChatMessages({
40
59
  prompt,
41
60
  systemMessageMode = "system"
@@ -89,7 +108,7 @@ function convertToOpenAIChatMessages({
89
108
  return {
90
109
  type: "image_url",
91
110
  image_url: {
92
- url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${(0, import_provider_utils.convertToBase64)(part.data)}`,
111
+ url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${(0, import_provider_utils2.convertToBase64)(part.data)}`,
93
112
  // OpenAI specific extension: image detail
94
113
  detail: (_b = (_a = part.providerOptions) == null ? void 0 : _a.openai) == null ? void 0 : _b.imageDetail
95
114
  }
@@ -105,7 +124,7 @@ function convertToOpenAIChatMessages({
105
124
  return {
106
125
  type: "input_audio",
107
126
  input_audio: {
108
- data: (0, import_provider_utils.convertToBase64)(part.data),
127
+ data: (0, import_provider_utils2.convertToBase64)(part.data),
109
128
  format: "wav"
110
129
  }
111
130
  };
@@ -115,7 +134,7 @@ function convertToOpenAIChatMessages({
115
134
  return {
116
135
  type: "input_audio",
117
136
  input_audio: {
118
- data: (0, import_provider_utils.convertToBase64)(part.data),
137
+ data: (0, import_provider_utils2.convertToBase64)(part.data),
119
138
  format: "mp3"
120
139
  }
121
140
  };
@@ -136,7 +155,7 @@ function convertToOpenAIChatMessages({
136
155
  type: "file",
137
156
  file: typeof part.data === "string" && part.data.startsWith("file-") ? { file_id: part.data } : {
138
157
  filename: (_c = part.filename) != null ? _c : `part-${index}.pdf`,
139
- file_data: `data:application/pdf;base64,${(0, import_provider_utils.convertToBase64)(part.data)}`
158
+ file_data: `data:application/pdf;base64,${(0, import_provider_utils2.convertToBase64)(part.data)}`
140
159
  }
141
160
  };
142
161
  } else {
@@ -211,7 +230,7 @@ function convertToOpenAIChatMessages({
211
230
  return { messages, warnings };
212
231
  }
213
232
 
214
- // src/get-response-metadata.ts
233
+ // src/chat/get-response-metadata.ts
215
234
  function getResponseMetadata({
216
235
  id,
217
236
  model,
@@ -224,7 +243,7 @@ function getResponseMetadata({
224
243
  };
225
244
  }
226
245
 
227
- // src/map-openai-finish-reason.ts
246
+ // src/chat/map-openai-finish-reason.ts
228
247
  function mapOpenAIFinishReason(finishReason) {
229
248
  switch (finishReason) {
230
249
  case "stop":
@@ -241,16 +260,16 @@ function mapOpenAIFinishReason(finishReason) {
241
260
  }
242
261
  }
243
262
 
244
- // src/openai-chat-options.ts
245
- var import_v4 = require("zod/v4");
246
- var openaiProviderOptions = import_v4.z.object({
263
+ // src/chat/openai-chat-options.ts
264
+ var import_v42 = require("zod/v4");
265
+ var openaiProviderOptions = import_v42.z.object({
247
266
  /**
248
267
  * Modify the likelihood of specified tokens appearing in the completion.
249
268
  *
250
269
  * Accepts a JSON object that maps tokens (specified by their token ID in
251
270
  * the GPT tokenizer) to an associated bias value from -100 to 100.
252
271
  */
253
- logitBias: import_v4.z.record(import_v4.z.coerce.number(), import_v4.z.number()).optional(),
272
+ logitBias: import_v42.z.record(import_v42.z.coerce.number(), import_v42.z.number()).optional(),
254
273
  /**
255
274
  * Return the log probabilities of the tokens.
256
275
  *
@@ -260,42 +279,42 @@ var openaiProviderOptions = import_v4.z.object({
260
279
  * Setting to a number will return the log probabilities of the top n
261
280
  * tokens that were generated.
262
281
  */
263
- logprobs: import_v4.z.union([import_v4.z.boolean(), import_v4.z.number()]).optional(),
282
+ logprobs: import_v42.z.union([import_v42.z.boolean(), import_v42.z.number()]).optional(),
264
283
  /**
265
284
  * Whether to enable parallel function calling during tool use. Default to true.
266
285
  */
267
- parallelToolCalls: import_v4.z.boolean().optional(),
286
+ parallelToolCalls: import_v42.z.boolean().optional(),
268
287
  /**
269
288
  * A unique identifier representing your end-user, which can help OpenAI to
270
289
  * monitor and detect abuse.
271
290
  */
272
- user: import_v4.z.string().optional(),
291
+ user: import_v42.z.string().optional(),
273
292
  /**
274
293
  * Reasoning effort for reasoning models. Defaults to `medium`.
275
294
  */
276
- reasoningEffort: import_v4.z.enum(["minimal", "low", "medium", "high"]).optional(),
295
+ reasoningEffort: import_v42.z.enum(["minimal", "low", "medium", "high"]).optional(),
277
296
  /**
278
297
  * Maximum number of completion tokens to generate. Useful for reasoning models.
279
298
  */
280
- maxCompletionTokens: import_v4.z.number().optional(),
299
+ maxCompletionTokens: import_v42.z.number().optional(),
281
300
  /**
282
301
  * Whether to enable persistence in responses API.
283
302
  */
284
- store: import_v4.z.boolean().optional(),
303
+ store: import_v42.z.boolean().optional(),
285
304
  /**
286
305
  * Metadata to associate with the request.
287
306
  */
288
- metadata: import_v4.z.record(import_v4.z.string().max(64), import_v4.z.string().max(512)).optional(),
307
+ metadata: import_v42.z.record(import_v42.z.string().max(64), import_v42.z.string().max(512)).optional(),
289
308
  /**
290
309
  * Parameters for prediction mode.
291
310
  */
292
- prediction: import_v4.z.record(import_v4.z.string(), import_v4.z.any()).optional(),
311
+ prediction: import_v42.z.record(import_v42.z.string(), import_v42.z.any()).optional(),
293
312
  /**
294
313
  * Whether to use structured outputs.
295
314
  *
296
315
  * @default true
297
316
  */
298
- structuredOutputs: import_v4.z.boolean().optional(),
317
+ structuredOutputs: import_v42.z.boolean().optional(),
299
318
  /**
300
319
  * Service tier for the request.
301
320
  * - 'auto': Default service tier
@@ -304,40 +323,21 @@ var openaiProviderOptions = import_v4.z.object({
304
323
  *
305
324
  * @default 'auto'
306
325
  */
307
- serviceTier: import_v4.z.enum(["auto", "flex", "priority"]).optional(),
326
+ serviceTier: import_v42.z.enum(["auto", "flex", "priority"]).optional(),
308
327
  /**
309
328
  * Whether to use strict JSON schema validation.
310
329
  *
311
330
  * @default false
312
331
  */
313
- strictJsonSchema: import_v4.z.boolean().optional(),
332
+ strictJsonSchema: import_v42.z.boolean().optional(),
314
333
  /**
315
334
  * Controls the verbosity of the model's responses.
316
335
  * Lower values will result in more concise responses, while higher values will result in more verbose responses.
317
336
  */
318
- textVerbosity: import_v4.z.enum(["low", "medium", "high"]).optional()
337
+ textVerbosity: import_v42.z.enum(["low", "medium", "high"]).optional()
319
338
  });
320
339
 
321
- // src/openai-error.ts
322
- var import_v42 = require("zod/v4");
323
- var import_provider_utils2 = require("@ai-sdk/provider-utils");
324
- var openaiErrorDataSchema = import_v42.z.object({
325
- error: import_v42.z.object({
326
- message: import_v42.z.string(),
327
- // The additional information below is handled loosely to support
328
- // OpenAI-compatible providers that have slightly different error
329
- // responses:
330
- type: import_v42.z.string().nullish(),
331
- param: import_v42.z.any().nullish(),
332
- code: import_v42.z.union([import_v42.z.string(), import_v42.z.number()]).nullish()
333
- })
334
- });
335
- var openaiFailedResponseHandler = (0, import_provider_utils2.createJsonErrorResponseHandler)({
336
- errorSchema: openaiErrorDataSchema,
337
- errorToMessage: (data) => data.error.message
338
- });
339
-
340
- // src/openai-prepare-tools.ts
340
+ // src/chat/openai-chat-prepare-tools.ts
341
341
  var import_provider2 = require("@ai-sdk/provider");
342
342
 
343
343
  // src/tool/file-search.ts
@@ -426,8 +426,8 @@ var webSearchPreview = (0, import_provider_utils4.createProviderDefinedToolFacto
426
426
  inputSchema: import_v44.z.object({})
427
427
  });
428
428
 
429
- // src/openai-prepare-tools.ts
430
- function prepareTools({
429
+ // src/chat/openai-chat-prepare-tools.ts
430
+ function prepareChatTools({
431
431
  tools,
432
432
  toolChoice,
433
433
  structuredOutputs,
@@ -513,7 +513,7 @@ function prepareTools({
513
513
  }
514
514
  }
515
515
 
516
- // src/openai-chat-language-model.ts
516
+ // src/chat/openai-chat-language-model.ts
517
517
  var OpenAIChatLanguageModel = class {
518
518
  constructor(modelId, config) {
519
519
  this.specificationVersion = "v2";
@@ -598,7 +598,7 @@ var OpenAIChatLanguageModel = class {
598
598
  seed,
599
599
  verbosity: openaiOptions.textVerbosity,
600
600
  // openai specific settings:
601
- // TODO remove in next major version; we auto-map maxOutputTokens now
601
+ // TODO AI SDK 6: remove, we auto-map maxOutputTokens now
602
602
  max_completion_tokens: openaiOptions.maxCompletionTokens,
603
603
  store: openaiOptions.store,
604
604
  metadata: openaiOptions.metadata,
@@ -698,7 +698,7 @@ var OpenAIChatLanguageModel = class {
698
698
  tools: openaiTools2,
699
699
  toolChoice: openaiToolChoice,
700
700
  toolWarnings
701
- } = prepareTools({
701
+ } = prepareChatTools({
702
702
  tools,
703
703
  toolChoice,
704
704
  structuredOutputs,
@@ -1168,11 +1168,11 @@ var reasoningModels = {
1168
1168
  }
1169
1169
  };
1170
1170
 
1171
- // src/openai-completion-language-model.ts
1171
+ // src/completion/openai-completion-language-model.ts
1172
1172
  var import_provider_utils6 = require("@ai-sdk/provider-utils");
1173
1173
  var import_v47 = require("zod/v4");
1174
1174
 
1175
- // src/convert-to-openai-completion-prompt.ts
1175
+ // src/completion/convert-to-openai-completion-prompt.ts
1176
1176
  var import_provider4 = require("@ai-sdk/provider");
1177
1177
  function convertToOpenAICompletionPrompt({
1178
1178
  prompt,
@@ -1247,7 +1247,37 @@ ${user}:`]
1247
1247
  };
1248
1248
  }
1249
1249
 
1250
- // src/openai-completion-options.ts
1250
+ // src/completion/get-response-metadata.ts
1251
+ function getResponseMetadata2({
1252
+ id,
1253
+ model,
1254
+ created
1255
+ }) {
1256
+ return {
1257
+ id: id != null ? id : void 0,
1258
+ modelId: model != null ? model : void 0,
1259
+ timestamp: created != null ? new Date(created * 1e3) : void 0
1260
+ };
1261
+ }
1262
+
1263
+ // src/completion/map-openai-finish-reason.ts
1264
+ function mapOpenAIFinishReason2(finishReason) {
1265
+ switch (finishReason) {
1266
+ case "stop":
1267
+ return "stop";
1268
+ case "length":
1269
+ return "length";
1270
+ case "content_filter":
1271
+ return "content-filter";
1272
+ case "function_call":
1273
+ case "tool_calls":
1274
+ return "tool-calls";
1275
+ default:
1276
+ return "unknown";
1277
+ }
1278
+ }
1279
+
1280
+ // src/completion/openai-completion-options.ts
1251
1281
  var import_v46 = require("zod/v4");
1252
1282
  var openaiCompletionProviderOptions = import_v46.z.object({
1253
1283
  /**
@@ -1290,7 +1320,7 @@ var openaiCompletionProviderOptions = import_v46.z.object({
1290
1320
  logprobs: import_v46.z.union([import_v46.z.boolean(), import_v46.z.number()]).optional()
1291
1321
  });
1292
1322
 
1293
- // src/openai-completion-language-model.ts
1323
+ // src/completion/openai-completion-language-model.ts
1294
1324
  var OpenAICompletionLanguageModel = class {
1295
1325
  constructor(modelId, config) {
1296
1326
  this.specificationVersion = "v2";
@@ -1410,10 +1440,10 @@ var OpenAICompletionLanguageModel = class {
1410
1440
  outputTokens: (_b = response.usage) == null ? void 0 : _b.completion_tokens,
1411
1441
  totalTokens: (_c = response.usage) == null ? void 0 : _c.total_tokens
1412
1442
  },
1413
- finishReason: mapOpenAIFinishReason(choice.finish_reason),
1443
+ finishReason: mapOpenAIFinishReason2(choice.finish_reason),
1414
1444
  request: { body: args },
1415
1445
  response: {
1416
- ...getResponseMetadata(response),
1446
+ ...getResponseMetadata2(response),
1417
1447
  headers: responseHeaders,
1418
1448
  body: rawResponse
1419
1449
  },
@@ -1477,7 +1507,7 @@ var OpenAICompletionLanguageModel = class {
1477
1507
  isFirstChunk = false;
1478
1508
  controller.enqueue({
1479
1509
  type: "response-metadata",
1480
- ...getResponseMetadata(value)
1510
+ ...getResponseMetadata2(value)
1481
1511
  });
1482
1512
  controller.enqueue({ type: "text-start", id: "0" });
1483
1513
  }
@@ -1488,7 +1518,7 @@ var OpenAICompletionLanguageModel = class {
1488
1518
  }
1489
1519
  const choice = value.choices[0];
1490
1520
  if ((choice == null ? void 0 : choice.finish_reason) != null) {
1491
- finishReason = mapOpenAIFinishReason(choice.finish_reason);
1521
+ finishReason = mapOpenAIFinishReason2(choice.finish_reason);
1492
1522
  }
1493
1523
  if ((choice == null ? void 0 : choice.logprobs) != null) {
1494
1524
  providerMetadata.openai.logprobs = choice.logprobs;
@@ -1563,12 +1593,12 @@ var openaiCompletionChunkSchema = import_v47.z.union([
1563
1593
  openaiErrorDataSchema
1564
1594
  ]);
1565
1595
 
1566
- // src/openai-embedding-model.ts
1596
+ // src/embedding/openai-embedding-model.ts
1567
1597
  var import_provider5 = require("@ai-sdk/provider");
1568
1598
  var import_provider_utils7 = require("@ai-sdk/provider-utils");
1569
1599
  var import_v49 = require("zod/v4");
1570
1600
 
1571
- // src/openai-embedding-options.ts
1601
+ // src/embedding/openai-embedding-options.ts
1572
1602
  var import_v48 = require("zod/v4");
1573
1603
  var openaiEmbeddingProviderOptions = import_v48.z.object({
1574
1604
  /**
@@ -1583,7 +1613,7 @@ var openaiEmbeddingProviderOptions = import_v48.z.object({
1583
1613
  user: import_v48.z.string().optional()
1584
1614
  });
1585
1615
 
1586
- // src/openai-embedding-model.ts
1616
+ // src/embedding/openai-embedding-model.ts
1587
1617
  var OpenAIEmbeddingModel = class {
1588
1618
  constructor(modelId, config) {
1589
1619
  this.specificationVersion = "v2";
@@ -1651,11 +1681,11 @@ var openaiTextEmbeddingResponseSchema = import_v49.z.object({
1651
1681
  usage: import_v49.z.object({ prompt_tokens: import_v49.z.number() }).nullish()
1652
1682
  });
1653
1683
 
1654
- // src/openai-image-model.ts
1684
+ // src/image/openai-image-model.ts
1655
1685
  var import_provider_utils8 = require("@ai-sdk/provider-utils");
1656
1686
  var import_v410 = require("zod/v4");
1657
1687
 
1658
- // src/openai-image-settings.ts
1688
+ // src/image/openai-image-options.ts
1659
1689
  var modelMaxImagesPerCall = {
1660
1690
  "dall-e-3": 1,
1661
1691
  "dall-e-2": 10,
@@ -1663,7 +1693,7 @@ var modelMaxImagesPerCall = {
1663
1693
  };
1664
1694
  var hasDefaultResponseFormat = /* @__PURE__ */ new Set(["gpt-image-1"]);
1665
1695
 
1666
- // src/openai-image-model.ts
1696
+ // src/image/openai-image-model.ts
1667
1697
  var OpenAIImageModel = class {
1668
1698
  constructor(modelId, config) {
1669
1699
  this.modelId = modelId;
@@ -1747,210 +1777,39 @@ var openaiImageResponseSchema = import_v410.z.object({
1747
1777
  )
1748
1778
  });
1749
1779
 
1750
- // src/openai-tools.ts
1751
- var openaiTools = {
1752
- fileSearch,
1753
- webSearchPreview
1754
- };
1755
-
1756
- // src/openai-transcription-model.ts
1780
+ // src/tool/code-interpreter.ts
1757
1781
  var import_provider_utils9 = require("@ai-sdk/provider-utils");
1758
- var import_v412 = require("zod/v4");
1759
-
1760
- // src/openai-transcription-options.ts
1761
1782
  var import_v411 = require("zod/v4");
1762
- var openAITranscriptionProviderOptions = import_v411.z.object({
1763
- /**
1764
- * Additional information to include in the transcription response.
1765
- */
1766
- include: import_v411.z.array(import_v411.z.string()).optional(),
1767
- /**
1768
- * The language of the input audio in ISO-639-1 format.
1769
- */
1770
- language: import_v411.z.string().optional(),
1771
- /**
1772
- * An optional text to guide the model's style or continue a previous audio segment.
1773
- */
1774
- prompt: import_v411.z.string().optional(),
1775
- /**
1776
- * The sampling temperature, between 0 and 1.
1777
- * @default 0
1778
- */
1779
- temperature: import_v411.z.number().min(0).max(1).default(0).optional(),
1780
- /**
1781
- * The timestamp granularities to populate for this transcription.
1782
- * @default ['segment']
1783
- */
1784
- timestampGranularities: import_v411.z.array(import_v411.z.enum(["word", "segment"])).default(["segment"]).optional()
1783
+ var codeInterpreterArgsSchema = import_v411.z.object({
1784
+ container: import_v411.z.union([
1785
+ import_v411.z.string(),
1786
+ import_v411.z.object({
1787
+ fileIds: import_v411.z.array(import_v411.z.string()).optional()
1788
+ })
1789
+ ]).optional()
1790
+ });
1791
+ var codeInterpreter = (0, import_provider_utils9.createProviderDefinedToolFactory)({
1792
+ id: "openai.code_interpreter",
1793
+ name: "code_interpreter",
1794
+ inputSchema: import_v411.z.object({})
1785
1795
  });
1786
1796
 
1787
- // src/openai-transcription-model.ts
1788
- var languageMap = {
1789
- afrikaans: "af",
1790
- arabic: "ar",
1791
- armenian: "hy",
1792
- azerbaijani: "az",
1793
- belarusian: "be",
1794
- bosnian: "bs",
1795
- bulgarian: "bg",
1796
- catalan: "ca",
1797
- chinese: "zh",
1798
- croatian: "hr",
1799
- czech: "cs",
1800
- danish: "da",
1801
- dutch: "nl",
1802
- english: "en",
1803
- estonian: "et",
1804
- finnish: "fi",
1805
- french: "fr",
1806
- galician: "gl",
1807
- german: "de",
1808
- greek: "el",
1809
- hebrew: "he",
1810
- hindi: "hi",
1811
- hungarian: "hu",
1812
- icelandic: "is",
1813
- indonesian: "id",
1814
- italian: "it",
1815
- japanese: "ja",
1816
- kannada: "kn",
1817
- kazakh: "kk",
1818
- korean: "ko",
1819
- latvian: "lv",
1820
- lithuanian: "lt",
1821
- macedonian: "mk",
1822
- malay: "ms",
1823
- marathi: "mr",
1824
- maori: "mi",
1825
- nepali: "ne",
1826
- norwegian: "no",
1827
- persian: "fa",
1828
- polish: "pl",
1829
- portuguese: "pt",
1830
- romanian: "ro",
1831
- russian: "ru",
1832
- serbian: "sr",
1833
- slovak: "sk",
1834
- slovenian: "sl",
1835
- spanish: "es",
1836
- swahili: "sw",
1837
- swedish: "sv",
1838
- tagalog: "tl",
1839
- tamil: "ta",
1840
- thai: "th",
1841
- turkish: "tr",
1842
- ukrainian: "uk",
1843
- urdu: "ur",
1844
- vietnamese: "vi",
1845
- welsh: "cy"
1846
- };
1847
- var OpenAITranscriptionModel = class {
1848
- constructor(modelId, config) {
1849
- this.modelId = modelId;
1850
- this.config = config;
1851
- this.specificationVersion = "v2";
1852
- }
1853
- get provider() {
1854
- return this.config.provider;
1855
- }
1856
- async getArgs({
1857
- audio,
1858
- mediaType,
1859
- providerOptions
1860
- }) {
1861
- const warnings = [];
1862
- const openAIOptions = await (0, import_provider_utils9.parseProviderOptions)({
1863
- provider: "openai",
1864
- providerOptions,
1865
- schema: openAITranscriptionProviderOptions
1866
- });
1867
- const formData = new FormData();
1868
- const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([(0, import_provider_utils9.convertBase64ToUint8Array)(audio)]);
1869
- formData.append("model", this.modelId);
1870
- formData.append("file", new File([blob], "audio", { type: mediaType }));
1871
- if (openAIOptions) {
1872
- const transcriptionModelOptions = {
1873
- include: openAIOptions.include,
1874
- language: openAIOptions.language,
1875
- prompt: openAIOptions.prompt,
1876
- temperature: openAIOptions.temperature,
1877
- timestamp_granularities: openAIOptions.timestampGranularities
1878
- };
1879
- for (const [key, value] of Object.entries(transcriptionModelOptions)) {
1880
- if (value != null) {
1881
- formData.append(key, String(value));
1882
- }
1883
- }
1884
- }
1885
- return {
1886
- formData,
1887
- warnings
1888
- };
1889
- }
1890
- async doGenerate(options) {
1891
- var _a, _b, _c, _d, _e, _f;
1892
- const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
1893
- const { formData, warnings } = await this.getArgs(options);
1894
- const {
1895
- value: response,
1896
- responseHeaders,
1897
- rawValue: rawResponse
1898
- } = await (0, import_provider_utils9.postFormDataToApi)({
1899
- url: this.config.url({
1900
- path: "/audio/transcriptions",
1901
- modelId: this.modelId
1902
- }),
1903
- headers: (0, import_provider_utils9.combineHeaders)(this.config.headers(), options.headers),
1904
- formData,
1905
- failedResponseHandler: openaiFailedResponseHandler,
1906
- successfulResponseHandler: (0, import_provider_utils9.createJsonResponseHandler)(
1907
- openaiTranscriptionResponseSchema
1908
- ),
1909
- abortSignal: options.abortSignal,
1910
- fetch: this.config.fetch
1911
- });
1912
- const language = response.language != null && response.language in languageMap ? languageMap[response.language] : void 0;
1913
- return {
1914
- text: response.text,
1915
- segments: (_e = (_d = response.words) == null ? void 0 : _d.map((word) => ({
1916
- text: word.word,
1917
- startSecond: word.start,
1918
- endSecond: word.end
1919
- }))) != null ? _e : [],
1920
- language,
1921
- durationInSeconds: (_f = response.duration) != null ? _f : void 0,
1922
- warnings,
1923
- response: {
1924
- timestamp: currentDate,
1925
- modelId: this.modelId,
1926
- headers: responseHeaders,
1927
- body: rawResponse
1928
- }
1929
- };
1930
- }
1797
+ // src/openai-tools.ts
1798
+ var openaiTools = {
1799
+ codeInterpreter,
1800
+ fileSearch,
1801
+ webSearchPreview
1931
1802
  };
1932
- var openaiTranscriptionResponseSchema = import_v412.z.object({
1933
- text: import_v412.z.string(),
1934
- language: import_v412.z.string().nullish(),
1935
- duration: import_v412.z.number().nullish(),
1936
- words: import_v412.z.array(
1937
- import_v412.z.object({
1938
- word: import_v412.z.string(),
1939
- start: import_v412.z.number(),
1940
- end: import_v412.z.number()
1941
- })
1942
- ).nullish()
1943
- });
1944
1803
 
1945
1804
  // src/responses/openai-responses-language-model.ts
1946
1805
  var import_provider8 = require("@ai-sdk/provider");
1947
1806
  var import_provider_utils12 = require("@ai-sdk/provider-utils");
1948
- var import_v414 = require("zod/v4");
1807
+ var import_v413 = require("zod/v4");
1949
1808
 
1950
1809
  // src/responses/convert-to-openai-responses-messages.ts
1951
1810
  var import_provider6 = require("@ai-sdk/provider");
1952
1811
  var import_provider_utils10 = require("@ai-sdk/provider-utils");
1953
- var import_v413 = require("zod/v4");
1812
+ var import_v412 = require("zod/v4");
1954
1813
  var import_provider_utils11 = require("@ai-sdk/provider-utils");
1955
1814
  async function convertToOpenAIResponsesMessages({
1956
1815
  prompt,
@@ -2002,7 +1861,7 @@ async function convertToOpenAIResponsesMessages({
2002
1861
  return {
2003
1862
  type: "input_image",
2004
1863
  ...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && part.data.startsWith("file-") ? { file_id: part.data } : {
2005
- image_url: `data:${mediaType};base64,${part.data}`
1864
+ image_url: `data:${mediaType};base64,${(0, import_provider_utils11.convertToBase64)(part.data)}`
2006
1865
  },
2007
1866
  detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b2.imageDetail
2008
1867
  };
@@ -2134,9 +1993,9 @@ async function convertToOpenAIResponsesMessages({
2134
1993
  }
2135
1994
  return { messages, warnings };
2136
1995
  }
2137
- var openaiResponsesReasoningProviderOptionsSchema = import_v413.z.object({
2138
- itemId: import_v413.z.string().nullish(),
2139
- reasoningEncryptedContent: import_v413.z.string().nullish()
1996
+ var openaiResponsesReasoningProviderOptionsSchema = import_v412.z.object({
1997
+ itemId: import_v412.z.string().nullish(),
1998
+ reasoningEncryptedContent: import_v412.z.string().nullish()
2140
1999
  });
2141
2000
 
2142
2001
  // src/responses/map-openai-responses-finish-reason.ts
@@ -2181,7 +2040,7 @@ function prepareResponsesTools({
2181
2040
  strict: strictJsonSchema
2182
2041
  });
2183
2042
  break;
2184
- case "provider-defined":
2043
+ case "provider-defined": {
2185
2044
  switch (tool.id) {
2186
2045
  case "openai.file_search": {
2187
2046
  const args = fileSearchArgsSchema.parse(tool.args);
@@ -2194,18 +2053,30 @@ function prepareResponsesTools({
2194
2053
  });
2195
2054
  break;
2196
2055
  }
2197
- case "openai.web_search_preview":
2056
+ case "openai.web_search_preview": {
2057
+ const args = webSearchPreviewArgsSchema.parse(tool.args);
2198
2058
  openaiTools2.push({
2199
2059
  type: "web_search_preview",
2200
- search_context_size: tool.args.searchContextSize,
2201
- user_location: tool.args.userLocation
2060
+ search_context_size: args.searchContextSize,
2061
+ user_location: args.userLocation
2202
2062
  });
2203
2063
  break;
2204
- default:
2064
+ }
2065
+ case "openai.code_interpreter": {
2066
+ const args = codeInterpreterArgsSchema.parse(tool.args);
2067
+ openaiTools2.push({
2068
+ type: "code_interpreter",
2069
+ container: args.container == null ? { type: "auto", file_ids: void 0 } : typeof args.container === "string" ? args.container : { type: "auto", file_ids: args.container.fileIds }
2070
+ });
2071
+ break;
2072
+ }
2073
+ default: {
2205
2074
  toolWarnings.push({ type: "unsupported-tool", tool });
2206
2075
  break;
2076
+ }
2207
2077
  }
2208
2078
  break;
2079
+ }
2209
2080
  default:
2210
2081
  toolWarnings.push({ type: "unsupported-tool", tool });
2211
2082
  break;
@@ -2223,7 +2094,7 @@ function prepareResponsesTools({
2223
2094
  case "tool":
2224
2095
  return {
2225
2096
  tools: openaiTools2,
2226
- toolChoice: toolChoice.toolName === "file_search" ? { type: "file_search" } : toolChoice.toolName === "web_search_preview" ? { type: "web_search_preview" } : { type: "function", name: toolChoice.toolName },
2097
+ toolChoice: toolChoice.toolName === "code_interpreter" || toolChoice.toolName === "file_search" || toolChoice.toolName === "web_search_preview" ? { type: toolChoice.toolName } : { type: "function", name: toolChoice.toolName },
2227
2098
  toolWarnings
2228
2099
  };
2229
2100
  default: {
@@ -2428,72 +2299,72 @@ var OpenAIResponsesLanguageModel = class {
2428
2299
  body,
2429
2300
  failedResponseHandler: openaiFailedResponseHandler,
2430
2301
  successfulResponseHandler: (0, import_provider_utils12.createJsonResponseHandler)(
2431
- import_v414.z.object({
2432
- id: import_v414.z.string(),
2433
- created_at: import_v414.z.number(),
2434
- error: import_v414.z.object({
2435
- code: import_v414.z.string(),
2436
- message: import_v414.z.string()
2302
+ import_v413.z.object({
2303
+ id: import_v413.z.string(),
2304
+ created_at: import_v413.z.number(),
2305
+ error: import_v413.z.object({
2306
+ code: import_v413.z.string(),
2307
+ message: import_v413.z.string()
2437
2308
  }).nullish(),
2438
- model: import_v414.z.string(),
2439
- output: import_v414.z.array(
2440
- import_v414.z.discriminatedUnion("type", [
2441
- import_v414.z.object({
2442
- type: import_v414.z.literal("message"),
2443
- role: import_v414.z.literal("assistant"),
2444
- id: import_v414.z.string(),
2445
- content: import_v414.z.array(
2446
- import_v414.z.object({
2447
- type: import_v414.z.literal("output_text"),
2448
- text: import_v414.z.string(),
2449
- annotations: import_v414.z.array(
2450
- import_v414.z.object({
2451
- type: import_v414.z.literal("url_citation"),
2452
- start_index: import_v414.z.number(),
2453
- end_index: import_v414.z.number(),
2454
- url: import_v414.z.string(),
2455
- title: import_v414.z.string()
2309
+ model: import_v413.z.string(),
2310
+ output: import_v413.z.array(
2311
+ import_v413.z.discriminatedUnion("type", [
2312
+ import_v413.z.object({
2313
+ type: import_v413.z.literal("message"),
2314
+ role: import_v413.z.literal("assistant"),
2315
+ id: import_v413.z.string(),
2316
+ content: import_v413.z.array(
2317
+ import_v413.z.object({
2318
+ type: import_v413.z.literal("output_text"),
2319
+ text: import_v413.z.string(),
2320
+ annotations: import_v413.z.array(
2321
+ import_v413.z.object({
2322
+ type: import_v413.z.literal("url_citation"),
2323
+ start_index: import_v413.z.number(),
2324
+ end_index: import_v413.z.number(),
2325
+ url: import_v413.z.string(),
2326
+ title: import_v413.z.string()
2456
2327
  })
2457
2328
  )
2458
2329
  })
2459
2330
  )
2460
2331
  }),
2461
- import_v414.z.object({
2462
- type: import_v414.z.literal("function_call"),
2463
- call_id: import_v414.z.string(),
2464
- name: import_v414.z.string(),
2465
- arguments: import_v414.z.string(),
2466
- id: import_v414.z.string()
2332
+ import_v413.z.object({
2333
+ type: import_v413.z.literal("function_call"),
2334
+ call_id: import_v413.z.string(),
2335
+ name: import_v413.z.string(),
2336
+ arguments: import_v413.z.string(),
2337
+ id: import_v413.z.string()
2467
2338
  }),
2468
- import_v414.z.object({
2469
- type: import_v414.z.literal("web_search_call"),
2470
- id: import_v414.z.string(),
2471
- status: import_v414.z.string().optional()
2339
+ import_v413.z.object({
2340
+ type: import_v413.z.literal("web_search_call"),
2341
+ id: import_v413.z.string(),
2342
+ status: import_v413.z.string().optional()
2472
2343
  }),
2473
- import_v414.z.object({
2474
- type: import_v414.z.literal("computer_call"),
2475
- id: import_v414.z.string(),
2476
- status: import_v414.z.string().optional()
2344
+ import_v413.z.object({
2345
+ type: import_v413.z.literal("computer_call"),
2346
+ id: import_v413.z.string(),
2347
+ status: import_v413.z.string().optional()
2477
2348
  }),
2478
- import_v414.z.object({
2479
- type: import_v414.z.literal("file_search_call"),
2480
- id: import_v414.z.string(),
2481
- status: import_v414.z.string().optional()
2349
+ import_v413.z.object({
2350
+ type: import_v413.z.literal("file_search_call"),
2351
+ id: import_v413.z.string(),
2352
+ status: import_v413.z.string().optional()
2482
2353
  }),
2483
- import_v414.z.object({
2484
- type: import_v414.z.literal("reasoning"),
2485
- id: import_v414.z.string(),
2486
- encrypted_content: import_v414.z.string().nullish(),
2487
- summary: import_v414.z.array(
2488
- import_v414.z.object({
2489
- type: import_v414.z.literal("summary_text"),
2490
- text: import_v414.z.string()
2354
+ import_v413.z.object({
2355
+ type: import_v413.z.literal("reasoning"),
2356
+ id: import_v413.z.string(),
2357
+ encrypted_content: import_v413.z.string().nullish(),
2358
+ summary: import_v413.z.array(
2359
+ import_v413.z.object({
2360
+ type: import_v413.z.literal("summary_text"),
2361
+ text: import_v413.z.string()
2491
2362
  })
2492
2363
  )
2493
2364
  })
2494
2365
  ])
2495
2366
  ),
2496
- incomplete_details: import_v414.z.object({ reason: import_v414.z.string() }).nullable(),
2367
+ incomplete_details: import_v413.z.object({ reason: import_v413.z.string() }).nullable(),
2497
2368
  usage: usageSchema2
2498
2369
  })
2499
2370
  ),
@@ -2940,140 +2811,140 @@ var OpenAIResponsesLanguageModel = class {
2940
2811
  };
2941
2812
  }
2942
2813
  };
2943
- var usageSchema2 = import_v414.z.object({
2944
- input_tokens: import_v414.z.number(),
2945
- input_tokens_details: import_v414.z.object({ cached_tokens: import_v414.z.number().nullish() }).nullish(),
2946
- output_tokens: import_v414.z.number(),
2947
- output_tokens_details: import_v414.z.object({ reasoning_tokens: import_v414.z.number().nullish() }).nullish()
2814
+ var usageSchema2 = import_v413.z.object({
2815
+ input_tokens: import_v413.z.number(),
2816
+ input_tokens_details: import_v413.z.object({ cached_tokens: import_v413.z.number().nullish() }).nullish(),
2817
+ output_tokens: import_v413.z.number(),
2818
+ output_tokens_details: import_v413.z.object({ reasoning_tokens: import_v413.z.number().nullish() }).nullish()
2948
2819
  });
2949
- var textDeltaChunkSchema = import_v414.z.object({
2950
- type: import_v414.z.literal("response.output_text.delta"),
2951
- item_id: import_v414.z.string(),
2952
- delta: import_v414.z.string()
2820
+ var textDeltaChunkSchema = import_v413.z.object({
2821
+ type: import_v413.z.literal("response.output_text.delta"),
2822
+ item_id: import_v413.z.string(),
2823
+ delta: import_v413.z.string()
2953
2824
  });
2954
- var errorChunkSchema = import_v414.z.object({
2955
- type: import_v414.z.literal("error"),
2956
- code: import_v414.z.string(),
2957
- message: import_v414.z.string(),
2958
- param: import_v414.z.string().nullish(),
2959
- sequence_number: import_v414.z.number()
2825
+ var errorChunkSchema = import_v413.z.object({
2826
+ type: import_v413.z.literal("error"),
2827
+ code: import_v413.z.string(),
2828
+ message: import_v413.z.string(),
2829
+ param: import_v413.z.string().nullish(),
2830
+ sequence_number: import_v413.z.number()
2960
2831
  });
2961
- var responseFinishedChunkSchema = import_v414.z.object({
2962
- type: import_v414.z.enum(["response.completed", "response.incomplete"]),
2963
- response: import_v414.z.object({
2964
- incomplete_details: import_v414.z.object({ reason: import_v414.z.string() }).nullish(),
2832
+ var responseFinishedChunkSchema = import_v413.z.object({
2833
+ type: import_v413.z.enum(["response.completed", "response.incomplete"]),
2834
+ response: import_v413.z.object({
2835
+ incomplete_details: import_v413.z.object({ reason: import_v413.z.string() }).nullish(),
2965
2836
  usage: usageSchema2
2966
2837
  })
2967
2838
  });
2968
- var responseCreatedChunkSchema = import_v414.z.object({
2969
- type: import_v414.z.literal("response.created"),
2970
- response: import_v414.z.object({
2971
- id: import_v414.z.string(),
2972
- created_at: import_v414.z.number(),
2973
- model: import_v414.z.string()
2839
+ var responseCreatedChunkSchema = import_v413.z.object({
2840
+ type: import_v413.z.literal("response.created"),
2841
+ response: import_v413.z.object({
2842
+ id: import_v413.z.string(),
2843
+ created_at: import_v413.z.number(),
2844
+ model: import_v413.z.string()
2974
2845
  })
2975
2846
  });
2976
- var responseOutputItemAddedSchema = import_v414.z.object({
2977
- type: import_v414.z.literal("response.output_item.added"),
2978
- output_index: import_v414.z.number(),
2979
- item: import_v414.z.discriminatedUnion("type", [
2980
- import_v414.z.object({
2981
- type: import_v414.z.literal("message"),
2982
- id: import_v414.z.string()
2847
+ var responseOutputItemAddedSchema = import_v413.z.object({
2848
+ type: import_v413.z.literal("response.output_item.added"),
2849
+ output_index: import_v413.z.number(),
2850
+ item: import_v413.z.discriminatedUnion("type", [
2851
+ import_v413.z.object({
2852
+ type: import_v413.z.literal("message"),
2853
+ id: import_v413.z.string()
2983
2854
  }),
2984
- import_v414.z.object({
2985
- type: import_v414.z.literal("reasoning"),
2986
- id: import_v414.z.string(),
2987
- encrypted_content: import_v414.z.string().nullish()
2855
+ import_v413.z.object({
2856
+ type: import_v413.z.literal("reasoning"),
2857
+ id: import_v413.z.string(),
2858
+ encrypted_content: import_v413.z.string().nullish()
2988
2859
  }),
2989
- import_v414.z.object({
2990
- type: import_v414.z.literal("function_call"),
2991
- id: import_v414.z.string(),
2992
- call_id: import_v414.z.string(),
2993
- name: import_v414.z.string(),
2994
- arguments: import_v414.z.string()
2860
+ import_v413.z.object({
2861
+ type: import_v413.z.literal("function_call"),
2862
+ id: import_v413.z.string(),
2863
+ call_id: import_v413.z.string(),
2864
+ name: import_v413.z.string(),
2865
+ arguments: import_v413.z.string()
2995
2866
  }),
2996
- import_v414.z.object({
2997
- type: import_v414.z.literal("web_search_call"),
2998
- id: import_v414.z.string(),
2999
- status: import_v414.z.string()
2867
+ import_v413.z.object({
2868
+ type: import_v413.z.literal("web_search_call"),
2869
+ id: import_v413.z.string(),
2870
+ status: import_v413.z.string()
3000
2871
  }),
3001
- import_v414.z.object({
3002
- type: import_v414.z.literal("computer_call"),
3003
- id: import_v414.z.string(),
3004
- status: import_v414.z.string()
2872
+ import_v413.z.object({
2873
+ type: import_v413.z.literal("computer_call"),
2874
+ id: import_v413.z.string(),
2875
+ status: import_v413.z.string()
3005
2876
  }),
3006
- import_v414.z.object({
3007
- type: import_v414.z.literal("file_search_call"),
3008
- id: import_v414.z.string(),
3009
- status: import_v414.z.string()
2877
+ import_v413.z.object({
2878
+ type: import_v413.z.literal("file_search_call"),
2879
+ id: import_v413.z.string(),
2880
+ status: import_v413.z.string()
3010
2881
  })
3011
2882
  ])
3012
2883
  });
3013
- var responseOutputItemDoneSchema = import_v414.z.object({
3014
- type: import_v414.z.literal("response.output_item.done"),
3015
- output_index: import_v414.z.number(),
3016
- item: import_v414.z.discriminatedUnion("type", [
3017
- import_v414.z.object({
3018
- type: import_v414.z.literal("message"),
3019
- id: import_v414.z.string()
2884
+ var responseOutputItemDoneSchema = import_v413.z.object({
2885
+ type: import_v413.z.literal("response.output_item.done"),
2886
+ output_index: import_v413.z.number(),
2887
+ item: import_v413.z.discriminatedUnion("type", [
2888
+ import_v413.z.object({
2889
+ type: import_v413.z.literal("message"),
2890
+ id: import_v413.z.string()
3020
2891
  }),
3021
- import_v414.z.object({
3022
- type: import_v414.z.literal("reasoning"),
3023
- id: import_v414.z.string(),
3024
- encrypted_content: import_v414.z.string().nullish()
2892
+ import_v413.z.object({
2893
+ type: import_v413.z.literal("reasoning"),
2894
+ id: import_v413.z.string(),
2895
+ encrypted_content: import_v413.z.string().nullish()
3025
2896
  }),
3026
- import_v414.z.object({
3027
- type: import_v414.z.literal("function_call"),
3028
- id: import_v414.z.string(),
3029
- call_id: import_v414.z.string(),
3030
- name: import_v414.z.string(),
3031
- arguments: import_v414.z.string(),
3032
- status: import_v414.z.literal("completed")
2897
+ import_v413.z.object({
2898
+ type: import_v413.z.literal("function_call"),
2899
+ id: import_v413.z.string(),
2900
+ call_id: import_v413.z.string(),
2901
+ name: import_v413.z.string(),
2902
+ arguments: import_v413.z.string(),
2903
+ status: import_v413.z.literal("completed")
3033
2904
  }),
3034
- import_v414.z.object({
3035
- type: import_v414.z.literal("web_search_call"),
3036
- id: import_v414.z.string(),
3037
- status: import_v414.z.literal("completed")
2905
+ import_v413.z.object({
2906
+ type: import_v413.z.literal("web_search_call"),
2907
+ id: import_v413.z.string(),
2908
+ status: import_v413.z.literal("completed")
3038
2909
  }),
3039
- import_v414.z.object({
3040
- type: import_v414.z.literal("computer_call"),
3041
- id: import_v414.z.string(),
3042
- status: import_v414.z.literal("completed")
2910
+ import_v413.z.object({
2911
+ type: import_v413.z.literal("computer_call"),
2912
+ id: import_v413.z.string(),
2913
+ status: import_v413.z.literal("completed")
3043
2914
  }),
3044
- import_v414.z.object({
3045
- type: import_v414.z.literal("file_search_call"),
3046
- id: import_v414.z.string(),
3047
- status: import_v414.z.literal("completed")
2915
+ import_v413.z.object({
2916
+ type: import_v413.z.literal("file_search_call"),
2917
+ id: import_v413.z.string(),
2918
+ status: import_v413.z.literal("completed")
3048
2919
  })
3049
2920
  ])
3050
2921
  });
3051
- var responseFunctionCallArgumentsDeltaSchema = import_v414.z.object({
3052
- type: import_v414.z.literal("response.function_call_arguments.delta"),
3053
- item_id: import_v414.z.string(),
3054
- output_index: import_v414.z.number(),
3055
- delta: import_v414.z.string()
2922
+ var responseFunctionCallArgumentsDeltaSchema = import_v413.z.object({
2923
+ type: import_v413.z.literal("response.function_call_arguments.delta"),
2924
+ item_id: import_v413.z.string(),
2925
+ output_index: import_v413.z.number(),
2926
+ delta: import_v413.z.string()
3056
2927
  });
3057
- var responseAnnotationAddedSchema = import_v414.z.object({
3058
- type: import_v414.z.literal("response.output_text.annotation.added"),
3059
- annotation: import_v414.z.object({
3060
- type: import_v414.z.literal("url_citation"),
3061
- url: import_v414.z.string(),
3062
- title: import_v414.z.string()
2928
+ var responseAnnotationAddedSchema = import_v413.z.object({
2929
+ type: import_v413.z.literal("response.output_text.annotation.added"),
2930
+ annotation: import_v413.z.object({
2931
+ type: import_v413.z.literal("url_citation"),
2932
+ url: import_v413.z.string(),
2933
+ title: import_v413.z.string()
3063
2934
  })
3064
2935
  });
3065
- var responseReasoningSummaryPartAddedSchema = import_v414.z.object({
3066
- type: import_v414.z.literal("response.reasoning_summary_part.added"),
3067
- item_id: import_v414.z.string(),
3068
- summary_index: import_v414.z.number()
2936
+ var responseReasoningSummaryPartAddedSchema = import_v413.z.object({
2937
+ type: import_v413.z.literal("response.reasoning_summary_part.added"),
2938
+ item_id: import_v413.z.string(),
2939
+ summary_index: import_v413.z.number()
3069
2940
  });
3070
- var responseReasoningSummaryTextDeltaSchema = import_v414.z.object({
3071
- type: import_v414.z.literal("response.reasoning_summary_text.delta"),
3072
- item_id: import_v414.z.string(),
3073
- summary_index: import_v414.z.number(),
3074
- delta: import_v414.z.string()
2941
+ var responseReasoningSummaryTextDeltaSchema = import_v413.z.object({
2942
+ type: import_v413.z.literal("response.reasoning_summary_text.delta"),
2943
+ item_id: import_v413.z.string(),
2944
+ summary_index: import_v413.z.number(),
2945
+ delta: import_v413.z.string()
3075
2946
  });
3076
- var openaiResponsesChunkSchema = import_v414.z.union([
2947
+ var openaiResponsesChunkSchema = import_v413.z.union([
3077
2948
  textDeltaChunkSchema,
3078
2949
  responseFinishedChunkSchema,
3079
2950
  responseCreatedChunkSchema,
@@ -3084,7 +2955,7 @@ var openaiResponsesChunkSchema = import_v414.z.union([
3084
2955
  responseReasoningSummaryPartAddedSchema,
3085
2956
  responseReasoningSummaryTextDeltaSchema,
3086
2957
  errorChunkSchema,
3087
- import_v414.z.object({ type: import_v414.z.string() }).loose()
2958
+ import_v413.z.object({ type: import_v413.z.string() }).loose()
3088
2959
  // fallback for unknown chunks
3089
2960
  ]);
3090
2961
  function isTextDeltaChunk(chunk) {
@@ -3150,27 +3021,27 @@ function supportsFlexProcessing2(modelId) {
3150
3021
  function supportsPriorityProcessing2(modelId) {
3151
3022
  return modelId.startsWith("gpt-4") || modelId.startsWith("gpt-5-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-nano") || modelId.startsWith("o3") || modelId.startsWith("o4-mini");
3152
3023
  }
3153
- var openaiResponsesProviderOptionsSchema = import_v414.z.object({
3154
- metadata: import_v414.z.any().nullish(),
3155
- parallelToolCalls: import_v414.z.boolean().nullish(),
3156
- previousResponseId: import_v414.z.string().nullish(),
3157
- store: import_v414.z.boolean().nullish(),
3158
- user: import_v414.z.string().nullish(),
3159
- reasoningEffort: import_v414.z.string().nullish(),
3160
- strictJsonSchema: import_v414.z.boolean().nullish(),
3161
- instructions: import_v414.z.string().nullish(),
3162
- reasoningSummary: import_v414.z.string().nullish(),
3163
- serviceTier: import_v414.z.enum(["auto", "flex", "priority"]).nullish(),
3164
- include: import_v414.z.array(import_v414.z.enum(["reasoning.encrypted_content", "file_search_call.results"])).nullish(),
3165
- textVerbosity: import_v414.z.enum(["low", "medium", "high"]).nullish()
3024
+ var openaiResponsesProviderOptionsSchema = import_v413.z.object({
3025
+ metadata: import_v413.z.any().nullish(),
3026
+ parallelToolCalls: import_v413.z.boolean().nullish(),
3027
+ previousResponseId: import_v413.z.string().nullish(),
3028
+ store: import_v413.z.boolean().nullish(),
3029
+ user: import_v413.z.string().nullish(),
3030
+ reasoningEffort: import_v413.z.string().nullish(),
3031
+ strictJsonSchema: import_v413.z.boolean().nullish(),
3032
+ instructions: import_v413.z.string().nullish(),
3033
+ reasoningSummary: import_v413.z.string().nullish(),
3034
+ serviceTier: import_v413.z.enum(["auto", "flex", "priority"]).nullish(),
3035
+ include: import_v413.z.array(import_v413.z.enum(["reasoning.encrypted_content", "file_search_call.results"])).nullish(),
3036
+ textVerbosity: import_v413.z.enum(["low", "medium", "high"]).nullish()
3166
3037
  });
3167
3038
 
3168
- // src/openai-speech-model.ts
3039
+ // src/speech/openai-speech-model.ts
3169
3040
  var import_provider_utils13 = require("@ai-sdk/provider-utils");
3170
- var import_v415 = require("zod/v4");
3171
- var OpenAIProviderOptionsSchema = import_v415.z.object({
3172
- instructions: import_v415.z.string().nullish(),
3173
- speed: import_v415.z.number().min(0.25).max(4).default(1).nullish()
3041
+ var import_v414 = require("zod/v4");
3042
+ var OpenAIProviderOptionsSchema = import_v414.z.object({
3043
+ instructions: import_v414.z.string().nullish(),
3044
+ speed: import_v414.z.number().min(0.25).max(4).default(1).nullish()
3174
3045
  });
3175
3046
  var OpenAISpeechModel = class {
3176
3047
  constructor(modelId, config) {
@@ -3272,13 +3143,202 @@ var OpenAISpeechModel = class {
3272
3143
  }
3273
3144
  };
3274
3145
 
3146
+ // src/transcription/openai-transcription-model.ts
3147
+ var import_provider_utils14 = require("@ai-sdk/provider-utils");
3148
+ var import_v416 = require("zod/v4");
3149
+
3150
+ // src/transcription/openai-transcription-options.ts
3151
+ var import_v415 = require("zod/v4");
3152
+ var openAITranscriptionProviderOptions = import_v415.z.object({
3153
+ /**
3154
+ * Additional information to include in the transcription response.
3155
+ */
3156
+ include: import_v415.z.array(import_v415.z.string()).optional(),
3157
+ /**
3158
+ * The language of the input audio in ISO-639-1 format.
3159
+ */
3160
+ language: import_v415.z.string().optional(),
3161
+ /**
3162
+ * An optional text to guide the model's style or continue a previous audio segment.
3163
+ */
3164
+ prompt: import_v415.z.string().optional(),
3165
+ /**
3166
+ * The sampling temperature, between 0 and 1.
3167
+ * @default 0
3168
+ */
3169
+ temperature: import_v415.z.number().min(0).max(1).default(0).optional(),
3170
+ /**
3171
+ * The timestamp granularities to populate for this transcription.
3172
+ * @default ['segment']
3173
+ */
3174
+ timestampGranularities: import_v415.z.array(import_v415.z.enum(["word", "segment"])).default(["segment"]).optional()
3175
+ });
3176
+
3177
+ // src/transcription/openai-transcription-model.ts
3178
+ var languageMap = {
3179
+ afrikaans: "af",
3180
+ arabic: "ar",
3181
+ armenian: "hy",
3182
+ azerbaijani: "az",
3183
+ belarusian: "be",
3184
+ bosnian: "bs",
3185
+ bulgarian: "bg",
3186
+ catalan: "ca",
3187
+ chinese: "zh",
3188
+ croatian: "hr",
3189
+ czech: "cs",
3190
+ danish: "da",
3191
+ dutch: "nl",
3192
+ english: "en",
3193
+ estonian: "et",
3194
+ finnish: "fi",
3195
+ french: "fr",
3196
+ galician: "gl",
3197
+ german: "de",
3198
+ greek: "el",
3199
+ hebrew: "he",
3200
+ hindi: "hi",
3201
+ hungarian: "hu",
3202
+ icelandic: "is",
3203
+ indonesian: "id",
3204
+ italian: "it",
3205
+ japanese: "ja",
3206
+ kannada: "kn",
3207
+ kazakh: "kk",
3208
+ korean: "ko",
3209
+ latvian: "lv",
3210
+ lithuanian: "lt",
3211
+ macedonian: "mk",
3212
+ malay: "ms",
3213
+ marathi: "mr",
3214
+ maori: "mi",
3215
+ nepali: "ne",
3216
+ norwegian: "no",
3217
+ persian: "fa",
3218
+ polish: "pl",
3219
+ portuguese: "pt",
3220
+ romanian: "ro",
3221
+ russian: "ru",
3222
+ serbian: "sr",
3223
+ slovak: "sk",
3224
+ slovenian: "sl",
3225
+ spanish: "es",
3226
+ swahili: "sw",
3227
+ swedish: "sv",
3228
+ tagalog: "tl",
3229
+ tamil: "ta",
3230
+ thai: "th",
3231
+ turkish: "tr",
3232
+ ukrainian: "uk",
3233
+ urdu: "ur",
3234
+ vietnamese: "vi",
3235
+ welsh: "cy"
3236
+ };
3237
+ var OpenAITranscriptionModel = class {
3238
+ constructor(modelId, config) {
3239
+ this.modelId = modelId;
3240
+ this.config = config;
3241
+ this.specificationVersion = "v2";
3242
+ }
3243
+ get provider() {
3244
+ return this.config.provider;
3245
+ }
3246
+ async getArgs({
3247
+ audio,
3248
+ mediaType,
3249
+ providerOptions
3250
+ }) {
3251
+ const warnings = [];
3252
+ const openAIOptions = await (0, import_provider_utils14.parseProviderOptions)({
3253
+ provider: "openai",
3254
+ providerOptions,
3255
+ schema: openAITranscriptionProviderOptions
3256
+ });
3257
+ const formData = new FormData();
3258
+ const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([(0, import_provider_utils14.convertBase64ToUint8Array)(audio)]);
3259
+ formData.append("model", this.modelId);
3260
+ formData.append("file", new File([blob], "audio", { type: mediaType }));
3261
+ if (openAIOptions) {
3262
+ const transcriptionModelOptions = {
3263
+ include: openAIOptions.include,
3264
+ language: openAIOptions.language,
3265
+ prompt: openAIOptions.prompt,
3266
+ temperature: openAIOptions.temperature,
3267
+ timestamp_granularities: openAIOptions.timestampGranularities
3268
+ };
3269
+ for (const [key, value] of Object.entries(transcriptionModelOptions)) {
3270
+ if (value != null) {
3271
+ formData.append(key, String(value));
3272
+ }
3273
+ }
3274
+ }
3275
+ return {
3276
+ formData,
3277
+ warnings
3278
+ };
3279
+ }
3280
+ async doGenerate(options) {
3281
+ var _a, _b, _c, _d, _e, _f;
3282
+ const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
3283
+ const { formData, warnings } = await this.getArgs(options);
3284
+ const {
3285
+ value: response,
3286
+ responseHeaders,
3287
+ rawValue: rawResponse
3288
+ } = await (0, import_provider_utils14.postFormDataToApi)({
3289
+ url: this.config.url({
3290
+ path: "/audio/transcriptions",
3291
+ modelId: this.modelId
3292
+ }),
3293
+ headers: (0, import_provider_utils14.combineHeaders)(this.config.headers(), options.headers),
3294
+ formData,
3295
+ failedResponseHandler: openaiFailedResponseHandler,
3296
+ successfulResponseHandler: (0, import_provider_utils14.createJsonResponseHandler)(
3297
+ openaiTranscriptionResponseSchema
3298
+ ),
3299
+ abortSignal: options.abortSignal,
3300
+ fetch: this.config.fetch
3301
+ });
3302
+ const language = response.language != null && response.language in languageMap ? languageMap[response.language] : void 0;
3303
+ return {
3304
+ text: response.text,
3305
+ segments: (_e = (_d = response.words) == null ? void 0 : _d.map((word) => ({
3306
+ text: word.word,
3307
+ startSecond: word.start,
3308
+ endSecond: word.end
3309
+ }))) != null ? _e : [],
3310
+ language,
3311
+ durationInSeconds: (_f = response.duration) != null ? _f : void 0,
3312
+ warnings,
3313
+ response: {
3314
+ timestamp: currentDate,
3315
+ modelId: this.modelId,
3316
+ headers: responseHeaders,
3317
+ body: rawResponse
3318
+ }
3319
+ };
3320
+ }
3321
+ };
3322
+ var openaiTranscriptionResponseSchema = import_v416.z.object({
3323
+ text: import_v416.z.string(),
3324
+ language: import_v416.z.string().nullish(),
3325
+ duration: import_v416.z.number().nullish(),
3326
+ words: import_v416.z.array(
3327
+ import_v416.z.object({
3328
+ word: import_v416.z.string(),
3329
+ start: import_v416.z.number(),
3330
+ end: import_v416.z.number()
3331
+ })
3332
+ ).nullish()
3333
+ });
3334
+
3275
3335
  // src/openai-provider.ts
3276
3336
  function createOpenAI(options = {}) {
3277
3337
  var _a, _b;
3278
- const baseURL = (_a = (0, import_provider_utils14.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://api.openai.com/v1";
3338
+ const baseURL = (_a = (0, import_provider_utils15.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://api.openai.com/v1";
3279
3339
  const providerName = (_b = options.name) != null ? _b : "openai";
3280
3340
  const getHeaders = () => ({
3281
- Authorization: `Bearer ${(0, import_provider_utils14.loadApiKey)({
3341
+ Authorization: `Bearer ${(0, import_provider_utils15.loadApiKey)({
3282
3342
  apiKey: options.apiKey,
3283
3343
  environmentVariableName: "OPENAI_API_KEY",
3284
3344
  description: "OpenAI"