@ai-sdk/openai 2.0.0-canary.7 → 2.0.0-canary.9

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.
@@ -25,6 +25,7 @@ __export(internal_exports, {
25
25
  OpenAIEmbeddingModel: () => OpenAIEmbeddingModel,
26
26
  OpenAIImageModel: () => OpenAIImageModel,
27
27
  OpenAIResponsesLanguageModel: () => OpenAIResponsesLanguageModel,
28
+ OpenAISpeechModel: () => OpenAISpeechModel,
28
29
  OpenAITranscriptionModel: () => OpenAITranscriptionModel,
29
30
  modelMaxImagesPerCall: () => modelMaxImagesPerCall,
30
31
  openaiProviderOptions: () => openaiProviderOptions
@@ -534,13 +535,13 @@ var OpenAIChatLanguageModel = class {
534
535
  }
535
536
  baseArgs.max_tokens = void 0;
536
537
  }
537
- } else if (this.modelId.startsWith("gpt-4o-search-preview")) {
538
+ } else if (this.modelId.startsWith("gpt-4o-search-preview") || this.modelId.startsWith("gpt-4o-mini-search-preview")) {
538
539
  if (baseArgs.temperature != null) {
539
540
  baseArgs.temperature = void 0;
540
541
  warnings.push({
541
542
  type: "unsupported-setting",
542
543
  setting: "temperature",
543
- details: "temperature is not supported for the gpt-4o-search-preview model and has been removed."
544
+ details: "temperature is not supported for the search preview models and has been removed."
544
545
  });
545
546
  }
546
547
  }
@@ -563,7 +564,7 @@ var OpenAIChatLanguageModel = class {
563
564
  };
564
565
  }
565
566
  async doGenerate(options) {
566
- var _a, _b, _c, _d, _e, _f, _g;
567
+ var _a, _b, _c, _d, _e, _f, _g, _h;
567
568
  const { args: body, warnings } = this.getArgs(options);
568
569
  const {
569
570
  responseHeaders,
@@ -583,10 +584,23 @@ var OpenAIChatLanguageModel = class {
583
584
  abortSignal: options.abortSignal,
584
585
  fetch: this.config.fetch
585
586
  });
586
- const { messages: rawPrompt, ...rawSettings } = body;
587
587
  const choice = response.choices[0];
588
- const completionTokenDetails = (_a = response.usage) == null ? void 0 : _a.completion_tokens_details;
589
- const promptTokenDetails = (_b = response.usage) == null ? void 0 : _b.prompt_tokens_details;
588
+ const content = [];
589
+ const text = choice.message.content;
590
+ if (text != null && text.length > 0) {
591
+ content.push({ type: "text", text });
592
+ }
593
+ for (const toolCall of (_a = choice.message.tool_calls) != null ? _a : []) {
594
+ content.push({
595
+ type: "tool-call",
596
+ toolCallType: "function",
597
+ toolCallId: (_b = toolCall.id) != null ? _b : (0, import_provider_utils3.generateId)(),
598
+ toolName: toolCall.function.name,
599
+ args: toolCall.function.arguments
600
+ });
601
+ }
602
+ const completionTokenDetails = (_c = response.usage) == null ? void 0 : _c.completion_tokens_details;
603
+ const promptTokenDetails = (_d = response.usage) == null ? void 0 : _d.prompt_tokens_details;
590
604
  const providerMetadata = { openai: {} };
591
605
  if ((completionTokenDetails == null ? void 0 : completionTokenDetails.reasoning_tokens) != null) {
592
606
  providerMetadata.openai.reasoningTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.reasoning_tokens;
@@ -601,21 +615,11 @@ var OpenAIChatLanguageModel = class {
601
615
  providerMetadata.openai.cachedPromptTokens = promptTokenDetails == null ? void 0 : promptTokenDetails.cached_tokens;
602
616
  }
603
617
  return {
604
- text: choice.message.content != null ? { type: "text", text: choice.message.content } : void 0,
605
- toolCalls: (_c = choice.message.tool_calls) == null ? void 0 : _c.map((toolCall) => {
606
- var _a2;
607
- return {
608
- type: "tool-call",
609
- toolCallType: "function",
610
- toolCallId: (_a2 = toolCall.id) != null ? _a2 : (0, import_provider_utils3.generateId)(),
611
- toolName: toolCall.function.name,
612
- args: toolCall.function.arguments
613
- };
614
- }),
618
+ content,
615
619
  finishReason: mapOpenAIFinishReason(choice.finish_reason),
616
620
  usage: {
617
- inputTokens: (_e = (_d = response.usage) == null ? void 0 : _d.prompt_tokens) != null ? _e : void 0,
618
- outputTokens: (_g = (_f = response.usage) == null ? void 0 : _f.completion_tokens) != null ? _g : void 0
621
+ inputTokens: (_f = (_e = response.usage) == null ? void 0 : _e.prompt_tokens) != null ? _f : void 0,
622
+ outputTokens: (_h = (_g = response.usage) == null ? void 0 : _g.completion_tokens) != null ? _h : void 0
619
623
  },
620
624
  request: { body },
621
625
  response: {
@@ -663,6 +667,9 @@ var OpenAIChatLanguageModel = class {
663
667
  return {
664
668
  stream: response.pipeThrough(
665
669
  new TransformStream({
670
+ start(controller) {
671
+ controller.enqueue({ type: "stream-start", warnings });
672
+ },
666
673
  transform(chunk, controller) {
667
674
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
668
675
  if (!chunk.success) {
@@ -820,8 +827,7 @@ var OpenAIChatLanguageModel = class {
820
827
  })
821
828
  ),
822
829
  request: { body },
823
- response: { headers: responseHeaders },
824
- warnings
830
+ response: { headers: responseHeaders }
825
831
  };
826
832
  }
827
833
  };
@@ -922,7 +928,7 @@ var openaiChatChunkSchema = import_zod3.z.union([
922
928
  openaiErrorDataSchema
923
929
  ]);
924
930
  function isReasoningModel(modelId) {
925
- return modelId === "o1" || modelId.startsWith("o1-") || modelId === "o3" || modelId.startsWith("o3-");
931
+ return modelId.startsWith("o");
926
932
  }
927
933
  function isAudioModel(modelId) {
928
934
  return modelId.startsWith("gpt-4o-audio-preview");
@@ -1145,7 +1151,7 @@ var OpenAICompletionLanguageModel = class {
1145
1151
  });
1146
1152
  const choice = response.choices[0];
1147
1153
  return {
1148
- text: { type: "text", text: choice.text },
1154
+ content: [{ type: "text", text: choice.text }],
1149
1155
  usage: {
1150
1156
  inputTokens: response.usage.prompt_tokens,
1151
1157
  outputTokens: response.usage.completion_tokens
@@ -1193,6 +1199,9 @@ var OpenAICompletionLanguageModel = class {
1193
1199
  return {
1194
1200
  stream: response.pipeThrough(
1195
1201
  new TransformStream({
1202
+ start(controller) {
1203
+ controller.enqueue({ type: "stream-start", warnings });
1204
+ },
1196
1205
  transform(chunk, controller) {
1197
1206
  if (!chunk.success) {
1198
1207
  finishReason = "error";
@@ -1244,9 +1253,8 @@ var OpenAICompletionLanguageModel = class {
1244
1253
  }
1245
1254
  })
1246
1255
  ),
1247
- response: { headers: responseHeaders },
1248
- warnings,
1249
- request: { body: JSON.stringify(body) }
1256
+ request: { body },
1257
+ response: { headers: responseHeaders }
1250
1258
  };
1251
1259
  }
1252
1260
  };
@@ -1619,9 +1627,108 @@ var openaiTranscriptionResponseSchema = import_zod7.z.object({
1619
1627
  ).nullish()
1620
1628
  });
1621
1629
 
1622
- // src/responses/openai-responses-language-model.ts
1630
+ // src/openai-speech-model.ts
1623
1631
  var import_provider_utils8 = require("@ai-sdk/provider-utils");
1624
1632
  var import_zod8 = require("zod");
1633
+ var OpenAIProviderOptionsSchema = import_zod8.z.object({
1634
+ instructions: import_zod8.z.string().nullish(),
1635
+ speed: import_zod8.z.number().min(0.25).max(4).default(1).nullish()
1636
+ });
1637
+ var OpenAISpeechModel = class {
1638
+ constructor(modelId, config) {
1639
+ this.modelId = modelId;
1640
+ this.config = config;
1641
+ this.specificationVersion = "v1";
1642
+ }
1643
+ get provider() {
1644
+ return this.config.provider;
1645
+ }
1646
+ getArgs({
1647
+ text,
1648
+ voice = "alloy",
1649
+ outputFormat = "mp3",
1650
+ speed,
1651
+ instructions,
1652
+ providerOptions
1653
+ }) {
1654
+ const warnings = [];
1655
+ const openAIOptions = (0, import_provider_utils8.parseProviderOptions)({
1656
+ provider: "openai",
1657
+ providerOptions,
1658
+ schema: OpenAIProviderOptionsSchema
1659
+ });
1660
+ const requestBody = {
1661
+ model: this.modelId,
1662
+ input: text,
1663
+ voice,
1664
+ response_format: "mp3",
1665
+ speed,
1666
+ instructions
1667
+ };
1668
+ if (outputFormat) {
1669
+ if (["mp3", "opus", "aac", "flac", "wav", "pcm"].includes(outputFormat)) {
1670
+ requestBody.response_format = outputFormat;
1671
+ } else {
1672
+ warnings.push({
1673
+ type: "unsupported-setting",
1674
+ setting: "outputFormat",
1675
+ details: `Unsupported output format: ${outputFormat}. Using mp3 instead.`
1676
+ });
1677
+ }
1678
+ }
1679
+ if (openAIOptions) {
1680
+ const speechModelOptions = {};
1681
+ for (const key in speechModelOptions) {
1682
+ const value = speechModelOptions[key];
1683
+ if (value !== void 0) {
1684
+ requestBody[key] = value;
1685
+ }
1686
+ }
1687
+ }
1688
+ return {
1689
+ requestBody,
1690
+ warnings
1691
+ };
1692
+ }
1693
+ async doGenerate(options) {
1694
+ var _a, _b, _c;
1695
+ const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
1696
+ const { requestBody, warnings } = this.getArgs(options);
1697
+ const {
1698
+ value: audio,
1699
+ responseHeaders,
1700
+ rawValue: rawResponse
1701
+ } = await (0, import_provider_utils8.postJsonToApi)({
1702
+ url: this.config.url({
1703
+ path: "/audio/speech",
1704
+ modelId: this.modelId
1705
+ }),
1706
+ headers: (0, import_provider_utils8.combineHeaders)(this.config.headers(), options.headers),
1707
+ body: requestBody,
1708
+ failedResponseHandler: openaiFailedResponseHandler,
1709
+ successfulResponseHandler: (0, import_provider_utils8.createBinaryResponseHandler)(),
1710
+ abortSignal: options.abortSignal,
1711
+ fetch: this.config.fetch
1712
+ });
1713
+ return {
1714
+ audio,
1715
+ warnings,
1716
+ request: {
1717
+ body: JSON.stringify(requestBody)
1718
+ },
1719
+ response: {
1720
+ timestamp: currentDate,
1721
+ modelId: this.modelId,
1722
+ headers: responseHeaders,
1723
+ body: rawResponse
1724
+ }
1725
+ };
1726
+ }
1727
+ };
1728
+
1729
+ // src/responses/openai-responses-language-model.ts
1730
+ var import_provider_utils9 = require("@ai-sdk/provider-utils");
1731
+ var import_zod9 = require("zod");
1625
1732
 
1626
1733
  // src/responses/convert-to-openai-responses-messages.ts
1627
1734
  var import_provider6 = require("@ai-sdk/provider");
@@ -1831,6 +1938,7 @@ var OpenAIResponsesLanguageModel = class {
1831
1938
  constructor(modelId, config) {
1832
1939
  this.specificationVersion = "v2";
1833
1940
  this.defaultObjectGenerationMode = "json";
1941
+ this.supportsStructuredOutputs = true;
1834
1942
  this.modelId = modelId;
1835
1943
  this.config = config;
1836
1944
  }
@@ -1881,7 +1989,7 @@ var OpenAIResponsesLanguageModel = class {
1881
1989
  systemMessageMode: modelConfig.systemMessageMode
1882
1990
  });
1883
1991
  warnings.push(...messageWarnings);
1884
- const openaiOptions = (0, import_provider_utils8.parseProviderOptions)({
1992
+ const openaiOptions = (0, import_provider_utils9.parseProviderOptions)({
1885
1993
  provider: "openai",
1886
1994
  providerOptions,
1887
1995
  schema: openaiResponsesProviderOptionsSchema
@@ -1956,100 +2064,109 @@ var OpenAIResponsesLanguageModel = class {
1956
2064
  };
1957
2065
  }
1958
2066
  async doGenerate(options) {
1959
- var _a, _b, _c, _d, _e;
2067
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1960
2068
  const { args: body, warnings } = this.getArgs(options);
1961
2069
  const {
1962
2070
  responseHeaders,
1963
2071
  value: response,
1964
2072
  rawValue: rawResponse
1965
- } = await (0, import_provider_utils8.postJsonToApi)({
2073
+ } = await (0, import_provider_utils9.postJsonToApi)({
1966
2074
  url: this.config.url({
1967
2075
  path: "/responses",
1968
2076
  modelId: this.modelId
1969
2077
  }),
1970
- headers: (0, import_provider_utils8.combineHeaders)(this.config.headers(), options.headers),
2078
+ headers: (0, import_provider_utils9.combineHeaders)(this.config.headers(), options.headers),
1971
2079
  body,
1972
2080
  failedResponseHandler: openaiFailedResponseHandler,
1973
- successfulResponseHandler: (0, import_provider_utils8.createJsonResponseHandler)(
1974
- import_zod8.z.object({
1975
- id: import_zod8.z.string(),
1976
- created_at: import_zod8.z.number(),
1977
- model: import_zod8.z.string(),
1978
- output: import_zod8.z.array(
1979
- import_zod8.z.discriminatedUnion("type", [
1980
- import_zod8.z.object({
1981
- type: import_zod8.z.literal("message"),
1982
- role: import_zod8.z.literal("assistant"),
1983
- content: import_zod8.z.array(
1984
- import_zod8.z.object({
1985
- type: import_zod8.z.literal("output_text"),
1986
- text: import_zod8.z.string(),
1987
- annotations: import_zod8.z.array(
1988
- import_zod8.z.object({
1989
- type: import_zod8.z.literal("url_citation"),
1990
- start_index: import_zod8.z.number(),
1991
- end_index: import_zod8.z.number(),
1992
- url: import_zod8.z.string(),
1993
- title: import_zod8.z.string()
2081
+ successfulResponseHandler: (0, import_provider_utils9.createJsonResponseHandler)(
2082
+ import_zod9.z.object({
2083
+ id: import_zod9.z.string(),
2084
+ created_at: import_zod9.z.number(),
2085
+ model: import_zod9.z.string(),
2086
+ output: import_zod9.z.array(
2087
+ import_zod9.z.discriminatedUnion("type", [
2088
+ import_zod9.z.object({
2089
+ type: import_zod9.z.literal("message"),
2090
+ role: import_zod9.z.literal("assistant"),
2091
+ content: import_zod9.z.array(
2092
+ import_zod9.z.object({
2093
+ type: import_zod9.z.literal("output_text"),
2094
+ text: import_zod9.z.string(),
2095
+ annotations: import_zod9.z.array(
2096
+ import_zod9.z.object({
2097
+ type: import_zod9.z.literal("url_citation"),
2098
+ start_index: import_zod9.z.number(),
2099
+ end_index: import_zod9.z.number(),
2100
+ url: import_zod9.z.string(),
2101
+ title: import_zod9.z.string()
1994
2102
  })
1995
2103
  )
1996
2104
  })
1997
2105
  )
1998
2106
  }),
1999
- import_zod8.z.object({
2000
- type: import_zod8.z.literal("function_call"),
2001
- call_id: import_zod8.z.string(),
2002
- name: import_zod8.z.string(),
2003
- arguments: import_zod8.z.string()
2107
+ import_zod9.z.object({
2108
+ type: import_zod9.z.literal("function_call"),
2109
+ call_id: import_zod9.z.string(),
2110
+ name: import_zod9.z.string(),
2111
+ arguments: import_zod9.z.string()
2004
2112
  }),
2005
- import_zod8.z.object({
2006
- type: import_zod8.z.literal("web_search_call")
2113
+ import_zod9.z.object({
2114
+ type: import_zod9.z.literal("web_search_call")
2007
2115
  }),
2008
- import_zod8.z.object({
2009
- type: import_zod8.z.literal("computer_call")
2116
+ import_zod9.z.object({
2117
+ type: import_zod9.z.literal("computer_call")
2010
2118
  }),
2011
- import_zod8.z.object({
2012
- type: import_zod8.z.literal("reasoning")
2119
+ import_zod9.z.object({
2120
+ type: import_zod9.z.literal("reasoning")
2013
2121
  })
2014
2122
  ])
2015
2123
  ),
2016
- incomplete_details: import_zod8.z.object({ reason: import_zod8.z.string() }).nullable(),
2124
+ incomplete_details: import_zod9.z.object({ reason: import_zod9.z.string() }).nullable(),
2017
2125
  usage: usageSchema
2018
2126
  })
2019
2127
  ),
2020
2128
  abortSignal: options.abortSignal,
2021
2129
  fetch: this.config.fetch
2022
2130
  });
2023
- const outputTextElements = response.output.filter((output) => output.type === "message").flatMap((output) => output.content).filter((content) => content.type === "output_text");
2024
- const toolCalls = response.output.filter((output) => output.type === "function_call").map((output) => ({
2025
- type: "tool-call",
2026
- toolCallType: "function",
2027
- toolCallId: output.call_id,
2028
- toolName: output.name,
2029
- args: output.arguments
2030
- }));
2131
+ const content = [];
2132
+ for (const part of response.output) {
2133
+ switch (part.type) {
2134
+ case "message": {
2135
+ for (const contentPart of part.content) {
2136
+ content.push({
2137
+ type: "text",
2138
+ text: contentPart.text
2139
+ });
2140
+ for (const annotation of contentPart.annotations) {
2141
+ content.push({
2142
+ type: "source",
2143
+ sourceType: "url",
2144
+ id: (_c = (_b = (_a = this.config).generateId) == null ? void 0 : _b.call(_a)) != null ? _c : (0, import_provider_utils9.generateId)(),
2145
+ url: annotation.url,
2146
+ title: annotation.title
2147
+ });
2148
+ }
2149
+ }
2150
+ break;
2151
+ }
2152
+ case "function_call": {
2153
+ content.push({
2154
+ type: "tool-call",
2155
+ toolCallType: "function",
2156
+ toolCallId: part.call_id,
2157
+ toolName: part.name,
2158
+ args: part.arguments
2159
+ });
2160
+ break;
2161
+ }
2162
+ }
2163
+ }
2031
2164
  return {
2032
- text: {
2033
- type: "text",
2034
- text: outputTextElements.map((content) => content.text).join("\n")
2035
- },
2036
- sources: outputTextElements.flatMap(
2037
- (content) => content.annotations.map((annotation) => {
2038
- var _a2, _b2, _c2;
2039
- return {
2040
- type: "source",
2041
- sourceType: "url",
2042
- id: (_c2 = (_b2 = (_a2 = this.config).generateId) == null ? void 0 : _b2.call(_a2)) != null ? _c2 : (0, import_provider_utils8.generateId)(),
2043
- url: annotation.url,
2044
- title: annotation.title
2045
- };
2046
- })
2047
- ),
2165
+ content,
2048
2166
  finishReason: mapOpenAIResponseFinishReason({
2049
- finishReason: (_a = response.incomplete_details) == null ? void 0 : _a.reason,
2050
- hasToolCalls: toolCalls.length > 0
2167
+ finishReason: (_d = response.incomplete_details) == null ? void 0 : _d.reason,
2168
+ hasToolCalls: content.some((part) => part.type === "tool-call")
2051
2169
  }),
2052
- toolCalls: toolCalls.length > 0 ? toolCalls : void 0,
2053
2170
  usage: {
2054
2171
  inputTokens: response.usage.input_tokens,
2055
2172
  outputTokens: response.usage.output_tokens
@@ -2065,8 +2182,8 @@ var OpenAIResponsesLanguageModel = class {
2065
2182
  providerMetadata: {
2066
2183
  openai: {
2067
2184
  responseId: response.id,
2068
- cachedPromptTokens: (_c = (_b = response.usage.input_tokens_details) == null ? void 0 : _b.cached_tokens) != null ? _c : null,
2069
- reasoningTokens: (_e = (_d = response.usage.output_tokens_details) == null ? void 0 : _d.reasoning_tokens) != null ? _e : null
2185
+ cachedPromptTokens: (_f = (_e = response.usage.input_tokens_details) == null ? void 0 : _e.cached_tokens) != null ? _f : null,
2186
+ reasoningTokens: (_h = (_g = response.usage.output_tokens_details) == null ? void 0 : _g.reasoning_tokens) != null ? _h : null
2070
2187
  }
2071
2188
  },
2072
2189
  warnings
@@ -2074,18 +2191,18 @@ var OpenAIResponsesLanguageModel = class {
2074
2191
  }
2075
2192
  async doStream(options) {
2076
2193
  const { args: body, warnings } = this.getArgs(options);
2077
- const { responseHeaders, value: response } = await (0, import_provider_utils8.postJsonToApi)({
2194
+ const { responseHeaders, value: response } = await (0, import_provider_utils9.postJsonToApi)({
2078
2195
  url: this.config.url({
2079
2196
  path: "/responses",
2080
2197
  modelId: this.modelId
2081
2198
  }),
2082
- headers: (0, import_provider_utils8.combineHeaders)(this.config.headers(), options.headers),
2199
+ headers: (0, import_provider_utils9.combineHeaders)(this.config.headers(), options.headers),
2083
2200
  body: {
2084
2201
  ...body,
2085
2202
  stream: true
2086
2203
  },
2087
2204
  failedResponseHandler: openaiFailedResponseHandler,
2088
- successfulResponseHandler: (0, import_provider_utils8.createEventSourceResponseHandler)(
2205
+ successfulResponseHandler: (0, import_provider_utils9.createEventSourceResponseHandler)(
2089
2206
  openaiResponsesChunkSchema
2090
2207
  ),
2091
2208
  abortSignal: options.abortSignal,
@@ -2105,6 +2222,9 @@ var OpenAIResponsesLanguageModel = class {
2105
2222
  return {
2106
2223
  stream: response.pipeThrough(
2107
2224
  new TransformStream({
2225
+ start(controller) {
2226
+ controller.enqueue({ type: "stream-start", warnings });
2227
+ },
2108
2228
  transform(chunk, controller) {
2109
2229
  var _a, _b, _c, _d, _e, _f, _g, _h;
2110
2230
  if (!chunk.success) {
@@ -2174,7 +2294,7 @@ var OpenAIResponsesLanguageModel = class {
2174
2294
  controller.enqueue({
2175
2295
  type: "source",
2176
2296
  sourceType: "url",
2177
- id: (_h = (_g = (_f = self.config).generateId) == null ? void 0 : _g.call(_f)) != null ? _h : (0, import_provider_utils8.generateId)(),
2297
+ id: (_h = (_g = (_f = self.config).generateId) == null ? void 0 : _g.call(_f)) != null ? _h : (0, import_provider_utils9.generateId)(),
2178
2298
  url: value.annotation.url,
2179
2299
  title: value.annotation.title
2180
2300
  });
@@ -2199,84 +2319,83 @@ var OpenAIResponsesLanguageModel = class {
2199
2319
  })
2200
2320
  ),
2201
2321
  request: { body },
2202
- response: { headers: responseHeaders },
2203
- warnings
2322
+ response: { headers: responseHeaders }
2204
2323
  };
2205
2324
  }
2206
2325
  };
2207
- var usageSchema = import_zod8.z.object({
2208
- input_tokens: import_zod8.z.number(),
2209
- input_tokens_details: import_zod8.z.object({ cached_tokens: import_zod8.z.number().nullish() }).nullish(),
2210
- output_tokens: import_zod8.z.number(),
2211
- output_tokens_details: import_zod8.z.object({ reasoning_tokens: import_zod8.z.number().nullish() }).nullish()
2326
+ var usageSchema = import_zod9.z.object({
2327
+ input_tokens: import_zod9.z.number(),
2328
+ input_tokens_details: import_zod9.z.object({ cached_tokens: import_zod9.z.number().nullish() }).nullish(),
2329
+ output_tokens: import_zod9.z.number(),
2330
+ output_tokens_details: import_zod9.z.object({ reasoning_tokens: import_zod9.z.number().nullish() }).nullish()
2212
2331
  });
2213
- var textDeltaChunkSchema = import_zod8.z.object({
2214
- type: import_zod8.z.literal("response.output_text.delta"),
2215
- delta: import_zod8.z.string()
2332
+ var textDeltaChunkSchema = import_zod9.z.object({
2333
+ type: import_zod9.z.literal("response.output_text.delta"),
2334
+ delta: import_zod9.z.string()
2216
2335
  });
2217
- var responseFinishedChunkSchema = import_zod8.z.object({
2218
- type: import_zod8.z.enum(["response.completed", "response.incomplete"]),
2219
- response: import_zod8.z.object({
2220
- incomplete_details: import_zod8.z.object({ reason: import_zod8.z.string() }).nullish(),
2336
+ var responseFinishedChunkSchema = import_zod9.z.object({
2337
+ type: import_zod9.z.enum(["response.completed", "response.incomplete"]),
2338
+ response: import_zod9.z.object({
2339
+ incomplete_details: import_zod9.z.object({ reason: import_zod9.z.string() }).nullish(),
2221
2340
  usage: usageSchema
2222
2341
  })
2223
2342
  });
2224
- var responseCreatedChunkSchema = import_zod8.z.object({
2225
- type: import_zod8.z.literal("response.created"),
2226
- response: import_zod8.z.object({
2227
- id: import_zod8.z.string(),
2228
- created_at: import_zod8.z.number(),
2229
- model: import_zod8.z.string()
2343
+ var responseCreatedChunkSchema = import_zod9.z.object({
2344
+ type: import_zod9.z.literal("response.created"),
2345
+ response: import_zod9.z.object({
2346
+ id: import_zod9.z.string(),
2347
+ created_at: import_zod9.z.number(),
2348
+ model: import_zod9.z.string()
2230
2349
  })
2231
2350
  });
2232
- var responseOutputItemDoneSchema = import_zod8.z.object({
2233
- type: import_zod8.z.literal("response.output_item.done"),
2234
- output_index: import_zod8.z.number(),
2235
- item: import_zod8.z.discriminatedUnion("type", [
2236
- import_zod8.z.object({
2237
- type: import_zod8.z.literal("message")
2351
+ var responseOutputItemDoneSchema = import_zod9.z.object({
2352
+ type: import_zod9.z.literal("response.output_item.done"),
2353
+ output_index: import_zod9.z.number(),
2354
+ item: import_zod9.z.discriminatedUnion("type", [
2355
+ import_zod9.z.object({
2356
+ type: import_zod9.z.literal("message")
2238
2357
  }),
2239
- import_zod8.z.object({
2240
- type: import_zod8.z.literal("function_call"),
2241
- id: import_zod8.z.string(),
2242
- call_id: import_zod8.z.string(),
2243
- name: import_zod8.z.string(),
2244
- arguments: import_zod8.z.string(),
2245
- status: import_zod8.z.literal("completed")
2358
+ import_zod9.z.object({
2359
+ type: import_zod9.z.literal("function_call"),
2360
+ id: import_zod9.z.string(),
2361
+ call_id: import_zod9.z.string(),
2362
+ name: import_zod9.z.string(),
2363
+ arguments: import_zod9.z.string(),
2364
+ status: import_zod9.z.literal("completed")
2246
2365
  })
2247
2366
  ])
2248
2367
  });
2249
- var responseFunctionCallArgumentsDeltaSchema = import_zod8.z.object({
2250
- type: import_zod8.z.literal("response.function_call_arguments.delta"),
2251
- item_id: import_zod8.z.string(),
2252
- output_index: import_zod8.z.number(),
2253
- delta: import_zod8.z.string()
2368
+ var responseFunctionCallArgumentsDeltaSchema = import_zod9.z.object({
2369
+ type: import_zod9.z.literal("response.function_call_arguments.delta"),
2370
+ item_id: import_zod9.z.string(),
2371
+ output_index: import_zod9.z.number(),
2372
+ delta: import_zod9.z.string()
2254
2373
  });
2255
- var responseOutputItemAddedSchema = import_zod8.z.object({
2256
- type: import_zod8.z.literal("response.output_item.added"),
2257
- output_index: import_zod8.z.number(),
2258
- item: import_zod8.z.discriminatedUnion("type", [
2259
- import_zod8.z.object({
2260
- type: import_zod8.z.literal("message")
2374
+ var responseOutputItemAddedSchema = import_zod9.z.object({
2375
+ type: import_zod9.z.literal("response.output_item.added"),
2376
+ output_index: import_zod9.z.number(),
2377
+ item: import_zod9.z.discriminatedUnion("type", [
2378
+ import_zod9.z.object({
2379
+ type: import_zod9.z.literal("message")
2261
2380
  }),
2262
- import_zod8.z.object({
2263
- type: import_zod8.z.literal("function_call"),
2264
- id: import_zod8.z.string(),
2265
- call_id: import_zod8.z.string(),
2266
- name: import_zod8.z.string(),
2267
- arguments: import_zod8.z.string()
2381
+ import_zod9.z.object({
2382
+ type: import_zod9.z.literal("function_call"),
2383
+ id: import_zod9.z.string(),
2384
+ call_id: import_zod9.z.string(),
2385
+ name: import_zod9.z.string(),
2386
+ arguments: import_zod9.z.string()
2268
2387
  })
2269
2388
  ])
2270
2389
  });
2271
- var responseAnnotationAddedSchema = import_zod8.z.object({
2272
- type: import_zod8.z.literal("response.output_text.annotation.added"),
2273
- annotation: import_zod8.z.object({
2274
- type: import_zod8.z.literal("url_citation"),
2275
- url: import_zod8.z.string(),
2276
- title: import_zod8.z.string()
2390
+ var responseAnnotationAddedSchema = import_zod9.z.object({
2391
+ type: import_zod9.z.literal("response.output_text.annotation.added"),
2392
+ annotation: import_zod9.z.object({
2393
+ type: import_zod9.z.literal("url_citation"),
2394
+ url: import_zod9.z.string(),
2395
+ title: import_zod9.z.string()
2277
2396
  })
2278
2397
  });
2279
- var openaiResponsesChunkSchema = import_zod8.z.union([
2398
+ var openaiResponsesChunkSchema = import_zod9.z.union([
2280
2399
  textDeltaChunkSchema,
2281
2400
  responseFinishedChunkSchema,
2282
2401
  responseCreatedChunkSchema,
@@ -2284,7 +2403,7 @@ var openaiResponsesChunkSchema = import_zod8.z.union([
2284
2403
  responseFunctionCallArgumentsDeltaSchema,
2285
2404
  responseOutputItemAddedSchema,
2286
2405
  responseAnnotationAddedSchema,
2287
- import_zod8.z.object({ type: import_zod8.z.string() }).passthrough()
2406
+ import_zod9.z.object({ type: import_zod9.z.string() }).passthrough()
2288
2407
  // fallback for unknown chunks
2289
2408
  ]);
2290
2409
  function isTextDeltaChunk(chunk) {
@@ -2329,15 +2448,15 @@ function getResponsesModelConfig(modelId) {
2329
2448
  requiredAutoTruncation: false
2330
2449
  };
2331
2450
  }
2332
- var openaiResponsesProviderOptionsSchema = import_zod8.z.object({
2333
- metadata: import_zod8.z.any().nullish(),
2334
- parallelToolCalls: import_zod8.z.boolean().nullish(),
2335
- previousResponseId: import_zod8.z.string().nullish(),
2336
- store: import_zod8.z.boolean().nullish(),
2337
- user: import_zod8.z.string().nullish(),
2338
- reasoningEffort: import_zod8.z.string().nullish(),
2339
- strictSchemas: import_zod8.z.boolean().nullish(),
2340
- instructions: import_zod8.z.string().nullish()
2451
+ var openaiResponsesProviderOptionsSchema = import_zod9.z.object({
2452
+ metadata: import_zod9.z.any().nullish(),
2453
+ parallelToolCalls: import_zod9.z.boolean().nullish(),
2454
+ previousResponseId: import_zod9.z.string().nullish(),
2455
+ store: import_zod9.z.boolean().nullish(),
2456
+ user: import_zod9.z.string().nullish(),
2457
+ reasoningEffort: import_zod9.z.string().nullish(),
2458
+ strictSchemas: import_zod9.z.boolean().nullish(),
2459
+ instructions: import_zod9.z.string().nullish()
2341
2460
  });
2342
2461
  // Annotate the CommonJS export names for ESM import in node:
2343
2462
  0 && (module.exports = {
@@ -2346,6 +2465,7 @@ var openaiResponsesProviderOptionsSchema = import_zod8.z.object({
2346
2465
  OpenAIEmbeddingModel,
2347
2466
  OpenAIImageModel,
2348
2467
  OpenAIResponsesLanguageModel,
2468
+ OpenAISpeechModel,
2349
2469
  OpenAITranscriptionModel,
2350
2470
  modelMaxImagesPerCall,
2351
2471
  openaiProviderOptions