@ai-sdk/openai 2.0.0-canary.2 → 2.0.0-canary.3

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
@@ -23,7 +23,6 @@ import { z as z2 } from "zod";
23
23
  import {
24
24
  UnsupportedFunctionalityError
25
25
  } from "@ai-sdk/provider";
26
- import { convertUint8ArrayToBase64 } from "@ai-sdk/provider-utils";
27
26
  function convertToOpenAIChatMessages({
28
27
  prompt,
29
28
  useLegacyFunctionCalling = false,
@@ -67,55 +66,65 @@ function convertToOpenAIChatMessages({
67
66
  messages.push({
68
67
  role: "user",
69
68
  content: content.map((part, index) => {
70
- var _a, _b, _c, _d;
69
+ var _a, _b, _c;
71
70
  switch (part.type) {
72
71
  case "text": {
73
72
  return { type: "text", text: part.text };
74
73
  }
75
- case "image": {
76
- return {
77
- type: "image_url",
78
- image_url: {
79
- url: part.image instanceof URL ? part.image.toString() : `data:${(_a = part.mimeType) != null ? _a : "image/jpeg"};base64,${convertUint8ArrayToBase64(part.image)}`,
80
- // OpenAI specific extension: image detail
81
- detail: (_c = (_b = part.providerOptions) == null ? void 0 : _b.openai) == null ? void 0 : _c.imageDetail
82
- }
83
- };
84
- }
85
74
  case "file": {
86
- if (part.data instanceof URL) {
87
- throw new UnsupportedFunctionalityError({
88
- functionality: "'File content parts with URL data' functionality not supported."
89
- });
90
- }
91
- switch (part.mimeType) {
92
- case "audio/wav": {
93
- return {
94
- type: "input_audio",
95
- input_audio: { data: part.data, format: "wav" }
96
- };
97
- }
98
- case "audio/mp3":
99
- case "audio/mpeg": {
100
- return {
101
- type: "input_audio",
102
- input_audio: { data: part.data, format: "mp3" }
103
- };
75
+ if (part.mediaType.startsWith("image/")) {
76
+ const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
77
+ return {
78
+ type: "image_url",
79
+ image_url: {
80
+ url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${part.data}`,
81
+ // OpenAI specific extension: image detail
82
+ detail: (_b = (_a = part.providerOptions) == null ? void 0 : _a.openai) == null ? void 0 : _b.imageDetail
83
+ }
84
+ };
85
+ } else if (part.mediaType.startsWith("audio/")) {
86
+ if (part.data instanceof URL) {
87
+ throw new UnsupportedFunctionalityError({
88
+ functionality: "audio file parts with URLs"
89
+ });
104
90
  }
105
- case "application/pdf": {
106
- return {
107
- type: "file",
108
- file: {
109
- filename: (_d = part.filename) != null ? _d : `part-${index}.pdf`,
110
- file_data: `data:application/pdf;base64,${part.data}`
111
- }
112
- };
91
+ switch (part.mediaType) {
92
+ case "audio/wav": {
93
+ return {
94
+ type: "input_audio",
95
+ input_audio: { data: part.data, format: "wav" }
96
+ };
97
+ }
98
+ case "audio/mp3":
99
+ case "audio/mpeg": {
100
+ return {
101
+ type: "input_audio",
102
+ input_audio: { data: part.data, format: "mp3" }
103
+ };
104
+ }
105
+ default: {
106
+ throw new UnsupportedFunctionalityError({
107
+ functionality: `audio content parts with media type ${part.mediaType}`
108
+ });
109
+ }
113
110
  }
114
- default: {
111
+ } else if (part.mediaType === "application/pdf") {
112
+ if (part.data instanceof URL) {
115
113
  throw new UnsupportedFunctionalityError({
116
- functionality: `File content part type ${part.mimeType} in user messages`
114
+ functionality: "PDF file parts with URLs"
117
115
  });
118
116
  }
117
+ return {
118
+ type: "file",
119
+ file: {
120
+ filename: (_c = part.filename) != null ? _c : `part-${index}.pdf`,
121
+ file_data: `data:application/pdf;base64,${part.data}`
122
+ }
123
+ };
124
+ } else {
125
+ throw new UnsupportedFunctionalityError({
126
+ functionality: `file part media type ${part.mediaType}`
127
+ });
119
128
  }
120
129
  }
121
130
  }
@@ -350,7 +359,7 @@ function prepareTools({
350
359
  default: {
351
360
  const _exhaustiveCheck = type;
352
361
  throw new UnsupportedFunctionalityError2({
353
- functionality: `Unsupported tool choice type: ${_exhaustiveCheck}`
362
+ functionality: `tool choice type: ${_exhaustiveCheck}`
354
363
  });
355
364
  }
356
365
  }
@@ -1058,13 +1067,8 @@ function convertToOpenAICompletionPrompt({
1058
1067
  case "text": {
1059
1068
  return part.text;
1060
1069
  }
1061
- case "image": {
1062
- throw new UnsupportedFunctionalityError4({
1063
- functionality: "images"
1064
- });
1065
- }
1066
1070
  }
1067
- }).join("");
1071
+ }).filter(Boolean).join("");
1068
1072
  text += `${user}:
1069
1073
  ${userMessage}
1070
1074
 
@@ -1552,22 +1556,201 @@ var openaiTools = {
1552
1556
  webSearchPreview: webSearchPreviewTool
1553
1557
  };
1554
1558
 
1555
- // src/responses/openai-responses-language-model.ts
1559
+ // src/openai-transcription-model.ts
1556
1560
  import {
1557
1561
  combineHeaders as combineHeaders5,
1558
- createEventSourceResponseHandler as createEventSourceResponseHandler3,
1562
+ convertBase64ToUint8Array,
1559
1563
  createJsonResponseHandler as createJsonResponseHandler5,
1560
- generateId as generateId2,
1561
1564
  parseProviderOptions,
1562
- postJsonToApi as postJsonToApi5
1565
+ postFormDataToApi
1563
1566
  } from "@ai-sdk/provider-utils";
1564
1567
  import { z as z7 } from "zod";
1568
+ var OpenAIProviderOptionsSchema = z7.object({
1569
+ include: z7.array(z7.string()).optional().describe(
1570
+ "Additional information to include in the transcription response."
1571
+ ),
1572
+ language: z7.string().optional().describe("The language of the input audio in ISO-639-1 format."),
1573
+ prompt: z7.string().optional().describe(
1574
+ "An optional text to guide the model's style or continue a previous audio segment."
1575
+ ),
1576
+ temperature: z7.number().min(0).max(1).optional().default(0).describe("The sampling temperature, between 0 and 1."),
1577
+ timestampGranularities: z7.array(z7.enum(["word", "segment"])).optional().default(["segment"]).describe(
1578
+ "The timestamp granularities to populate for this transcription."
1579
+ )
1580
+ });
1581
+ var languageMap = {
1582
+ afrikaans: "af",
1583
+ arabic: "ar",
1584
+ armenian: "hy",
1585
+ azerbaijani: "az",
1586
+ belarusian: "be",
1587
+ bosnian: "bs",
1588
+ bulgarian: "bg",
1589
+ catalan: "ca",
1590
+ chinese: "zh",
1591
+ croatian: "hr",
1592
+ czech: "cs",
1593
+ danish: "da",
1594
+ dutch: "nl",
1595
+ english: "en",
1596
+ estonian: "et",
1597
+ finnish: "fi",
1598
+ french: "fr",
1599
+ galician: "gl",
1600
+ german: "de",
1601
+ greek: "el",
1602
+ hebrew: "he",
1603
+ hindi: "hi",
1604
+ hungarian: "hu",
1605
+ icelandic: "is",
1606
+ indonesian: "id",
1607
+ italian: "it",
1608
+ japanese: "ja",
1609
+ kannada: "kn",
1610
+ kazakh: "kk",
1611
+ korean: "ko",
1612
+ latvian: "lv",
1613
+ lithuanian: "lt",
1614
+ macedonian: "mk",
1615
+ malay: "ms",
1616
+ marathi: "mr",
1617
+ maori: "mi",
1618
+ nepali: "ne",
1619
+ norwegian: "no",
1620
+ persian: "fa",
1621
+ polish: "pl",
1622
+ portuguese: "pt",
1623
+ romanian: "ro",
1624
+ russian: "ru",
1625
+ serbian: "sr",
1626
+ slovak: "sk",
1627
+ slovenian: "sl",
1628
+ spanish: "es",
1629
+ swahili: "sw",
1630
+ swedish: "sv",
1631
+ tagalog: "tl",
1632
+ tamil: "ta",
1633
+ thai: "th",
1634
+ turkish: "tr",
1635
+ ukrainian: "uk",
1636
+ urdu: "ur",
1637
+ vietnamese: "vi",
1638
+ welsh: "cy"
1639
+ };
1640
+ var OpenAITranscriptionModel = class {
1641
+ constructor(modelId, config) {
1642
+ this.modelId = modelId;
1643
+ this.config = config;
1644
+ this.specificationVersion = "v1";
1645
+ }
1646
+ get provider() {
1647
+ return this.config.provider;
1648
+ }
1649
+ getArgs({
1650
+ audio,
1651
+ mediaType,
1652
+ providerOptions
1653
+ }) {
1654
+ const warnings = [];
1655
+ const openAIOptions = parseProviderOptions({
1656
+ provider: "openai",
1657
+ providerOptions,
1658
+ schema: OpenAIProviderOptionsSchema
1659
+ });
1660
+ const formData = new FormData();
1661
+ const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([convertBase64ToUint8Array(audio)]);
1662
+ formData.append("model", this.modelId);
1663
+ formData.append("file", new File([blob], "audio", { type: mediaType }));
1664
+ if (openAIOptions) {
1665
+ const transcriptionModelOptions = {
1666
+ include: openAIOptions.include,
1667
+ language: openAIOptions.language,
1668
+ prompt: openAIOptions.prompt,
1669
+ temperature: openAIOptions.temperature,
1670
+ timestamp_granularities: openAIOptions.timestampGranularities
1671
+ };
1672
+ for (const key in transcriptionModelOptions) {
1673
+ const value = transcriptionModelOptions[key];
1674
+ if (value !== void 0) {
1675
+ formData.append(key, value);
1676
+ }
1677
+ }
1678
+ }
1679
+ return {
1680
+ formData,
1681
+ warnings
1682
+ };
1683
+ }
1684
+ async doGenerate(options) {
1685
+ var _a, _b, _c, _d, _e, _f;
1686
+ const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
1687
+ const { formData, warnings } = this.getArgs(options);
1688
+ const {
1689
+ value: response,
1690
+ responseHeaders,
1691
+ rawValue: rawResponse
1692
+ } = await postFormDataToApi({
1693
+ url: this.config.url({
1694
+ path: "/audio/transcriptions",
1695
+ modelId: this.modelId
1696
+ }),
1697
+ headers: combineHeaders5(this.config.headers(), options.headers),
1698
+ formData,
1699
+ failedResponseHandler: openaiFailedResponseHandler,
1700
+ successfulResponseHandler: createJsonResponseHandler5(
1701
+ openaiTranscriptionResponseSchema
1702
+ ),
1703
+ abortSignal: options.abortSignal,
1704
+ fetch: this.config.fetch
1705
+ });
1706
+ const language = response.language != null && response.language in languageMap ? languageMap[response.language] : void 0;
1707
+ return {
1708
+ text: response.text,
1709
+ segments: (_e = (_d = response.words) == null ? void 0 : _d.map((word) => ({
1710
+ text: word.word,
1711
+ startSecond: word.start,
1712
+ endSecond: word.end
1713
+ }))) != null ? _e : [],
1714
+ language,
1715
+ durationInSeconds: (_f = response.duration) != null ? _f : void 0,
1716
+ warnings,
1717
+ response: {
1718
+ timestamp: currentDate,
1719
+ modelId: this.modelId,
1720
+ headers: responseHeaders,
1721
+ body: rawResponse
1722
+ }
1723
+ };
1724
+ }
1725
+ };
1726
+ var openaiTranscriptionResponseSchema = z7.object({
1727
+ text: z7.string(),
1728
+ language: z7.string().nullish(),
1729
+ duration: z7.number().nullish(),
1730
+ words: z7.array(
1731
+ z7.object({
1732
+ word: z7.string(),
1733
+ start: z7.number(),
1734
+ end: z7.number()
1735
+ })
1736
+ ).nullish()
1737
+ });
1738
+
1739
+ // src/responses/openai-responses-language-model.ts
1740
+ import {
1741
+ combineHeaders as combineHeaders6,
1742
+ createEventSourceResponseHandler as createEventSourceResponseHandler3,
1743
+ createJsonResponseHandler as createJsonResponseHandler6,
1744
+ generateId as generateId2,
1745
+ parseProviderOptions as parseProviderOptions2,
1746
+ postJsonToApi as postJsonToApi5
1747
+ } from "@ai-sdk/provider-utils";
1748
+ import { z as z8 } from "zod";
1565
1749
 
1566
1750
  // src/responses/convert-to-openai-responses-messages.ts
1567
1751
  import {
1568
1752
  UnsupportedFunctionalityError as UnsupportedFunctionalityError5
1569
1753
  } from "@ai-sdk/provider";
1570
- import { convertUint8ArrayToBase64 as convertUint8ArrayToBase642 } from "@ai-sdk/provider-utils";
1571
1754
  function convertToOpenAIResponsesMessages({
1572
1755
  prompt,
1573
1756
  systemMessageMode
@@ -1606,38 +1789,35 @@ function convertToOpenAIResponsesMessages({
1606
1789
  messages.push({
1607
1790
  role: "user",
1608
1791
  content: content.map((part, index) => {
1609
- var _a, _b, _c, _d;
1792
+ var _a, _b, _c;
1610
1793
  switch (part.type) {
1611
1794
  case "text": {
1612
1795
  return { type: "input_text", text: part.text };
1613
1796
  }
1614
- case "image": {
1615
- return {
1616
- type: "input_image",
1617
- image_url: part.image instanceof URL ? part.image.toString() : `data:${(_a = part.mimeType) != null ? _a : "image/jpeg"};base64,${convertUint8ArrayToBase642(part.image)}`,
1618
- // OpenAI specific extension: image detail
1619
- detail: (_c = (_b = part.providerOptions) == null ? void 0 : _b.openai) == null ? void 0 : _c.imageDetail
1620
- };
1621
- }
1622
1797
  case "file": {
1623
- if (part.data instanceof URL) {
1624
- throw new UnsupportedFunctionalityError5({
1625
- functionality: "File URLs in user messages"
1626
- });
1627
- }
1628
- switch (part.mimeType) {
1629
- case "application/pdf": {
1630
- return {
1631
- type: "input_file",
1632
- filename: (_d = part.filename) != null ? _d : `part-${index}.pdf`,
1633
- file_data: `data:application/pdf;base64,${part.data}`
1634
- };
1635
- }
1636
- default: {
1798
+ if (part.mediaType.startsWith("image/")) {
1799
+ const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
1800
+ return {
1801
+ type: "input_image",
1802
+ image_url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${part.data}`,
1803
+ // OpenAI specific extension: image detail
1804
+ detail: (_b = (_a = part.providerOptions) == null ? void 0 : _a.openai) == null ? void 0 : _b.imageDetail
1805
+ };
1806
+ } else if (part.mediaType === "application/pdf") {
1807
+ if (part.data instanceof URL) {
1637
1808
  throw new UnsupportedFunctionalityError5({
1638
- functionality: "Only PDF files are supported in user messages"
1809
+ functionality: "PDF file parts with URLs"
1639
1810
  });
1640
1811
  }
1812
+ return {
1813
+ type: "input_file",
1814
+ filename: (_c = part.filename) != null ? _c : `part-${index}.pdf`,
1815
+ file_data: `data:application/pdf;base64,${part.data}`
1816
+ };
1817
+ } else {
1818
+ throw new UnsupportedFunctionalityError5({
1819
+ functionality: `file part media type ${part.mediaType}`
1820
+ });
1641
1821
  }
1642
1822
  }
1643
1823
  }
@@ -1768,7 +1948,7 @@ function prepareResponsesTools({
1768
1948
  default: {
1769
1949
  const _exhaustiveCheck = type;
1770
1950
  throw new UnsupportedFunctionalityError6({
1771
- functionality: `Unsupported tool choice type: ${_exhaustiveCheck}`
1951
+ functionality: `tool choice type: ${_exhaustiveCheck}`
1772
1952
  });
1773
1953
  }
1774
1954
  }
@@ -1829,7 +2009,7 @@ var OpenAIResponsesLanguageModel = class {
1829
2009
  systemMessageMode: modelConfig.systemMessageMode
1830
2010
  });
1831
2011
  warnings.push(...messageWarnings);
1832
- const openaiOptions = parseProviderOptions({
2012
+ const openaiOptions = parseProviderOptions2({
1833
2013
  provider: "openai",
1834
2014
  providerOptions,
1835
2015
  schema: openaiResponsesProviderOptionsSchema
@@ -1915,53 +2095,53 @@ var OpenAIResponsesLanguageModel = class {
1915
2095
  path: "/responses",
1916
2096
  modelId: this.modelId
1917
2097
  }),
1918
- headers: combineHeaders5(this.config.headers(), options.headers),
2098
+ headers: combineHeaders6(this.config.headers(), options.headers),
1919
2099
  body,
1920
2100
  failedResponseHandler: openaiFailedResponseHandler,
1921
- successfulResponseHandler: createJsonResponseHandler5(
1922
- z7.object({
1923
- id: z7.string(),
1924
- created_at: z7.number(),
1925
- model: z7.string(),
1926
- output: z7.array(
1927
- z7.discriminatedUnion("type", [
1928
- z7.object({
1929
- type: z7.literal("message"),
1930
- role: z7.literal("assistant"),
1931
- content: z7.array(
1932
- z7.object({
1933
- type: z7.literal("output_text"),
1934
- text: z7.string(),
1935
- annotations: z7.array(
1936
- z7.object({
1937
- type: z7.literal("url_citation"),
1938
- start_index: z7.number(),
1939
- end_index: z7.number(),
1940
- url: z7.string(),
1941
- title: z7.string()
2101
+ successfulResponseHandler: createJsonResponseHandler6(
2102
+ z8.object({
2103
+ id: z8.string(),
2104
+ created_at: z8.number(),
2105
+ model: z8.string(),
2106
+ output: z8.array(
2107
+ z8.discriminatedUnion("type", [
2108
+ z8.object({
2109
+ type: z8.literal("message"),
2110
+ role: z8.literal("assistant"),
2111
+ content: z8.array(
2112
+ z8.object({
2113
+ type: z8.literal("output_text"),
2114
+ text: z8.string(),
2115
+ annotations: z8.array(
2116
+ z8.object({
2117
+ type: z8.literal("url_citation"),
2118
+ start_index: z8.number(),
2119
+ end_index: z8.number(),
2120
+ url: z8.string(),
2121
+ title: z8.string()
1942
2122
  })
1943
2123
  )
1944
2124
  })
1945
2125
  )
1946
2126
  }),
1947
- z7.object({
1948
- type: z7.literal("function_call"),
1949
- call_id: z7.string(),
1950
- name: z7.string(),
1951
- arguments: z7.string()
2127
+ z8.object({
2128
+ type: z8.literal("function_call"),
2129
+ call_id: z8.string(),
2130
+ name: z8.string(),
2131
+ arguments: z8.string()
1952
2132
  }),
1953
- z7.object({
1954
- type: z7.literal("web_search_call")
2133
+ z8.object({
2134
+ type: z8.literal("web_search_call")
1955
2135
  }),
1956
- z7.object({
1957
- type: z7.literal("computer_call")
2136
+ z8.object({
2137
+ type: z8.literal("computer_call")
1958
2138
  }),
1959
- z7.object({
1960
- type: z7.literal("reasoning")
2139
+ z8.object({
2140
+ type: z8.literal("reasoning")
1961
2141
  })
1962
2142
  ])
1963
2143
  ),
1964
- incomplete_details: z7.object({ reason: z7.string() }).nullable(),
2144
+ incomplete_details: z8.object({ reason: z8.string() }).nullable(),
1965
2145
  usage: usageSchema
1966
2146
  })
1967
2147
  ),
@@ -2030,7 +2210,7 @@ var OpenAIResponsesLanguageModel = class {
2030
2210
  path: "/responses",
2031
2211
  modelId: this.modelId
2032
2212
  }),
2033
- headers: combineHeaders5(this.config.headers(), options.headers),
2213
+ headers: combineHeaders6(this.config.headers(), options.headers),
2034
2214
  body: {
2035
2215
  ...body,
2036
2216
  stream: true
@@ -2159,79 +2339,79 @@ var OpenAIResponsesLanguageModel = class {
2159
2339
  };
2160
2340
  }
2161
2341
  };
2162
- var usageSchema = z7.object({
2163
- input_tokens: z7.number(),
2164
- input_tokens_details: z7.object({ cached_tokens: z7.number().nullish() }).nullish(),
2165
- output_tokens: z7.number(),
2166
- output_tokens_details: z7.object({ reasoning_tokens: z7.number().nullish() }).nullish()
2342
+ var usageSchema = z8.object({
2343
+ input_tokens: z8.number(),
2344
+ input_tokens_details: z8.object({ cached_tokens: z8.number().nullish() }).nullish(),
2345
+ output_tokens: z8.number(),
2346
+ output_tokens_details: z8.object({ reasoning_tokens: z8.number().nullish() }).nullish()
2167
2347
  });
2168
- var textDeltaChunkSchema = z7.object({
2169
- type: z7.literal("response.output_text.delta"),
2170
- delta: z7.string()
2348
+ var textDeltaChunkSchema = z8.object({
2349
+ type: z8.literal("response.output_text.delta"),
2350
+ delta: z8.string()
2171
2351
  });
2172
- var responseFinishedChunkSchema = z7.object({
2173
- type: z7.enum(["response.completed", "response.incomplete"]),
2174
- response: z7.object({
2175
- incomplete_details: z7.object({ reason: z7.string() }).nullish(),
2352
+ var responseFinishedChunkSchema = z8.object({
2353
+ type: z8.enum(["response.completed", "response.incomplete"]),
2354
+ response: z8.object({
2355
+ incomplete_details: z8.object({ reason: z8.string() }).nullish(),
2176
2356
  usage: usageSchema
2177
2357
  })
2178
2358
  });
2179
- var responseCreatedChunkSchema = z7.object({
2180
- type: z7.literal("response.created"),
2181
- response: z7.object({
2182
- id: z7.string(),
2183
- created_at: z7.number(),
2184
- model: z7.string()
2359
+ var responseCreatedChunkSchema = z8.object({
2360
+ type: z8.literal("response.created"),
2361
+ response: z8.object({
2362
+ id: z8.string(),
2363
+ created_at: z8.number(),
2364
+ model: z8.string()
2185
2365
  })
2186
2366
  });
2187
- var responseOutputItemDoneSchema = z7.object({
2188
- type: z7.literal("response.output_item.done"),
2189
- output_index: z7.number(),
2190
- item: z7.discriminatedUnion("type", [
2191
- z7.object({
2192
- type: z7.literal("message")
2367
+ var responseOutputItemDoneSchema = z8.object({
2368
+ type: z8.literal("response.output_item.done"),
2369
+ output_index: z8.number(),
2370
+ item: z8.discriminatedUnion("type", [
2371
+ z8.object({
2372
+ type: z8.literal("message")
2193
2373
  }),
2194
- z7.object({
2195
- type: z7.literal("function_call"),
2196
- id: z7.string(),
2197
- call_id: z7.string(),
2198
- name: z7.string(),
2199
- arguments: z7.string(),
2200
- status: z7.literal("completed")
2374
+ z8.object({
2375
+ type: z8.literal("function_call"),
2376
+ id: z8.string(),
2377
+ call_id: z8.string(),
2378
+ name: z8.string(),
2379
+ arguments: z8.string(),
2380
+ status: z8.literal("completed")
2201
2381
  })
2202
2382
  ])
2203
2383
  });
2204
- var responseFunctionCallArgumentsDeltaSchema = z7.object({
2205
- type: z7.literal("response.function_call_arguments.delta"),
2206
- item_id: z7.string(),
2207
- output_index: z7.number(),
2208
- delta: z7.string()
2384
+ var responseFunctionCallArgumentsDeltaSchema = z8.object({
2385
+ type: z8.literal("response.function_call_arguments.delta"),
2386
+ item_id: z8.string(),
2387
+ output_index: z8.number(),
2388
+ delta: z8.string()
2209
2389
  });
2210
- var responseOutputItemAddedSchema = z7.object({
2211
- type: z7.literal("response.output_item.added"),
2212
- output_index: z7.number(),
2213
- item: z7.discriminatedUnion("type", [
2214
- z7.object({
2215
- type: z7.literal("message")
2390
+ var responseOutputItemAddedSchema = z8.object({
2391
+ type: z8.literal("response.output_item.added"),
2392
+ output_index: z8.number(),
2393
+ item: z8.discriminatedUnion("type", [
2394
+ z8.object({
2395
+ type: z8.literal("message")
2216
2396
  }),
2217
- z7.object({
2218
- type: z7.literal("function_call"),
2219
- id: z7.string(),
2220
- call_id: z7.string(),
2221
- name: z7.string(),
2222
- arguments: z7.string()
2397
+ z8.object({
2398
+ type: z8.literal("function_call"),
2399
+ id: z8.string(),
2400
+ call_id: z8.string(),
2401
+ name: z8.string(),
2402
+ arguments: z8.string()
2223
2403
  })
2224
2404
  ])
2225
2405
  });
2226
- var responseAnnotationAddedSchema = z7.object({
2227
- type: z7.literal("response.output_text.annotation.added"),
2228
- annotation: z7.object({
2229
- type: z7.literal("url_citation"),
2230
- url: z7.string(),
2231
- title: z7.string()
2406
+ var responseAnnotationAddedSchema = z8.object({
2407
+ type: z8.literal("response.output_text.annotation.added"),
2408
+ annotation: z8.object({
2409
+ type: z8.literal("url_citation"),
2410
+ url: z8.string(),
2411
+ title: z8.string()
2232
2412
  })
2233
2413
  });
2234
- var openaiResponsesChunkSchema = z7.union([
2414
+ var openaiResponsesChunkSchema = z8.union([
2235
2415
  textDeltaChunkSchema,
2236
2416
  responseFinishedChunkSchema,
2237
2417
  responseCreatedChunkSchema,
@@ -2239,7 +2419,7 @@ var openaiResponsesChunkSchema = z7.union([
2239
2419
  responseFunctionCallArgumentsDeltaSchema,
2240
2420
  responseOutputItemAddedSchema,
2241
2421
  responseAnnotationAddedSchema,
2242
- z7.object({ type: z7.string() }).passthrough()
2422
+ z8.object({ type: z8.string() }).passthrough()
2243
2423
  // fallback for unknown chunks
2244
2424
  ]);
2245
2425
  function isTextDeltaChunk(chunk) {
@@ -2284,15 +2464,15 @@ function getResponsesModelConfig(modelId) {
2284
2464
  requiredAutoTruncation: false
2285
2465
  };
2286
2466
  }
2287
- var openaiResponsesProviderOptionsSchema = z7.object({
2288
- metadata: z7.any().nullish(),
2289
- parallelToolCalls: z7.boolean().nullish(),
2290
- previousResponseId: z7.string().nullish(),
2291
- store: z7.boolean().nullish(),
2292
- user: z7.string().nullish(),
2293
- reasoningEffort: z7.string().nullish(),
2294
- strictSchemas: z7.boolean().nullish(),
2295
- instructions: z7.string().nullish()
2467
+ var openaiResponsesProviderOptionsSchema = z8.object({
2468
+ metadata: z8.any().nullish(),
2469
+ parallelToolCalls: z8.boolean().nullish(),
2470
+ previousResponseId: z8.string().nullish(),
2471
+ store: z8.boolean().nullish(),
2472
+ user: z8.string().nullish(),
2473
+ reasoningEffort: z8.string().nullish(),
2474
+ strictSchemas: z8.boolean().nullish(),
2475
+ instructions: z8.string().nullish()
2296
2476
  });
2297
2477
 
2298
2478
  // src/openai-provider.ts
@@ -2337,6 +2517,12 @@ function createOpenAI(options = {}) {
2337
2517
  headers: getHeaders,
2338
2518
  fetch: options.fetch
2339
2519
  });
2520
+ const createTranscriptionModel = (modelId) => new OpenAITranscriptionModel(modelId, {
2521
+ provider: `${providerName}.transcription`,
2522
+ url: ({ path }) => `${baseURL}${path}`,
2523
+ headers: getHeaders,
2524
+ fetch: options.fetch
2525
+ });
2340
2526
  const createLanguageModel = (modelId, settings) => {
2341
2527
  if (new.target) {
2342
2528
  throw new Error(
@@ -2371,6 +2557,8 @@ function createOpenAI(options = {}) {
2371
2557
  provider.textEmbeddingModel = createEmbeddingModel;
2372
2558
  provider.image = createImageModel;
2373
2559
  provider.imageModel = createImageModel;
2560
+ provider.transcription = createTranscriptionModel;
2561
+ provider.transcriptionModel = createTranscriptionModel;
2374
2562
  provider.tools = openaiTools;
2375
2563
  return provider;
2376
2564
  }