@ai-sdk/openai 2.0.0-canary.7 → 2.0.0-canary.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.
@@ -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
@@ -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
  };
@@ -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");
@@ -1881,7 +1988,7 @@ var OpenAIResponsesLanguageModel = class {
1881
1988
  systemMessageMode: modelConfig.systemMessageMode
1882
1989
  });
1883
1990
  warnings.push(...messageWarnings);
1884
- const openaiOptions = (0, import_provider_utils8.parseProviderOptions)({
1991
+ const openaiOptions = (0, import_provider_utils9.parseProviderOptions)({
1885
1992
  provider: "openai",
1886
1993
  providerOptions,
1887
1994
  schema: openaiResponsesProviderOptionsSchema
@@ -1956,100 +2063,109 @@ var OpenAIResponsesLanguageModel = class {
1956
2063
  };
1957
2064
  }
1958
2065
  async doGenerate(options) {
1959
- var _a, _b, _c, _d, _e;
2066
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1960
2067
  const { args: body, warnings } = this.getArgs(options);
1961
2068
  const {
1962
2069
  responseHeaders,
1963
2070
  value: response,
1964
2071
  rawValue: rawResponse
1965
- } = await (0, import_provider_utils8.postJsonToApi)({
2072
+ } = await (0, import_provider_utils9.postJsonToApi)({
1966
2073
  url: this.config.url({
1967
2074
  path: "/responses",
1968
2075
  modelId: this.modelId
1969
2076
  }),
1970
- headers: (0, import_provider_utils8.combineHeaders)(this.config.headers(), options.headers),
2077
+ headers: (0, import_provider_utils9.combineHeaders)(this.config.headers(), options.headers),
1971
2078
  body,
1972
2079
  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()
2080
+ successfulResponseHandler: (0, import_provider_utils9.createJsonResponseHandler)(
2081
+ import_zod9.z.object({
2082
+ id: import_zod9.z.string(),
2083
+ created_at: import_zod9.z.number(),
2084
+ model: import_zod9.z.string(),
2085
+ output: import_zod9.z.array(
2086
+ import_zod9.z.discriminatedUnion("type", [
2087
+ import_zod9.z.object({
2088
+ type: import_zod9.z.literal("message"),
2089
+ role: import_zod9.z.literal("assistant"),
2090
+ content: import_zod9.z.array(
2091
+ import_zod9.z.object({
2092
+ type: import_zod9.z.literal("output_text"),
2093
+ text: import_zod9.z.string(),
2094
+ annotations: import_zod9.z.array(
2095
+ import_zod9.z.object({
2096
+ type: import_zod9.z.literal("url_citation"),
2097
+ start_index: import_zod9.z.number(),
2098
+ end_index: import_zod9.z.number(),
2099
+ url: import_zod9.z.string(),
2100
+ title: import_zod9.z.string()
1994
2101
  })
1995
2102
  )
1996
2103
  })
1997
2104
  )
1998
2105
  }),
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()
2106
+ import_zod9.z.object({
2107
+ type: import_zod9.z.literal("function_call"),
2108
+ call_id: import_zod9.z.string(),
2109
+ name: import_zod9.z.string(),
2110
+ arguments: import_zod9.z.string()
2004
2111
  }),
2005
- import_zod8.z.object({
2006
- type: import_zod8.z.literal("web_search_call")
2112
+ import_zod9.z.object({
2113
+ type: import_zod9.z.literal("web_search_call")
2007
2114
  }),
2008
- import_zod8.z.object({
2009
- type: import_zod8.z.literal("computer_call")
2115
+ import_zod9.z.object({
2116
+ type: import_zod9.z.literal("computer_call")
2010
2117
  }),
2011
- import_zod8.z.object({
2012
- type: import_zod8.z.literal("reasoning")
2118
+ import_zod9.z.object({
2119
+ type: import_zod9.z.literal("reasoning")
2013
2120
  })
2014
2121
  ])
2015
2122
  ),
2016
- incomplete_details: import_zod8.z.object({ reason: import_zod8.z.string() }).nullable(),
2123
+ incomplete_details: import_zod9.z.object({ reason: import_zod9.z.string() }).nullable(),
2017
2124
  usage: usageSchema
2018
2125
  })
2019
2126
  ),
2020
2127
  abortSignal: options.abortSignal,
2021
2128
  fetch: this.config.fetch
2022
2129
  });
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
- }));
2130
+ const content = [];
2131
+ for (const part of response.output) {
2132
+ switch (part.type) {
2133
+ case "message": {
2134
+ for (const contentPart of part.content) {
2135
+ content.push({
2136
+ type: "text",
2137
+ text: contentPart.text
2138
+ });
2139
+ for (const annotation of contentPart.annotations) {
2140
+ content.push({
2141
+ type: "source",
2142
+ sourceType: "url",
2143
+ id: (_c = (_b = (_a = this.config).generateId) == null ? void 0 : _b.call(_a)) != null ? _c : (0, import_provider_utils9.generateId)(),
2144
+ url: annotation.url,
2145
+ title: annotation.title
2146
+ });
2147
+ }
2148
+ }
2149
+ break;
2150
+ }
2151
+ case "function_call": {
2152
+ content.push({
2153
+ type: "tool-call",
2154
+ toolCallType: "function",
2155
+ toolCallId: part.call_id,
2156
+ toolName: part.name,
2157
+ args: part.arguments
2158
+ });
2159
+ break;
2160
+ }
2161
+ }
2162
+ }
2031
2163
  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
- ),
2164
+ content,
2048
2165
  finishReason: mapOpenAIResponseFinishReason({
2049
- finishReason: (_a = response.incomplete_details) == null ? void 0 : _a.reason,
2050
- hasToolCalls: toolCalls.length > 0
2166
+ finishReason: (_d = response.incomplete_details) == null ? void 0 : _d.reason,
2167
+ hasToolCalls: content.some((part) => part.type === "tool-call")
2051
2168
  }),
2052
- toolCalls: toolCalls.length > 0 ? toolCalls : void 0,
2053
2169
  usage: {
2054
2170
  inputTokens: response.usage.input_tokens,
2055
2171
  outputTokens: response.usage.output_tokens
@@ -2065,8 +2181,8 @@ var OpenAIResponsesLanguageModel = class {
2065
2181
  providerMetadata: {
2066
2182
  openai: {
2067
2183
  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
2184
+ cachedPromptTokens: (_f = (_e = response.usage.input_tokens_details) == null ? void 0 : _e.cached_tokens) != null ? _f : null,
2185
+ reasoningTokens: (_h = (_g = response.usage.output_tokens_details) == null ? void 0 : _g.reasoning_tokens) != null ? _h : null
2070
2186
  }
2071
2187
  },
2072
2188
  warnings
@@ -2074,18 +2190,18 @@ var OpenAIResponsesLanguageModel = class {
2074
2190
  }
2075
2191
  async doStream(options) {
2076
2192
  const { args: body, warnings } = this.getArgs(options);
2077
- const { responseHeaders, value: response } = await (0, import_provider_utils8.postJsonToApi)({
2193
+ const { responseHeaders, value: response } = await (0, import_provider_utils9.postJsonToApi)({
2078
2194
  url: this.config.url({
2079
2195
  path: "/responses",
2080
2196
  modelId: this.modelId
2081
2197
  }),
2082
- headers: (0, import_provider_utils8.combineHeaders)(this.config.headers(), options.headers),
2198
+ headers: (0, import_provider_utils9.combineHeaders)(this.config.headers(), options.headers),
2083
2199
  body: {
2084
2200
  ...body,
2085
2201
  stream: true
2086
2202
  },
2087
2203
  failedResponseHandler: openaiFailedResponseHandler,
2088
- successfulResponseHandler: (0, import_provider_utils8.createEventSourceResponseHandler)(
2204
+ successfulResponseHandler: (0, import_provider_utils9.createEventSourceResponseHandler)(
2089
2205
  openaiResponsesChunkSchema
2090
2206
  ),
2091
2207
  abortSignal: options.abortSignal,
@@ -2105,6 +2221,9 @@ var OpenAIResponsesLanguageModel = class {
2105
2221
  return {
2106
2222
  stream: response.pipeThrough(
2107
2223
  new TransformStream({
2224
+ start(controller) {
2225
+ controller.enqueue({ type: "stream-start", warnings });
2226
+ },
2108
2227
  transform(chunk, controller) {
2109
2228
  var _a, _b, _c, _d, _e, _f, _g, _h;
2110
2229
  if (!chunk.success) {
@@ -2174,7 +2293,7 @@ var OpenAIResponsesLanguageModel = class {
2174
2293
  controller.enqueue({
2175
2294
  type: "source",
2176
2295
  sourceType: "url",
2177
- id: (_h = (_g = (_f = self.config).generateId) == null ? void 0 : _g.call(_f)) != null ? _h : (0, import_provider_utils8.generateId)(),
2296
+ id: (_h = (_g = (_f = self.config).generateId) == null ? void 0 : _g.call(_f)) != null ? _h : (0, import_provider_utils9.generateId)(),
2178
2297
  url: value.annotation.url,
2179
2298
  title: value.annotation.title
2180
2299
  });
@@ -2199,84 +2318,83 @@ var OpenAIResponsesLanguageModel = class {
2199
2318
  })
2200
2319
  ),
2201
2320
  request: { body },
2202
- response: { headers: responseHeaders },
2203
- warnings
2321
+ response: { headers: responseHeaders }
2204
2322
  };
2205
2323
  }
2206
2324
  };
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()
2325
+ var usageSchema = import_zod9.z.object({
2326
+ input_tokens: import_zod9.z.number(),
2327
+ input_tokens_details: import_zod9.z.object({ cached_tokens: import_zod9.z.number().nullish() }).nullish(),
2328
+ output_tokens: import_zod9.z.number(),
2329
+ output_tokens_details: import_zod9.z.object({ reasoning_tokens: import_zod9.z.number().nullish() }).nullish()
2212
2330
  });
2213
- var textDeltaChunkSchema = import_zod8.z.object({
2214
- type: import_zod8.z.literal("response.output_text.delta"),
2215
- delta: import_zod8.z.string()
2331
+ var textDeltaChunkSchema = import_zod9.z.object({
2332
+ type: import_zod9.z.literal("response.output_text.delta"),
2333
+ delta: import_zod9.z.string()
2216
2334
  });
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(),
2335
+ var responseFinishedChunkSchema = import_zod9.z.object({
2336
+ type: import_zod9.z.enum(["response.completed", "response.incomplete"]),
2337
+ response: import_zod9.z.object({
2338
+ incomplete_details: import_zod9.z.object({ reason: import_zod9.z.string() }).nullish(),
2221
2339
  usage: usageSchema
2222
2340
  })
2223
2341
  });
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()
2342
+ var responseCreatedChunkSchema = import_zod9.z.object({
2343
+ type: import_zod9.z.literal("response.created"),
2344
+ response: import_zod9.z.object({
2345
+ id: import_zod9.z.string(),
2346
+ created_at: import_zod9.z.number(),
2347
+ model: import_zod9.z.string()
2230
2348
  })
2231
2349
  });
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")
2350
+ var responseOutputItemDoneSchema = import_zod9.z.object({
2351
+ type: import_zod9.z.literal("response.output_item.done"),
2352
+ output_index: import_zod9.z.number(),
2353
+ item: import_zod9.z.discriminatedUnion("type", [
2354
+ import_zod9.z.object({
2355
+ type: import_zod9.z.literal("message")
2238
2356
  }),
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")
2357
+ import_zod9.z.object({
2358
+ type: import_zod9.z.literal("function_call"),
2359
+ id: import_zod9.z.string(),
2360
+ call_id: import_zod9.z.string(),
2361
+ name: import_zod9.z.string(),
2362
+ arguments: import_zod9.z.string(),
2363
+ status: import_zod9.z.literal("completed")
2246
2364
  })
2247
2365
  ])
2248
2366
  });
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()
2367
+ var responseFunctionCallArgumentsDeltaSchema = import_zod9.z.object({
2368
+ type: import_zod9.z.literal("response.function_call_arguments.delta"),
2369
+ item_id: import_zod9.z.string(),
2370
+ output_index: import_zod9.z.number(),
2371
+ delta: import_zod9.z.string()
2254
2372
  });
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")
2373
+ var responseOutputItemAddedSchema = import_zod9.z.object({
2374
+ type: import_zod9.z.literal("response.output_item.added"),
2375
+ output_index: import_zod9.z.number(),
2376
+ item: import_zod9.z.discriminatedUnion("type", [
2377
+ import_zod9.z.object({
2378
+ type: import_zod9.z.literal("message")
2261
2379
  }),
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()
2380
+ import_zod9.z.object({
2381
+ type: import_zod9.z.literal("function_call"),
2382
+ id: import_zod9.z.string(),
2383
+ call_id: import_zod9.z.string(),
2384
+ name: import_zod9.z.string(),
2385
+ arguments: import_zod9.z.string()
2268
2386
  })
2269
2387
  ])
2270
2388
  });
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()
2389
+ var responseAnnotationAddedSchema = import_zod9.z.object({
2390
+ type: import_zod9.z.literal("response.output_text.annotation.added"),
2391
+ annotation: import_zod9.z.object({
2392
+ type: import_zod9.z.literal("url_citation"),
2393
+ url: import_zod9.z.string(),
2394
+ title: import_zod9.z.string()
2277
2395
  })
2278
2396
  });
2279
- var openaiResponsesChunkSchema = import_zod8.z.union([
2397
+ var openaiResponsesChunkSchema = import_zod9.z.union([
2280
2398
  textDeltaChunkSchema,
2281
2399
  responseFinishedChunkSchema,
2282
2400
  responseCreatedChunkSchema,
@@ -2284,7 +2402,7 @@ var openaiResponsesChunkSchema = import_zod8.z.union([
2284
2402
  responseFunctionCallArgumentsDeltaSchema,
2285
2403
  responseOutputItemAddedSchema,
2286
2404
  responseAnnotationAddedSchema,
2287
- import_zod8.z.object({ type: import_zod8.z.string() }).passthrough()
2405
+ import_zod9.z.object({ type: import_zod9.z.string() }).passthrough()
2288
2406
  // fallback for unknown chunks
2289
2407
  ]);
2290
2408
  function isTextDeltaChunk(chunk) {
@@ -2329,15 +2447,15 @@ function getResponsesModelConfig(modelId) {
2329
2447
  requiredAutoTruncation: false
2330
2448
  };
2331
2449
  }
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()
2450
+ var openaiResponsesProviderOptionsSchema = import_zod9.z.object({
2451
+ metadata: import_zod9.z.any().nullish(),
2452
+ parallelToolCalls: import_zod9.z.boolean().nullish(),
2453
+ previousResponseId: import_zod9.z.string().nullish(),
2454
+ store: import_zod9.z.boolean().nullish(),
2455
+ user: import_zod9.z.string().nullish(),
2456
+ reasoningEffort: import_zod9.z.string().nullish(),
2457
+ strictSchemas: import_zod9.z.boolean().nullish(),
2458
+ instructions: import_zod9.z.string().nullish()
2341
2459
  });
2342
2460
  // Annotate the CommonJS export names for ESM import in node:
2343
2461
  0 && (module.exports = {
@@ -2346,6 +2464,7 @@ var openaiResponsesProviderOptionsSchema = import_zod8.z.object({
2346
2464
  OpenAIEmbeddingModel,
2347
2465
  OpenAIImageModel,
2348
2466
  OpenAIResponsesLanguageModel,
2467
+ OpenAISpeechModel,
2349
2468
  OpenAITranscriptionModel,
2350
2469
  modelMaxImagesPerCall,
2351
2470
  openaiProviderOptions