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

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.
@@ -17,7 +17,6 @@ import { z as z2 } from "zod";
17
17
  import {
18
18
  UnsupportedFunctionalityError
19
19
  } from "@ai-sdk/provider";
20
- import { convertUint8ArrayToBase64 } from "@ai-sdk/provider-utils";
21
20
  function convertToOpenAIChatMessages({
22
21
  prompt,
23
22
  useLegacyFunctionCalling = false,
@@ -61,55 +60,65 @@ function convertToOpenAIChatMessages({
61
60
  messages.push({
62
61
  role: "user",
63
62
  content: content.map((part, index) => {
64
- var _a, _b, _c, _d;
63
+ var _a, _b, _c;
65
64
  switch (part.type) {
66
65
  case "text": {
67
66
  return { type: "text", text: part.text };
68
67
  }
69
- case "image": {
70
- return {
71
- type: "image_url",
72
- image_url: {
73
- url: part.image instanceof URL ? part.image.toString() : `data:${(_a = part.mimeType) != null ? _a : "image/jpeg"};base64,${convertUint8ArrayToBase64(part.image)}`,
74
- // OpenAI specific extension: image detail
75
- detail: (_c = (_b = part.providerOptions) == null ? void 0 : _b.openai) == null ? void 0 : _c.imageDetail
76
- }
77
- };
78
- }
79
68
  case "file": {
80
- if (part.data instanceof URL) {
81
- throw new UnsupportedFunctionalityError({
82
- functionality: "'File content parts with URL data' functionality not supported."
83
- });
84
- }
85
- switch (part.mimeType) {
86
- case "audio/wav": {
87
- return {
88
- type: "input_audio",
89
- input_audio: { data: part.data, format: "wav" }
90
- };
91
- }
92
- case "audio/mp3":
93
- case "audio/mpeg": {
94
- return {
95
- type: "input_audio",
96
- input_audio: { data: part.data, format: "mp3" }
97
- };
69
+ if (part.mediaType.startsWith("image/")) {
70
+ const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
71
+ return {
72
+ type: "image_url",
73
+ image_url: {
74
+ url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${part.data}`,
75
+ // OpenAI specific extension: image detail
76
+ detail: (_b = (_a = part.providerOptions) == null ? void 0 : _a.openai) == null ? void 0 : _b.imageDetail
77
+ }
78
+ };
79
+ } else if (part.mediaType.startsWith("audio/")) {
80
+ if (part.data instanceof URL) {
81
+ throw new UnsupportedFunctionalityError({
82
+ functionality: "audio file parts with URLs"
83
+ });
98
84
  }
99
- case "application/pdf": {
100
- return {
101
- type: "file",
102
- file: {
103
- filename: (_d = part.filename) != null ? _d : `part-${index}.pdf`,
104
- file_data: `data:application/pdf;base64,${part.data}`
105
- }
106
- };
85
+ switch (part.mediaType) {
86
+ case "audio/wav": {
87
+ return {
88
+ type: "input_audio",
89
+ input_audio: { data: part.data, format: "wav" }
90
+ };
91
+ }
92
+ case "audio/mp3":
93
+ case "audio/mpeg": {
94
+ return {
95
+ type: "input_audio",
96
+ input_audio: { data: part.data, format: "mp3" }
97
+ };
98
+ }
99
+ default: {
100
+ throw new UnsupportedFunctionalityError({
101
+ functionality: `audio content parts with media type ${part.mediaType}`
102
+ });
103
+ }
107
104
  }
108
- default: {
105
+ } else if (part.mediaType === "application/pdf") {
106
+ if (part.data instanceof URL) {
109
107
  throw new UnsupportedFunctionalityError({
110
- functionality: `File content part type ${part.mimeType} in user messages`
108
+ functionality: "PDF file parts with URLs"
111
109
  });
112
110
  }
111
+ return {
112
+ type: "file",
113
+ file: {
114
+ filename: (_c = part.filename) != null ? _c : `part-${index}.pdf`,
115
+ file_data: `data:application/pdf;base64,${part.data}`
116
+ }
117
+ };
118
+ } else {
119
+ throw new UnsupportedFunctionalityError({
120
+ functionality: `file part media type ${part.mediaType}`
121
+ });
113
122
  }
114
123
  }
115
124
  }
@@ -344,7 +353,7 @@ function prepareTools({
344
353
  default: {
345
354
  const _exhaustiveCheck = type;
346
355
  throw new UnsupportedFunctionalityError2({
347
- functionality: `Unsupported tool choice type: ${_exhaustiveCheck}`
356
+ functionality: `tool choice type: ${_exhaustiveCheck}`
348
357
  });
349
358
  }
350
359
  }
@@ -606,9 +615,12 @@ var OpenAIChatLanguageModel = class {
606
615
  completionTokens: (_h = (_g = response.usage) == null ? void 0 : _g.completion_tokens) != null ? _h : NaN
607
616
  },
608
617
  rawCall: { rawPrompt, rawSettings },
609
- rawResponse: { headers: responseHeaders, body: rawResponse },
610
618
  request: { body: JSON.stringify(body) },
611
- response: getResponseMetadata(response),
619
+ response: {
620
+ ...getResponseMetadata(response),
621
+ headers: responseHeaders,
622
+ body: rawResponse
623
+ },
612
624
  warnings,
613
625
  logprobs: mapOpenAIChatLogProbsOutput(choice.logprobs),
614
626
  providerMetadata
@@ -654,7 +666,7 @@ var OpenAIChatLanguageModel = class {
654
666
  return {
655
667
  stream: simulatedStream,
656
668
  rawCall: result.rawCall,
657
- rawResponse: result.rawResponse,
669
+ response: result.response,
658
670
  warnings: result.warnings
659
671
  };
660
672
  }
@@ -864,7 +876,7 @@ var OpenAIChatLanguageModel = class {
864
876
  })
865
877
  ),
866
878
  rawCall: { rawPrompt, rawSettings },
867
- rawResponse: { headers: responseHeaders },
879
+ response: { headers: responseHeaders },
868
880
  request: { body: JSON.stringify(body) },
869
881
  warnings
870
882
  };
@@ -1052,13 +1064,8 @@ function convertToOpenAICompletionPrompt({
1052
1064
  case "text": {
1053
1065
  return part.text;
1054
1066
  }
1055
- case "image": {
1056
- throw new UnsupportedFunctionalityError4({
1057
- functionality: "images"
1058
- });
1059
- }
1060
1067
  }
1061
- }).join("");
1068
+ }).filter(Boolean).join("");
1062
1069
  text += `${user}:
1063
1070
  ${userMessage}
1064
1071
 
@@ -1220,10 +1227,13 @@ var OpenAICompletionLanguageModel = class {
1220
1227
  finishReason: mapOpenAIFinishReason(choice.finish_reason),
1221
1228
  logprobs: mapOpenAICompletionLogProbs(choice.logprobs),
1222
1229
  rawCall: { rawPrompt, rawSettings },
1223
- rawResponse: { headers: responseHeaders, body: rawResponse },
1224
- response: getResponseMetadata(response),
1225
- warnings,
1226
- request: { body: JSON.stringify(args) }
1230
+ request: { body: JSON.stringify(args) },
1231
+ response: {
1232
+ ...getResponseMetadata(response),
1233
+ headers: responseHeaders,
1234
+ body: rawResponse
1235
+ },
1236
+ warnings
1227
1237
  };
1228
1238
  }
1229
1239
  async doStream(options) {
@@ -1313,7 +1323,7 @@ var OpenAICompletionLanguageModel = class {
1313
1323
  })
1314
1324
  ),
1315
1325
  rawCall: { rawPrompt, rawSettings },
1316
- rawResponse: { headers: responseHeaders },
1326
+ response: { headers: responseHeaders },
1317
1327
  warnings,
1318
1328
  request: { body: JSON.stringify(body) }
1319
1329
  };
@@ -1525,22 +1535,201 @@ var openaiImageResponseSchema = z5.object({
1525
1535
  data: z5.array(z5.object({ b64_json: z5.string() }))
1526
1536
  });
1527
1537
 
1528
- // src/responses/openai-responses-language-model.ts
1538
+ // src/openai-transcription-model.ts
1529
1539
  import {
1530
1540
  combineHeaders as combineHeaders5,
1531
- createEventSourceResponseHandler as createEventSourceResponseHandler3,
1541
+ convertBase64ToUint8Array,
1532
1542
  createJsonResponseHandler as createJsonResponseHandler5,
1533
- generateId as generateId2,
1534
1543
  parseProviderOptions,
1535
- postJsonToApi as postJsonToApi5
1544
+ postFormDataToApi
1536
1545
  } from "@ai-sdk/provider-utils";
1537
1546
  import { z as z6 } from "zod";
1547
+ var OpenAIProviderOptionsSchema = z6.object({
1548
+ include: z6.array(z6.string()).optional().describe(
1549
+ "Additional information to include in the transcription response."
1550
+ ),
1551
+ language: z6.string().optional().describe("The language of the input audio in ISO-639-1 format."),
1552
+ prompt: z6.string().optional().describe(
1553
+ "An optional text to guide the model's style or continue a previous audio segment."
1554
+ ),
1555
+ temperature: z6.number().min(0).max(1).optional().default(0).describe("The sampling temperature, between 0 and 1."),
1556
+ timestampGranularities: z6.array(z6.enum(["word", "segment"])).optional().default(["segment"]).describe(
1557
+ "The timestamp granularities to populate for this transcription."
1558
+ )
1559
+ });
1560
+ var languageMap = {
1561
+ afrikaans: "af",
1562
+ arabic: "ar",
1563
+ armenian: "hy",
1564
+ azerbaijani: "az",
1565
+ belarusian: "be",
1566
+ bosnian: "bs",
1567
+ bulgarian: "bg",
1568
+ catalan: "ca",
1569
+ chinese: "zh",
1570
+ croatian: "hr",
1571
+ czech: "cs",
1572
+ danish: "da",
1573
+ dutch: "nl",
1574
+ english: "en",
1575
+ estonian: "et",
1576
+ finnish: "fi",
1577
+ french: "fr",
1578
+ galician: "gl",
1579
+ german: "de",
1580
+ greek: "el",
1581
+ hebrew: "he",
1582
+ hindi: "hi",
1583
+ hungarian: "hu",
1584
+ icelandic: "is",
1585
+ indonesian: "id",
1586
+ italian: "it",
1587
+ japanese: "ja",
1588
+ kannada: "kn",
1589
+ kazakh: "kk",
1590
+ korean: "ko",
1591
+ latvian: "lv",
1592
+ lithuanian: "lt",
1593
+ macedonian: "mk",
1594
+ malay: "ms",
1595
+ marathi: "mr",
1596
+ maori: "mi",
1597
+ nepali: "ne",
1598
+ norwegian: "no",
1599
+ persian: "fa",
1600
+ polish: "pl",
1601
+ portuguese: "pt",
1602
+ romanian: "ro",
1603
+ russian: "ru",
1604
+ serbian: "sr",
1605
+ slovak: "sk",
1606
+ slovenian: "sl",
1607
+ spanish: "es",
1608
+ swahili: "sw",
1609
+ swedish: "sv",
1610
+ tagalog: "tl",
1611
+ tamil: "ta",
1612
+ thai: "th",
1613
+ turkish: "tr",
1614
+ ukrainian: "uk",
1615
+ urdu: "ur",
1616
+ vietnamese: "vi",
1617
+ welsh: "cy"
1618
+ };
1619
+ var OpenAITranscriptionModel = class {
1620
+ constructor(modelId, config) {
1621
+ this.modelId = modelId;
1622
+ this.config = config;
1623
+ this.specificationVersion = "v1";
1624
+ }
1625
+ get provider() {
1626
+ return this.config.provider;
1627
+ }
1628
+ getArgs({
1629
+ audio,
1630
+ mediaType,
1631
+ providerOptions
1632
+ }) {
1633
+ const warnings = [];
1634
+ const openAIOptions = parseProviderOptions({
1635
+ provider: "openai",
1636
+ providerOptions,
1637
+ schema: OpenAIProviderOptionsSchema
1638
+ });
1639
+ const formData = new FormData();
1640
+ const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([convertBase64ToUint8Array(audio)]);
1641
+ formData.append("model", this.modelId);
1642
+ formData.append("file", new File([blob], "audio", { type: mediaType }));
1643
+ if (openAIOptions) {
1644
+ const transcriptionModelOptions = {
1645
+ include: openAIOptions.include,
1646
+ language: openAIOptions.language,
1647
+ prompt: openAIOptions.prompt,
1648
+ temperature: openAIOptions.temperature,
1649
+ timestamp_granularities: openAIOptions.timestampGranularities
1650
+ };
1651
+ for (const key in transcriptionModelOptions) {
1652
+ const value = transcriptionModelOptions[key];
1653
+ if (value !== void 0) {
1654
+ formData.append(key, value);
1655
+ }
1656
+ }
1657
+ }
1658
+ return {
1659
+ formData,
1660
+ warnings
1661
+ };
1662
+ }
1663
+ async doGenerate(options) {
1664
+ var _a, _b, _c, _d, _e, _f;
1665
+ const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
1666
+ const { formData, warnings } = this.getArgs(options);
1667
+ const {
1668
+ value: response,
1669
+ responseHeaders,
1670
+ rawValue: rawResponse
1671
+ } = await postFormDataToApi({
1672
+ url: this.config.url({
1673
+ path: "/audio/transcriptions",
1674
+ modelId: this.modelId
1675
+ }),
1676
+ headers: combineHeaders5(this.config.headers(), options.headers),
1677
+ formData,
1678
+ failedResponseHandler: openaiFailedResponseHandler,
1679
+ successfulResponseHandler: createJsonResponseHandler5(
1680
+ openaiTranscriptionResponseSchema
1681
+ ),
1682
+ abortSignal: options.abortSignal,
1683
+ fetch: this.config.fetch
1684
+ });
1685
+ const language = response.language != null && response.language in languageMap ? languageMap[response.language] : void 0;
1686
+ return {
1687
+ text: response.text,
1688
+ segments: (_e = (_d = response.words) == null ? void 0 : _d.map((word) => ({
1689
+ text: word.word,
1690
+ startSecond: word.start,
1691
+ endSecond: word.end
1692
+ }))) != null ? _e : [],
1693
+ language,
1694
+ durationInSeconds: (_f = response.duration) != null ? _f : void 0,
1695
+ warnings,
1696
+ response: {
1697
+ timestamp: currentDate,
1698
+ modelId: this.modelId,
1699
+ headers: responseHeaders,
1700
+ body: rawResponse
1701
+ }
1702
+ };
1703
+ }
1704
+ };
1705
+ var openaiTranscriptionResponseSchema = z6.object({
1706
+ text: z6.string(),
1707
+ language: z6.string().nullish(),
1708
+ duration: z6.number().nullish(),
1709
+ words: z6.array(
1710
+ z6.object({
1711
+ word: z6.string(),
1712
+ start: z6.number(),
1713
+ end: z6.number()
1714
+ })
1715
+ ).nullish()
1716
+ });
1717
+
1718
+ // src/responses/openai-responses-language-model.ts
1719
+ import {
1720
+ combineHeaders as combineHeaders6,
1721
+ createEventSourceResponseHandler as createEventSourceResponseHandler3,
1722
+ createJsonResponseHandler as createJsonResponseHandler6,
1723
+ generateId as generateId2,
1724
+ parseProviderOptions as parseProviderOptions2,
1725
+ postJsonToApi as postJsonToApi5
1726
+ } from "@ai-sdk/provider-utils";
1727
+ import { z as z7 } from "zod";
1538
1728
 
1539
1729
  // src/responses/convert-to-openai-responses-messages.ts
1540
1730
  import {
1541
1731
  UnsupportedFunctionalityError as UnsupportedFunctionalityError5
1542
1732
  } from "@ai-sdk/provider";
1543
- import { convertUint8ArrayToBase64 as convertUint8ArrayToBase642 } from "@ai-sdk/provider-utils";
1544
1733
  function convertToOpenAIResponsesMessages({
1545
1734
  prompt,
1546
1735
  systemMessageMode
@@ -1579,38 +1768,35 @@ function convertToOpenAIResponsesMessages({
1579
1768
  messages.push({
1580
1769
  role: "user",
1581
1770
  content: content.map((part, index) => {
1582
- var _a, _b, _c, _d;
1771
+ var _a, _b, _c;
1583
1772
  switch (part.type) {
1584
1773
  case "text": {
1585
1774
  return { type: "input_text", text: part.text };
1586
1775
  }
1587
- case "image": {
1588
- return {
1589
- type: "input_image",
1590
- image_url: part.image instanceof URL ? part.image.toString() : `data:${(_a = part.mimeType) != null ? _a : "image/jpeg"};base64,${convertUint8ArrayToBase642(part.image)}`,
1591
- // OpenAI specific extension: image detail
1592
- detail: (_c = (_b = part.providerOptions) == null ? void 0 : _b.openai) == null ? void 0 : _c.imageDetail
1593
- };
1594
- }
1595
1776
  case "file": {
1596
- if (part.data instanceof URL) {
1597
- throw new UnsupportedFunctionalityError5({
1598
- functionality: "File URLs in user messages"
1599
- });
1600
- }
1601
- switch (part.mimeType) {
1602
- case "application/pdf": {
1603
- return {
1604
- type: "input_file",
1605
- filename: (_d = part.filename) != null ? _d : `part-${index}.pdf`,
1606
- file_data: `data:application/pdf;base64,${part.data}`
1607
- };
1608
- }
1609
- default: {
1777
+ if (part.mediaType.startsWith("image/")) {
1778
+ const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
1779
+ return {
1780
+ type: "input_image",
1781
+ image_url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${part.data}`,
1782
+ // OpenAI specific extension: image detail
1783
+ detail: (_b = (_a = part.providerOptions) == null ? void 0 : _a.openai) == null ? void 0 : _b.imageDetail
1784
+ };
1785
+ } else if (part.mediaType === "application/pdf") {
1786
+ if (part.data instanceof URL) {
1610
1787
  throw new UnsupportedFunctionalityError5({
1611
- functionality: "Only PDF files are supported in user messages"
1788
+ functionality: "PDF file parts with URLs"
1612
1789
  });
1613
1790
  }
1791
+ return {
1792
+ type: "input_file",
1793
+ filename: (_c = part.filename) != null ? _c : `part-${index}.pdf`,
1794
+ file_data: `data:application/pdf;base64,${part.data}`
1795
+ };
1796
+ } else {
1797
+ throw new UnsupportedFunctionalityError5({
1798
+ functionality: `file part media type ${part.mediaType}`
1799
+ });
1614
1800
  }
1615
1801
  }
1616
1802
  }
@@ -1741,7 +1927,7 @@ function prepareResponsesTools({
1741
1927
  default: {
1742
1928
  const _exhaustiveCheck = type;
1743
1929
  throw new UnsupportedFunctionalityError6({
1744
- functionality: `Unsupported tool choice type: ${_exhaustiveCheck}`
1930
+ functionality: `tool choice type: ${_exhaustiveCheck}`
1745
1931
  });
1746
1932
  }
1747
1933
  }
@@ -1802,7 +1988,7 @@ var OpenAIResponsesLanguageModel = class {
1802
1988
  systemMessageMode: modelConfig.systemMessageMode
1803
1989
  });
1804
1990
  warnings.push(...messageWarnings);
1805
- const openaiOptions = parseProviderOptions({
1991
+ const openaiOptions = parseProviderOptions2({
1806
1992
  provider: "openai",
1807
1993
  providerOptions,
1808
1994
  schema: openaiResponsesProviderOptionsSchema
@@ -1888,53 +2074,53 @@ var OpenAIResponsesLanguageModel = class {
1888
2074
  path: "/responses",
1889
2075
  modelId: this.modelId
1890
2076
  }),
1891
- headers: combineHeaders5(this.config.headers(), options.headers),
2077
+ headers: combineHeaders6(this.config.headers(), options.headers),
1892
2078
  body,
1893
2079
  failedResponseHandler: openaiFailedResponseHandler,
1894
- successfulResponseHandler: createJsonResponseHandler5(
1895
- z6.object({
1896
- id: z6.string(),
1897
- created_at: z6.number(),
1898
- model: z6.string(),
1899
- output: z6.array(
1900
- z6.discriminatedUnion("type", [
1901
- z6.object({
1902
- type: z6.literal("message"),
1903
- role: z6.literal("assistant"),
1904
- content: z6.array(
1905
- z6.object({
1906
- type: z6.literal("output_text"),
1907
- text: z6.string(),
1908
- annotations: z6.array(
1909
- z6.object({
1910
- type: z6.literal("url_citation"),
1911
- start_index: z6.number(),
1912
- end_index: z6.number(),
1913
- url: z6.string(),
1914
- title: z6.string()
2080
+ successfulResponseHandler: createJsonResponseHandler6(
2081
+ z7.object({
2082
+ id: z7.string(),
2083
+ created_at: z7.number(),
2084
+ model: z7.string(),
2085
+ output: z7.array(
2086
+ z7.discriminatedUnion("type", [
2087
+ z7.object({
2088
+ type: z7.literal("message"),
2089
+ role: z7.literal("assistant"),
2090
+ content: z7.array(
2091
+ z7.object({
2092
+ type: z7.literal("output_text"),
2093
+ text: z7.string(),
2094
+ annotations: z7.array(
2095
+ z7.object({
2096
+ type: z7.literal("url_citation"),
2097
+ start_index: z7.number(),
2098
+ end_index: z7.number(),
2099
+ url: z7.string(),
2100
+ title: z7.string()
1915
2101
  })
1916
2102
  )
1917
2103
  })
1918
2104
  )
1919
2105
  }),
1920
- z6.object({
1921
- type: z6.literal("function_call"),
1922
- call_id: z6.string(),
1923
- name: z6.string(),
1924
- arguments: z6.string()
2106
+ z7.object({
2107
+ type: z7.literal("function_call"),
2108
+ call_id: z7.string(),
2109
+ name: z7.string(),
2110
+ arguments: z7.string()
1925
2111
  }),
1926
- z6.object({
1927
- type: z6.literal("web_search_call")
2112
+ z7.object({
2113
+ type: z7.literal("web_search_call")
1928
2114
  }),
1929
- z6.object({
1930
- type: z6.literal("computer_call")
2115
+ z7.object({
2116
+ type: z7.literal("computer_call")
1931
2117
  }),
1932
- z6.object({
1933
- type: z6.literal("reasoning")
2118
+ z7.object({
2119
+ type: z7.literal("reasoning")
1934
2120
  })
1935
2121
  ])
1936
2122
  ),
1937
- incomplete_details: z6.object({ reason: z6.string() }).nullable(),
2123
+ incomplete_details: z7.object({ reason: z7.string() }).nullable(),
1938
2124
  usage: usageSchema
1939
2125
  })
1940
2126
  ),
@@ -1974,17 +2160,15 @@ var OpenAIResponsesLanguageModel = class {
1974
2160
  rawPrompt: void 0,
1975
2161
  rawSettings: {}
1976
2162
  },
1977
- rawResponse: {
1978
- headers: responseHeaders,
1979
- body: rawResponse
1980
- },
1981
2163
  request: {
1982
2164
  body: JSON.stringify(body)
1983
2165
  },
1984
2166
  response: {
1985
2167
  id: response.id,
1986
2168
  timestamp: new Date(response.created_at * 1e3),
1987
- modelId: response.model
2169
+ modelId: response.model,
2170
+ headers: responseHeaders,
2171
+ body: rawResponse
1988
2172
  },
1989
2173
  providerMetadata: {
1990
2174
  openai: {
@@ -2003,7 +2187,7 @@ var OpenAIResponsesLanguageModel = class {
2003
2187
  path: "/responses",
2004
2188
  modelId: this.modelId
2005
2189
  }),
2006
- headers: combineHeaders5(this.config.headers(), options.headers),
2190
+ headers: combineHeaders6(this.config.headers(), options.headers),
2007
2191
  body: {
2008
2192
  ...body,
2009
2193
  stream: true
@@ -2126,85 +2310,85 @@ var OpenAIResponsesLanguageModel = class {
2126
2310
  rawPrompt: void 0,
2127
2311
  rawSettings: {}
2128
2312
  },
2129
- rawResponse: { headers: responseHeaders },
2130
2313
  request: { body: JSON.stringify(body) },
2314
+ response: { headers: responseHeaders },
2131
2315
  warnings
2132
2316
  };
2133
2317
  }
2134
2318
  };
2135
- var usageSchema = z6.object({
2136
- input_tokens: z6.number(),
2137
- input_tokens_details: z6.object({ cached_tokens: z6.number().nullish() }).nullish(),
2138
- output_tokens: z6.number(),
2139
- output_tokens_details: z6.object({ reasoning_tokens: z6.number().nullish() }).nullish()
2319
+ var usageSchema = z7.object({
2320
+ input_tokens: z7.number(),
2321
+ input_tokens_details: z7.object({ cached_tokens: z7.number().nullish() }).nullish(),
2322
+ output_tokens: z7.number(),
2323
+ output_tokens_details: z7.object({ reasoning_tokens: z7.number().nullish() }).nullish()
2140
2324
  });
2141
- var textDeltaChunkSchema = z6.object({
2142
- type: z6.literal("response.output_text.delta"),
2143
- delta: z6.string()
2325
+ var textDeltaChunkSchema = z7.object({
2326
+ type: z7.literal("response.output_text.delta"),
2327
+ delta: z7.string()
2144
2328
  });
2145
- var responseFinishedChunkSchema = z6.object({
2146
- type: z6.enum(["response.completed", "response.incomplete"]),
2147
- response: z6.object({
2148
- incomplete_details: z6.object({ reason: z6.string() }).nullish(),
2329
+ var responseFinishedChunkSchema = z7.object({
2330
+ type: z7.enum(["response.completed", "response.incomplete"]),
2331
+ response: z7.object({
2332
+ incomplete_details: z7.object({ reason: z7.string() }).nullish(),
2149
2333
  usage: usageSchema
2150
2334
  })
2151
2335
  });
2152
- var responseCreatedChunkSchema = z6.object({
2153
- type: z6.literal("response.created"),
2154
- response: z6.object({
2155
- id: z6.string(),
2156
- created_at: z6.number(),
2157
- model: z6.string()
2336
+ var responseCreatedChunkSchema = z7.object({
2337
+ type: z7.literal("response.created"),
2338
+ response: z7.object({
2339
+ id: z7.string(),
2340
+ created_at: z7.number(),
2341
+ model: z7.string()
2158
2342
  })
2159
2343
  });
2160
- var responseOutputItemDoneSchema = z6.object({
2161
- type: z6.literal("response.output_item.done"),
2162
- output_index: z6.number(),
2163
- item: z6.discriminatedUnion("type", [
2164
- z6.object({
2165
- type: z6.literal("message")
2344
+ var responseOutputItemDoneSchema = z7.object({
2345
+ type: z7.literal("response.output_item.done"),
2346
+ output_index: z7.number(),
2347
+ item: z7.discriminatedUnion("type", [
2348
+ z7.object({
2349
+ type: z7.literal("message")
2166
2350
  }),
2167
- z6.object({
2168
- type: z6.literal("function_call"),
2169
- id: z6.string(),
2170
- call_id: z6.string(),
2171
- name: z6.string(),
2172
- arguments: z6.string(),
2173
- status: z6.literal("completed")
2351
+ z7.object({
2352
+ type: z7.literal("function_call"),
2353
+ id: z7.string(),
2354
+ call_id: z7.string(),
2355
+ name: z7.string(),
2356
+ arguments: z7.string(),
2357
+ status: z7.literal("completed")
2174
2358
  })
2175
2359
  ])
2176
2360
  });
2177
- var responseFunctionCallArgumentsDeltaSchema = z6.object({
2178
- type: z6.literal("response.function_call_arguments.delta"),
2179
- item_id: z6.string(),
2180
- output_index: z6.number(),
2181
- delta: z6.string()
2361
+ var responseFunctionCallArgumentsDeltaSchema = z7.object({
2362
+ type: z7.literal("response.function_call_arguments.delta"),
2363
+ item_id: z7.string(),
2364
+ output_index: z7.number(),
2365
+ delta: z7.string()
2182
2366
  });
2183
- var responseOutputItemAddedSchema = z6.object({
2184
- type: z6.literal("response.output_item.added"),
2185
- output_index: z6.number(),
2186
- item: z6.discriminatedUnion("type", [
2187
- z6.object({
2188
- type: z6.literal("message")
2367
+ var responseOutputItemAddedSchema = z7.object({
2368
+ type: z7.literal("response.output_item.added"),
2369
+ output_index: z7.number(),
2370
+ item: z7.discriminatedUnion("type", [
2371
+ z7.object({
2372
+ type: z7.literal("message")
2189
2373
  }),
2190
- z6.object({
2191
- type: z6.literal("function_call"),
2192
- id: z6.string(),
2193
- call_id: z6.string(),
2194
- name: z6.string(),
2195
- arguments: z6.string()
2374
+ z7.object({
2375
+ type: z7.literal("function_call"),
2376
+ id: z7.string(),
2377
+ call_id: z7.string(),
2378
+ name: z7.string(),
2379
+ arguments: z7.string()
2196
2380
  })
2197
2381
  ])
2198
2382
  });
2199
- var responseAnnotationAddedSchema = z6.object({
2200
- type: z6.literal("response.output_text.annotation.added"),
2201
- annotation: z6.object({
2202
- type: z6.literal("url_citation"),
2203
- url: z6.string(),
2204
- title: z6.string()
2383
+ var responseAnnotationAddedSchema = z7.object({
2384
+ type: z7.literal("response.output_text.annotation.added"),
2385
+ annotation: z7.object({
2386
+ type: z7.literal("url_citation"),
2387
+ url: z7.string(),
2388
+ title: z7.string()
2205
2389
  })
2206
2390
  });
2207
- var openaiResponsesChunkSchema = z6.union([
2391
+ var openaiResponsesChunkSchema = z7.union([
2208
2392
  textDeltaChunkSchema,
2209
2393
  responseFinishedChunkSchema,
2210
2394
  responseCreatedChunkSchema,
@@ -2212,7 +2396,7 @@ var openaiResponsesChunkSchema = z6.union([
2212
2396
  responseFunctionCallArgumentsDeltaSchema,
2213
2397
  responseOutputItemAddedSchema,
2214
2398
  responseAnnotationAddedSchema,
2215
- z6.object({ type: z6.string() }).passthrough()
2399
+ z7.object({ type: z7.string() }).passthrough()
2216
2400
  // fallback for unknown chunks
2217
2401
  ]);
2218
2402
  function isTextDeltaChunk(chunk) {
@@ -2257,15 +2441,15 @@ function getResponsesModelConfig(modelId) {
2257
2441
  requiredAutoTruncation: false
2258
2442
  };
2259
2443
  }
2260
- var openaiResponsesProviderOptionsSchema = z6.object({
2261
- metadata: z6.any().nullish(),
2262
- parallelToolCalls: z6.boolean().nullish(),
2263
- previousResponseId: z6.string().nullish(),
2264
- store: z6.boolean().nullish(),
2265
- user: z6.string().nullish(),
2266
- reasoningEffort: z6.string().nullish(),
2267
- strictSchemas: z6.boolean().nullish(),
2268
- instructions: z6.string().nullish()
2444
+ var openaiResponsesProviderOptionsSchema = z7.object({
2445
+ metadata: z7.any().nullish(),
2446
+ parallelToolCalls: z7.boolean().nullish(),
2447
+ previousResponseId: z7.string().nullish(),
2448
+ store: z7.boolean().nullish(),
2449
+ user: z7.string().nullish(),
2450
+ reasoningEffort: z7.string().nullish(),
2451
+ strictSchemas: z7.boolean().nullish(),
2452
+ instructions: z7.string().nullish()
2269
2453
  });
2270
2454
  export {
2271
2455
  OpenAIChatLanguageModel,
@@ -2273,6 +2457,7 @@ export {
2273
2457
  OpenAIEmbeddingModel,
2274
2458
  OpenAIImageModel,
2275
2459
  OpenAIResponsesLanguageModel,
2460
+ OpenAITranscriptionModel,
2276
2461
  modelMaxImagesPerCall
2277
2462
  };
2278
2463
  //# sourceMappingURL=index.mjs.map