@ai-sdk/openai 1.3.7 → 1.3.8

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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 1.3.8
4
+
5
+ ### Patch Changes
6
+
7
+ - c21fa6d: feat: add transcription with experimental_transcribe
8
+ - Updated dependencies [c21fa6d]
9
+ - @ai-sdk/provider-utils@2.2.5
10
+ - @ai-sdk/provider@1.1.1
11
+
3
12
  ## 1.3.7
4
13
 
5
14
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { LanguageModelV1, ProviderV1, EmbeddingModelV1, ImageModelV1 } from '@ai-sdk/provider';
1
+ import { LanguageModelV1, ProviderV1, EmbeddingModelV1, ImageModelV1, TranscriptionModelV1 } from '@ai-sdk/provider';
2
2
  import { FetchFunction } from '@ai-sdk/provider-utils';
3
3
  import { z } from 'zod';
4
4
 
@@ -179,6 +179,8 @@ interface OpenAIImageSettings {
179
179
  maxImagesPerCall?: number;
180
180
  }
181
181
 
182
+ type OpenAITranscriptionModelId = 'whisper-1' | 'gpt-4o-mini-transcribe' | 'gpt-4o-transcribe' | (string & {});
183
+
182
184
  type OpenAIResponsesModelId = 'o1' | 'o1-2024-12-17' | 'o1-mini' | 'o1-mini-2024-09-12' | 'o1-preview' | 'o1-preview-2024-09-12' | 'o3-mini' | 'o3-mini-2025-01-31' | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-turbo-preview' | 'gpt-4-0125-preview' | 'gpt-4-1106-preview' | 'gpt-4' | 'gpt-4-0613' | 'gpt-4.5-preview' | 'gpt-4.5-preview-2025-02-27' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'chatgpt-4o-latest' | (string & {});
183
185
 
184
186
  declare const WebSearchPreviewParameters: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
@@ -244,6 +246,10 @@ interface OpenAIProvider extends ProviderV1 {
244
246
  */
245
247
  imageModel(modelId: OpenAIImageModelId, settings?: OpenAIImageSettings): ImageModelV1;
246
248
  /**
249
+ Creates a model for transcription.
250
+ */
251
+ transcription(modelId: OpenAITranscriptionModelId): TranscriptionModelV1;
252
+ /**
247
253
  OpenAI-specific tools.
248
254
  */
249
255
  tools: typeof openaiTools;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { LanguageModelV1, ProviderV1, EmbeddingModelV1, ImageModelV1 } from '@ai-sdk/provider';
1
+ import { LanguageModelV1, ProviderV1, EmbeddingModelV1, ImageModelV1, TranscriptionModelV1 } from '@ai-sdk/provider';
2
2
  import { FetchFunction } from '@ai-sdk/provider-utils';
3
3
  import { z } from 'zod';
4
4
 
@@ -179,6 +179,8 @@ interface OpenAIImageSettings {
179
179
  maxImagesPerCall?: number;
180
180
  }
181
181
 
182
+ type OpenAITranscriptionModelId = 'whisper-1' | 'gpt-4o-mini-transcribe' | 'gpt-4o-transcribe' | (string & {});
183
+
182
184
  type OpenAIResponsesModelId = 'o1' | 'o1-2024-12-17' | 'o1-mini' | 'o1-mini-2024-09-12' | 'o1-preview' | 'o1-preview-2024-09-12' | 'o3-mini' | 'o3-mini-2025-01-31' | 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-mini' | 'gpt-4o-mini-2024-07-18' | 'gpt-4-turbo' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-turbo-preview' | 'gpt-4-0125-preview' | 'gpt-4-1106-preview' | 'gpt-4' | 'gpt-4-0613' | 'gpt-4.5-preview' | 'gpt-4.5-preview-2025-02-27' | 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-1106' | 'chatgpt-4o-latest' | (string & {});
183
185
 
184
186
  declare const WebSearchPreviewParameters: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
@@ -244,6 +246,10 @@ interface OpenAIProvider extends ProviderV1 {
244
246
  */
245
247
  imageModel(modelId: OpenAIImageModelId, settings?: OpenAIImageSettings): ImageModelV1;
246
248
  /**
249
+ Creates a model for transcription.
250
+ */
251
+ transcription(modelId: OpenAITranscriptionModelId): TranscriptionModelV1;
252
+ /**
247
253
  OpenAI-specific tools.
248
254
  */
249
255
  tools: typeof openaiTools;
package/dist/index.js CHANGED
@@ -26,7 +26,7 @@ __export(src_exports, {
26
26
  module.exports = __toCommonJS(src_exports);
27
27
 
28
28
  // src/openai-provider.ts
29
- var import_provider_utils9 = require("@ai-sdk/provider-utils");
29
+ var import_provider_utils10 = require("@ai-sdk/provider-utils");
30
30
 
31
31
  // src/openai-chat-language-model.ts
32
32
  var import_provider3 = require("@ai-sdk/provider");
@@ -1601,13 +1601,192 @@ var openaiImageResponseSchema = import_zod5.z.object({
1601
1601
  data: import_zod5.z.array(import_zod5.z.object({ b64_json: import_zod5.z.string() }))
1602
1602
  });
1603
1603
 
1604
- // src/responses/openai-responses-language-model.ts
1605
- var import_provider_utils8 = require("@ai-sdk/provider-utils");
1604
+ // src/openai-transcription-model.ts
1605
+ var import_provider_utils7 = require("@ai-sdk/provider-utils");
1606
1606
  var import_zod6 = require("zod");
1607
+ var OpenAIProviderOptionsSchema = import_zod6.z.object({
1608
+ include: import_zod6.z.array(import_zod6.z.string()).optional().describe(
1609
+ "Additional information to include in the transcription response."
1610
+ ),
1611
+ language: import_zod6.z.string().optional().describe("The language of the input audio in ISO-639-1 format."),
1612
+ prompt: import_zod6.z.string().optional().describe(
1613
+ "An optional text to guide the model's style or continue a previous audio segment."
1614
+ ),
1615
+ temperature: import_zod6.z.number().min(0).max(1).optional().default(0).describe("The sampling temperature, between 0 and 1."),
1616
+ timestampGranularities: import_zod6.z.array(import_zod6.z.enum(["word", "segment"])).optional().default(["segment"]).describe(
1617
+ "The timestamp granularities to populate for this transcription."
1618
+ )
1619
+ });
1620
+ var languageMap = {
1621
+ afrikaans: "af",
1622
+ arabic: "ar",
1623
+ armenian: "hy",
1624
+ azerbaijani: "az",
1625
+ belarusian: "be",
1626
+ bosnian: "bs",
1627
+ bulgarian: "bg",
1628
+ catalan: "ca",
1629
+ chinese: "zh",
1630
+ croatian: "hr",
1631
+ czech: "cs",
1632
+ danish: "da",
1633
+ dutch: "nl",
1634
+ english: "en",
1635
+ estonian: "et",
1636
+ finnish: "fi",
1637
+ french: "fr",
1638
+ galician: "gl",
1639
+ german: "de",
1640
+ greek: "el",
1641
+ hebrew: "he",
1642
+ hindi: "hi",
1643
+ hungarian: "hu",
1644
+ icelandic: "is",
1645
+ indonesian: "id",
1646
+ italian: "it",
1647
+ japanese: "ja",
1648
+ kannada: "kn",
1649
+ kazakh: "kk",
1650
+ korean: "ko",
1651
+ latvian: "lv",
1652
+ lithuanian: "lt",
1653
+ macedonian: "mk",
1654
+ malay: "ms",
1655
+ marathi: "mr",
1656
+ maori: "mi",
1657
+ nepali: "ne",
1658
+ norwegian: "no",
1659
+ persian: "fa",
1660
+ polish: "pl",
1661
+ portuguese: "pt",
1662
+ romanian: "ro",
1663
+ russian: "ru",
1664
+ serbian: "sr",
1665
+ slovak: "sk",
1666
+ slovenian: "sl",
1667
+ spanish: "es",
1668
+ swahili: "sw",
1669
+ swedish: "sv",
1670
+ tagalog: "tl",
1671
+ tamil: "ta",
1672
+ thai: "th",
1673
+ turkish: "tr",
1674
+ ukrainian: "uk",
1675
+ urdu: "ur",
1676
+ vietnamese: "vi",
1677
+ welsh: "cy"
1678
+ };
1679
+ var OpenAITranscriptionModel = class {
1680
+ constructor(modelId, config) {
1681
+ this.modelId = modelId;
1682
+ this.config = config;
1683
+ this.specificationVersion = "v1";
1684
+ }
1685
+ get provider() {
1686
+ return this.config.provider;
1687
+ }
1688
+ getArgs({
1689
+ audio,
1690
+ mimeType,
1691
+ providerOptions
1692
+ }) {
1693
+ const warnings = [];
1694
+ const openAIOptions = (0, import_provider_utils7.parseProviderOptions)({
1695
+ provider: "openai",
1696
+ providerOptions,
1697
+ schema: OpenAIProviderOptionsSchema
1698
+ });
1699
+ const formData = new FormData();
1700
+ const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([(0, import_provider_utils7.convertBase64ToUint8Array)(audio)]);
1701
+ formData.append("model", this.modelId);
1702
+ formData.append("file", new File([blob], "audio", { type: mimeType }));
1703
+ if (openAIOptions) {
1704
+ const transcriptionModelOptions = {
1705
+ include: openAIOptions.include,
1706
+ language: openAIOptions.language,
1707
+ prompt: openAIOptions.prompt,
1708
+ temperature: openAIOptions.temperature,
1709
+ timestamp_granularities: openAIOptions.timestampGranularities
1710
+ };
1711
+ for (const key in transcriptionModelOptions) {
1712
+ const value = transcriptionModelOptions[key];
1713
+ if (value !== void 0) {
1714
+ formData.append(key, value);
1715
+ }
1716
+ }
1717
+ }
1718
+ return {
1719
+ formData,
1720
+ warnings
1721
+ };
1722
+ }
1723
+ async doGenerate(options) {
1724
+ var _a, _b, _c;
1725
+ const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
1726
+ const { formData, warnings } = this.getArgs(options);
1727
+ const { value: response, responseHeaders } = await (0, import_provider_utils7.postFormDataToApi)({
1728
+ url: this.config.url({
1729
+ path: "/audio/transcriptions",
1730
+ modelId: this.modelId
1731
+ }),
1732
+ headers: (0, import_provider_utils7.combineHeaders)(this.config.headers(), options.headers),
1733
+ formData,
1734
+ failedResponseHandler: openaiFailedResponseHandler,
1735
+ successfulResponseHandler: (0, import_provider_utils7.createJsonResponseHandler)(
1736
+ openaiTranscriptionResponseSchema
1737
+ ),
1738
+ abortSignal: options.abortSignal,
1739
+ fetch: this.config.fetch
1740
+ });
1741
+ let language;
1742
+ if (response.language && response.language in languageMap) {
1743
+ language = languageMap[response.language];
1744
+ }
1745
+ return {
1746
+ text: response.text,
1747
+ segments: response.words.map((word) => ({
1748
+ text: word.word,
1749
+ startSecond: word.start,
1750
+ endSecond: word.end
1751
+ })),
1752
+ language,
1753
+ durationInSeconds: response.duration,
1754
+ warnings,
1755
+ response: {
1756
+ timestamp: currentDate,
1757
+ modelId: this.modelId,
1758
+ headers: responseHeaders,
1759
+ body: response
1760
+ },
1761
+ // When using format `verbose_json` on `whisper-1`, OpenAI includes the things like `task` and enhanced `segments` information.
1762
+ providerMetadata: {
1763
+ openai: {
1764
+ transcript: response
1765
+ }
1766
+ }
1767
+ };
1768
+ }
1769
+ };
1770
+ var openaiTranscriptionResponseSchema = import_zod6.z.object({
1771
+ text: import_zod6.z.string(),
1772
+ language: import_zod6.z.string().optional(),
1773
+ duration: import_zod6.z.number().optional(),
1774
+ words: import_zod6.z.array(
1775
+ import_zod6.z.object({
1776
+ word: import_zod6.z.string(),
1777
+ start: import_zod6.z.number(),
1778
+ end: import_zod6.z.number()
1779
+ })
1780
+ )
1781
+ });
1782
+
1783
+ // src/responses/openai-responses-language-model.ts
1784
+ var import_provider_utils9 = require("@ai-sdk/provider-utils");
1785
+ var import_zod7 = require("zod");
1607
1786
 
1608
1787
  // src/responses/convert-to-openai-responses-messages.ts
1609
1788
  var import_provider7 = require("@ai-sdk/provider");
1610
- var import_provider_utils7 = require("@ai-sdk/provider-utils");
1789
+ var import_provider_utils8 = require("@ai-sdk/provider-utils");
1611
1790
  function convertToOpenAIResponsesMessages({
1612
1791
  prompt,
1613
1792
  systemMessageMode
@@ -1654,7 +1833,7 @@ function convertToOpenAIResponsesMessages({
1654
1833
  case "image": {
1655
1834
  return {
1656
1835
  type: "input_image",
1657
- image_url: part.image instanceof URL ? part.image.toString() : `data:${(_a = part.mimeType) != null ? _a : "image/jpeg"};base64,${(0, import_provider_utils7.convertUint8ArrayToBase64)(part.image)}`,
1836
+ image_url: part.image instanceof URL ? part.image.toString() : `data:${(_a = part.mimeType) != null ? _a : "image/jpeg"};base64,${(0, import_provider_utils8.convertUint8ArrayToBase64)(part.image)}`,
1658
1837
  // OpenAI specific extension: image detail
1659
1838
  detail: (_c = (_b = part.providerMetadata) == null ? void 0 : _b.openai) == null ? void 0 : _c.imageDetail
1660
1839
  };
@@ -1890,7 +2069,7 @@ var OpenAIResponsesLanguageModel = class {
1890
2069
  systemMessageMode: modelConfig.systemMessageMode
1891
2070
  });
1892
2071
  warnings.push(...messageWarnings);
1893
- const openaiOptions = (0, import_provider_utils8.parseProviderOptions)({
2072
+ const openaiOptions = (0, import_provider_utils9.parseProviderOptions)({
1894
2073
  provider: "openai",
1895
2074
  providerOptions: providerMetadata,
1896
2075
  schema: openaiResponsesProviderOptionsSchema
@@ -2010,58 +2189,58 @@ var OpenAIResponsesLanguageModel = class {
2010
2189
  responseHeaders,
2011
2190
  value: response,
2012
2191
  rawValue: rawResponse
2013
- } = await (0, import_provider_utils8.postJsonToApi)({
2192
+ } = await (0, import_provider_utils9.postJsonToApi)({
2014
2193
  url: this.config.url({
2015
2194
  path: "/responses",
2016
2195
  modelId: this.modelId
2017
2196
  }),
2018
- headers: (0, import_provider_utils8.combineHeaders)(this.config.headers(), options.headers),
2197
+ headers: (0, import_provider_utils9.combineHeaders)(this.config.headers(), options.headers),
2019
2198
  body,
2020
2199
  failedResponseHandler: openaiFailedResponseHandler,
2021
- successfulResponseHandler: (0, import_provider_utils8.createJsonResponseHandler)(
2022
- import_zod6.z.object({
2023
- id: import_zod6.z.string(),
2024
- created_at: import_zod6.z.number(),
2025
- model: import_zod6.z.string(),
2026
- output: import_zod6.z.array(
2027
- import_zod6.z.discriminatedUnion("type", [
2028
- import_zod6.z.object({
2029
- type: import_zod6.z.literal("message"),
2030
- role: import_zod6.z.literal("assistant"),
2031
- content: import_zod6.z.array(
2032
- import_zod6.z.object({
2033
- type: import_zod6.z.literal("output_text"),
2034
- text: import_zod6.z.string(),
2035
- annotations: import_zod6.z.array(
2036
- import_zod6.z.object({
2037
- type: import_zod6.z.literal("url_citation"),
2038
- start_index: import_zod6.z.number(),
2039
- end_index: import_zod6.z.number(),
2040
- url: import_zod6.z.string(),
2041
- title: import_zod6.z.string()
2200
+ successfulResponseHandler: (0, import_provider_utils9.createJsonResponseHandler)(
2201
+ import_zod7.z.object({
2202
+ id: import_zod7.z.string(),
2203
+ created_at: import_zod7.z.number(),
2204
+ model: import_zod7.z.string(),
2205
+ output: import_zod7.z.array(
2206
+ import_zod7.z.discriminatedUnion("type", [
2207
+ import_zod7.z.object({
2208
+ type: import_zod7.z.literal("message"),
2209
+ role: import_zod7.z.literal("assistant"),
2210
+ content: import_zod7.z.array(
2211
+ import_zod7.z.object({
2212
+ type: import_zod7.z.literal("output_text"),
2213
+ text: import_zod7.z.string(),
2214
+ annotations: import_zod7.z.array(
2215
+ import_zod7.z.object({
2216
+ type: import_zod7.z.literal("url_citation"),
2217
+ start_index: import_zod7.z.number(),
2218
+ end_index: import_zod7.z.number(),
2219
+ url: import_zod7.z.string(),
2220
+ title: import_zod7.z.string()
2042
2221
  })
2043
2222
  )
2044
2223
  })
2045
2224
  )
2046
2225
  }),
2047
- import_zod6.z.object({
2048
- type: import_zod6.z.literal("function_call"),
2049
- call_id: import_zod6.z.string(),
2050
- name: import_zod6.z.string(),
2051
- arguments: import_zod6.z.string()
2226
+ import_zod7.z.object({
2227
+ type: import_zod7.z.literal("function_call"),
2228
+ call_id: import_zod7.z.string(),
2229
+ name: import_zod7.z.string(),
2230
+ arguments: import_zod7.z.string()
2052
2231
  }),
2053
- import_zod6.z.object({
2054
- type: import_zod6.z.literal("web_search_call")
2232
+ import_zod7.z.object({
2233
+ type: import_zod7.z.literal("web_search_call")
2055
2234
  }),
2056
- import_zod6.z.object({
2057
- type: import_zod6.z.literal("computer_call")
2235
+ import_zod7.z.object({
2236
+ type: import_zod7.z.literal("computer_call")
2058
2237
  }),
2059
- import_zod6.z.object({
2060
- type: import_zod6.z.literal("reasoning")
2238
+ import_zod7.z.object({
2239
+ type: import_zod7.z.literal("reasoning")
2061
2240
  })
2062
2241
  ])
2063
2242
  ),
2064
- incomplete_details: import_zod6.z.object({ reason: import_zod6.z.string() }).nullable(),
2243
+ incomplete_details: import_zod7.z.object({ reason: import_zod7.z.string() }).nullable(),
2065
2244
  usage: usageSchema
2066
2245
  })
2067
2246
  ),
@@ -2082,7 +2261,7 @@ var OpenAIResponsesLanguageModel = class {
2082
2261
  var _a2, _b2, _c2;
2083
2262
  return {
2084
2263
  sourceType: "url",
2085
- id: (_c2 = (_b2 = (_a2 = this.config).generateId) == null ? void 0 : _b2.call(_a2)) != null ? _c2 : (0, import_provider_utils8.generateId)(),
2264
+ id: (_c2 = (_b2 = (_a2 = this.config).generateId) == null ? void 0 : _b2.call(_a2)) != null ? _c2 : (0, import_provider_utils9.generateId)(),
2086
2265
  url: annotation.url,
2087
2266
  title: annotation.title
2088
2267
  };
@@ -2125,18 +2304,18 @@ var OpenAIResponsesLanguageModel = class {
2125
2304
  }
2126
2305
  async doStream(options) {
2127
2306
  const { args: body, warnings } = this.getArgs(options);
2128
- const { responseHeaders, value: response } = await (0, import_provider_utils8.postJsonToApi)({
2307
+ const { responseHeaders, value: response } = await (0, import_provider_utils9.postJsonToApi)({
2129
2308
  url: this.config.url({
2130
2309
  path: "/responses",
2131
2310
  modelId: this.modelId
2132
2311
  }),
2133
- headers: (0, import_provider_utils8.combineHeaders)(this.config.headers(), options.headers),
2312
+ headers: (0, import_provider_utils9.combineHeaders)(this.config.headers(), options.headers),
2134
2313
  body: {
2135
2314
  ...body,
2136
2315
  stream: true
2137
2316
  },
2138
2317
  failedResponseHandler: openaiFailedResponseHandler,
2139
- successfulResponseHandler: (0, import_provider_utils8.createEventSourceResponseHandler)(
2318
+ successfulResponseHandler: (0, import_provider_utils9.createEventSourceResponseHandler)(
2140
2319
  openaiResponsesChunkSchema
2141
2320
  ),
2142
2321
  abortSignal: options.abortSignal,
@@ -2224,7 +2403,7 @@ var OpenAIResponsesLanguageModel = class {
2224
2403
  type: "source",
2225
2404
  source: {
2226
2405
  sourceType: "url",
2227
- id: (_h = (_g = (_f = self.config).generateId) == null ? void 0 : _g.call(_f)) != null ? _h : (0, import_provider_utils8.generateId)(),
2406
+ id: (_h = (_g = (_f = self.config).generateId) == null ? void 0 : _g.call(_f)) != null ? _h : (0, import_provider_utils9.generateId)(),
2228
2407
  url: value.annotation.url,
2229
2408
  title: value.annotation.title
2230
2409
  }
@@ -2259,79 +2438,79 @@ var OpenAIResponsesLanguageModel = class {
2259
2438
  };
2260
2439
  }
2261
2440
  };
2262
- var usageSchema = import_zod6.z.object({
2263
- input_tokens: import_zod6.z.number(),
2264
- input_tokens_details: import_zod6.z.object({ cached_tokens: import_zod6.z.number().nullish() }).nullish(),
2265
- output_tokens: import_zod6.z.number(),
2266
- output_tokens_details: import_zod6.z.object({ reasoning_tokens: import_zod6.z.number().nullish() }).nullish()
2441
+ var usageSchema = import_zod7.z.object({
2442
+ input_tokens: import_zod7.z.number(),
2443
+ input_tokens_details: import_zod7.z.object({ cached_tokens: import_zod7.z.number().nullish() }).nullish(),
2444
+ output_tokens: import_zod7.z.number(),
2445
+ output_tokens_details: import_zod7.z.object({ reasoning_tokens: import_zod7.z.number().nullish() }).nullish()
2267
2446
  });
2268
- var textDeltaChunkSchema = import_zod6.z.object({
2269
- type: import_zod6.z.literal("response.output_text.delta"),
2270
- delta: import_zod6.z.string()
2447
+ var textDeltaChunkSchema = import_zod7.z.object({
2448
+ type: import_zod7.z.literal("response.output_text.delta"),
2449
+ delta: import_zod7.z.string()
2271
2450
  });
2272
- var responseFinishedChunkSchema = import_zod6.z.object({
2273
- type: import_zod6.z.enum(["response.completed", "response.incomplete"]),
2274
- response: import_zod6.z.object({
2275
- incomplete_details: import_zod6.z.object({ reason: import_zod6.z.string() }).nullish(),
2451
+ var responseFinishedChunkSchema = import_zod7.z.object({
2452
+ type: import_zod7.z.enum(["response.completed", "response.incomplete"]),
2453
+ response: import_zod7.z.object({
2454
+ incomplete_details: import_zod7.z.object({ reason: import_zod7.z.string() }).nullish(),
2276
2455
  usage: usageSchema
2277
2456
  })
2278
2457
  });
2279
- var responseCreatedChunkSchema = import_zod6.z.object({
2280
- type: import_zod6.z.literal("response.created"),
2281
- response: import_zod6.z.object({
2282
- id: import_zod6.z.string(),
2283
- created_at: import_zod6.z.number(),
2284
- model: import_zod6.z.string()
2458
+ var responseCreatedChunkSchema = import_zod7.z.object({
2459
+ type: import_zod7.z.literal("response.created"),
2460
+ response: import_zod7.z.object({
2461
+ id: import_zod7.z.string(),
2462
+ created_at: import_zod7.z.number(),
2463
+ model: import_zod7.z.string()
2285
2464
  })
2286
2465
  });
2287
- var responseOutputItemDoneSchema = import_zod6.z.object({
2288
- type: import_zod6.z.literal("response.output_item.done"),
2289
- output_index: import_zod6.z.number(),
2290
- item: import_zod6.z.discriminatedUnion("type", [
2291
- import_zod6.z.object({
2292
- type: import_zod6.z.literal("message")
2466
+ var responseOutputItemDoneSchema = import_zod7.z.object({
2467
+ type: import_zod7.z.literal("response.output_item.done"),
2468
+ output_index: import_zod7.z.number(),
2469
+ item: import_zod7.z.discriminatedUnion("type", [
2470
+ import_zod7.z.object({
2471
+ type: import_zod7.z.literal("message")
2293
2472
  }),
2294
- import_zod6.z.object({
2295
- type: import_zod6.z.literal("function_call"),
2296
- id: import_zod6.z.string(),
2297
- call_id: import_zod6.z.string(),
2298
- name: import_zod6.z.string(),
2299
- arguments: import_zod6.z.string(),
2300
- status: import_zod6.z.literal("completed")
2473
+ import_zod7.z.object({
2474
+ type: import_zod7.z.literal("function_call"),
2475
+ id: import_zod7.z.string(),
2476
+ call_id: import_zod7.z.string(),
2477
+ name: import_zod7.z.string(),
2478
+ arguments: import_zod7.z.string(),
2479
+ status: import_zod7.z.literal("completed")
2301
2480
  })
2302
2481
  ])
2303
2482
  });
2304
- var responseFunctionCallArgumentsDeltaSchema = import_zod6.z.object({
2305
- type: import_zod6.z.literal("response.function_call_arguments.delta"),
2306
- item_id: import_zod6.z.string(),
2307
- output_index: import_zod6.z.number(),
2308
- delta: import_zod6.z.string()
2483
+ var responseFunctionCallArgumentsDeltaSchema = import_zod7.z.object({
2484
+ type: import_zod7.z.literal("response.function_call_arguments.delta"),
2485
+ item_id: import_zod7.z.string(),
2486
+ output_index: import_zod7.z.number(),
2487
+ delta: import_zod7.z.string()
2309
2488
  });
2310
- var responseOutputItemAddedSchema = import_zod6.z.object({
2311
- type: import_zod6.z.literal("response.output_item.added"),
2312
- output_index: import_zod6.z.number(),
2313
- item: import_zod6.z.discriminatedUnion("type", [
2314
- import_zod6.z.object({
2315
- type: import_zod6.z.literal("message")
2489
+ var responseOutputItemAddedSchema = import_zod7.z.object({
2490
+ type: import_zod7.z.literal("response.output_item.added"),
2491
+ output_index: import_zod7.z.number(),
2492
+ item: import_zod7.z.discriminatedUnion("type", [
2493
+ import_zod7.z.object({
2494
+ type: import_zod7.z.literal("message")
2316
2495
  }),
2317
- import_zod6.z.object({
2318
- type: import_zod6.z.literal("function_call"),
2319
- id: import_zod6.z.string(),
2320
- call_id: import_zod6.z.string(),
2321
- name: import_zod6.z.string(),
2322
- arguments: import_zod6.z.string()
2496
+ import_zod7.z.object({
2497
+ type: import_zod7.z.literal("function_call"),
2498
+ id: import_zod7.z.string(),
2499
+ call_id: import_zod7.z.string(),
2500
+ name: import_zod7.z.string(),
2501
+ arguments: import_zod7.z.string()
2323
2502
  })
2324
2503
  ])
2325
2504
  });
2326
- var responseAnnotationAddedSchema = import_zod6.z.object({
2327
- type: import_zod6.z.literal("response.output_text.annotation.added"),
2328
- annotation: import_zod6.z.object({
2329
- type: import_zod6.z.literal("url_citation"),
2330
- url: import_zod6.z.string(),
2331
- title: import_zod6.z.string()
2505
+ var responseAnnotationAddedSchema = import_zod7.z.object({
2506
+ type: import_zod7.z.literal("response.output_text.annotation.added"),
2507
+ annotation: import_zod7.z.object({
2508
+ type: import_zod7.z.literal("url_citation"),
2509
+ url: import_zod7.z.string(),
2510
+ title: import_zod7.z.string()
2332
2511
  })
2333
2512
  });
2334
- var openaiResponsesChunkSchema = import_zod6.z.union([
2513
+ var openaiResponsesChunkSchema = import_zod7.z.union([
2335
2514
  textDeltaChunkSchema,
2336
2515
  responseFinishedChunkSchema,
2337
2516
  responseCreatedChunkSchema,
@@ -2339,7 +2518,7 @@ var openaiResponsesChunkSchema = import_zod6.z.union([
2339
2518
  responseFunctionCallArgumentsDeltaSchema,
2340
2519
  responseOutputItemAddedSchema,
2341
2520
  responseAnnotationAddedSchema,
2342
- import_zod6.z.object({ type: import_zod6.z.string() }).passthrough()
2521
+ import_zod7.z.object({ type: import_zod7.z.string() }).passthrough()
2343
2522
  // fallback for unknown chunks
2344
2523
  ]);
2345
2524
  function isTextDeltaChunk(chunk) {
@@ -2384,20 +2563,20 @@ function getResponsesModelConfig(modelId) {
2384
2563
  requiredAutoTruncation: false
2385
2564
  };
2386
2565
  }
2387
- var openaiResponsesProviderOptionsSchema = import_zod6.z.object({
2388
- metadata: import_zod6.z.any().nullish(),
2389
- parallelToolCalls: import_zod6.z.boolean().nullish(),
2390
- previousResponseId: import_zod6.z.string().nullish(),
2391
- store: import_zod6.z.boolean().nullish(),
2392
- user: import_zod6.z.string().nullish(),
2393
- reasoningEffort: import_zod6.z.string().nullish(),
2394
- strictSchemas: import_zod6.z.boolean().nullish(),
2395
- instructions: import_zod6.z.string().nullish()
2566
+ var openaiResponsesProviderOptionsSchema = import_zod7.z.object({
2567
+ metadata: import_zod7.z.any().nullish(),
2568
+ parallelToolCalls: import_zod7.z.boolean().nullish(),
2569
+ previousResponseId: import_zod7.z.string().nullish(),
2570
+ store: import_zod7.z.boolean().nullish(),
2571
+ user: import_zod7.z.string().nullish(),
2572
+ reasoningEffort: import_zod7.z.string().nullish(),
2573
+ strictSchemas: import_zod7.z.boolean().nullish(),
2574
+ instructions: import_zod7.z.string().nullish()
2396
2575
  });
2397
2576
 
2398
2577
  // src/openai-tools.ts
2399
- var import_zod7 = require("zod");
2400
- var WebSearchPreviewParameters = import_zod7.z.object({});
2578
+ var import_zod8 = require("zod");
2579
+ var WebSearchPreviewParameters = import_zod8.z.object({});
2401
2580
  function webSearchPreviewTool({
2402
2581
  searchContextSize,
2403
2582
  userLocation
@@ -2419,11 +2598,11 @@ var openaiTools = {
2419
2598
  // src/openai-provider.ts
2420
2599
  function createOpenAI(options = {}) {
2421
2600
  var _a, _b, _c;
2422
- const baseURL = (_a = (0, import_provider_utils9.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://api.openai.com/v1";
2601
+ const baseURL = (_a = (0, import_provider_utils10.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://api.openai.com/v1";
2423
2602
  const compatibility = (_b = options.compatibility) != null ? _b : "compatible";
2424
2603
  const providerName = (_c = options.name) != null ? _c : "openai";
2425
2604
  const getHeaders = () => ({
2426
- Authorization: `Bearer ${(0, import_provider_utils9.loadApiKey)({
2605
+ Authorization: `Bearer ${(0, import_provider_utils10.loadApiKey)({
2427
2606
  apiKey: options.apiKey,
2428
2607
  environmentVariableName: "OPENAI_API_KEY",
2429
2608
  description: "OpenAI"
@@ -2458,6 +2637,12 @@ function createOpenAI(options = {}) {
2458
2637
  headers: getHeaders,
2459
2638
  fetch: options.fetch
2460
2639
  });
2640
+ const createTranscriptionModel = (modelId) => new OpenAITranscriptionModel(modelId, {
2641
+ provider: `${providerName}.transcription`,
2642
+ url: ({ path }) => `${baseURL}${path}`,
2643
+ headers: getHeaders,
2644
+ fetch: options.fetch
2645
+ });
2461
2646
  const createLanguageModel = (modelId, settings) => {
2462
2647
  if (new.target) {
2463
2648
  throw new Error(
@@ -2492,6 +2677,8 @@ function createOpenAI(options = {}) {
2492
2677
  provider.textEmbeddingModel = createEmbeddingModel;
2493
2678
  provider.image = createImageModel;
2494
2679
  provider.imageModel = createImageModel;
2680
+ provider.transcription = createTranscriptionModel;
2681
+ provider.transcriptionModel = createTranscriptionModel;
2495
2682
  provider.tools = openaiTools;
2496
2683
  return provider;
2497
2684
  }