@ai-sdk/openai 2.0.30 → 2.0.31

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.js CHANGED
@@ -26,7 +26,7 @@ __export(src_exports, {
26
26
  module.exports = __toCommonJS(src_exports);
27
27
 
28
28
  // src/openai-provider.ts
29
- var import_provider_utils15 = require("@ai-sdk/provider-utils");
29
+ var import_provider_utils16 = require("@ai-sdk/provider-utils");
30
30
 
31
31
  // src/chat/openai-chat-language-model.ts
32
32
  var import_provider3 = require("@ai-sdk/provider");
@@ -1829,39 +1829,69 @@ var codeInterpreter = (args = {}) => {
1829
1829
  return codeInterpreterToolFactory(args);
1830
1830
  };
1831
1831
 
1832
- // src/tool/web-search.ts
1832
+ // src/tool/image-generation.ts
1833
1833
  var import_provider_utils10 = require("@ai-sdk/provider-utils");
1834
1834
  var import_v412 = require("zod/v4");
1835
- var webSearchArgsSchema = import_v412.z.object({
1836
- filters: import_v412.z.object({
1837
- allowedDomains: import_v412.z.array(import_v412.z.string()).optional()
1835
+ var imageGenerationArgsSchema = import_v412.z.object({
1836
+ background: import_v412.z.enum(["auto", "opaque", "transparent"]).optional(),
1837
+ inputFidelity: import_v412.z.enum(["low", "high"]).optional(),
1838
+ inputImageMask: import_v412.z.object({
1839
+ fileId: import_v412.z.string().optional(),
1840
+ imageUrl: import_v412.z.string().optional()
1841
+ }).optional(),
1842
+ model: import_v412.z.string().optional(),
1843
+ moderation: import_v412.z.enum(["auto"]).optional(),
1844
+ outputCompression: import_v412.z.number().int().min(0).max(100).optional(),
1845
+ outputFormat: import_v412.z.enum(["png", "jpeg", "webp"]).optional(),
1846
+ quality: import_v412.z.enum(["auto", "low", "medium", "high"]).optional(),
1847
+ size: import_v412.z.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
1848
+ }).strict();
1849
+ var imageGenerationOutputSchema = import_v412.z.object({
1850
+ result: import_v412.z.string()
1851
+ });
1852
+ var imageGenerationToolFactory = (0, import_provider_utils10.createProviderDefinedToolFactoryWithOutputSchema)({
1853
+ id: "openai.image_generation",
1854
+ name: "image_generation",
1855
+ inputSchema: import_v412.z.object({}),
1856
+ outputSchema: imageGenerationOutputSchema
1857
+ });
1858
+ var imageGeneration = (args = {}) => {
1859
+ return imageGenerationToolFactory(args);
1860
+ };
1861
+
1862
+ // src/tool/web-search.ts
1863
+ var import_provider_utils11 = require("@ai-sdk/provider-utils");
1864
+ var import_v413 = require("zod/v4");
1865
+ var webSearchArgsSchema = import_v413.z.object({
1866
+ filters: import_v413.z.object({
1867
+ allowedDomains: import_v413.z.array(import_v413.z.string()).optional()
1838
1868
  }).optional(),
1839
- searchContextSize: import_v412.z.enum(["low", "medium", "high"]).optional(),
1840
- userLocation: import_v412.z.object({
1841
- type: import_v412.z.literal("approximate"),
1842
- country: import_v412.z.string().optional(),
1843
- city: import_v412.z.string().optional(),
1844
- region: import_v412.z.string().optional(),
1845
- timezone: import_v412.z.string().optional()
1869
+ searchContextSize: import_v413.z.enum(["low", "medium", "high"]).optional(),
1870
+ userLocation: import_v413.z.object({
1871
+ type: import_v413.z.literal("approximate"),
1872
+ country: import_v413.z.string().optional(),
1873
+ city: import_v413.z.string().optional(),
1874
+ region: import_v413.z.string().optional(),
1875
+ timezone: import_v413.z.string().optional()
1846
1876
  }).optional()
1847
1877
  });
1848
- var webSearchToolFactory = (0, import_provider_utils10.createProviderDefinedToolFactory)({
1878
+ var webSearchToolFactory = (0, import_provider_utils11.createProviderDefinedToolFactory)({
1849
1879
  id: "openai.web_search",
1850
1880
  name: "web_search",
1851
- inputSchema: import_v412.z.object({
1852
- action: import_v412.z.discriminatedUnion("type", [
1853
- import_v412.z.object({
1854
- type: import_v412.z.literal("search"),
1855
- query: import_v412.z.string().nullish()
1881
+ inputSchema: import_v413.z.object({
1882
+ action: import_v413.z.discriminatedUnion("type", [
1883
+ import_v413.z.object({
1884
+ type: import_v413.z.literal("search"),
1885
+ query: import_v413.z.string().nullish()
1856
1886
  }),
1857
- import_v412.z.object({
1858
- type: import_v412.z.literal("open_page"),
1859
- url: import_v412.z.string()
1887
+ import_v413.z.object({
1888
+ type: import_v413.z.literal("open_page"),
1889
+ url: import_v413.z.string()
1860
1890
  }),
1861
- import_v412.z.object({
1862
- type: import_v412.z.literal("find"),
1863
- url: import_v412.z.string(),
1864
- pattern: import_v412.z.string()
1891
+ import_v413.z.object({
1892
+ type: import_v413.z.literal("find"),
1893
+ url: import_v413.z.string(),
1894
+ pattern: import_v413.z.string()
1865
1895
  })
1866
1896
  ]).nullish()
1867
1897
  })
@@ -1895,6 +1925,20 @@ var openaiTools = {
1895
1925
  * @param filters - The filters to use for the file search.
1896
1926
  */
1897
1927
  fileSearch,
1928
+ /**
1929
+ * The image generation tool allows you to generate images using a text prompt,
1930
+ * and optionally image inputs. It leverages the GPT Image model,
1931
+ * and automatically optimizes text inputs for improved performance.
1932
+ *
1933
+ * Must have name `image_generation`.
1934
+ *
1935
+ * @param size - Image dimensions (e.g., 1024x1024, 1024x1536)
1936
+ * @param quality - Rendering quality (e.g. low, medium, high)
1937
+ * @param format - File output format
1938
+ * @param compression - Compression level (0-100%) for JPEG and WebP formats
1939
+ * @param background - Transparent or opaque
1940
+ */
1941
+ imageGeneration,
1898
1942
  /**
1899
1943
  * Web search allows models to access up-to-date information from the internet
1900
1944
  * and provide answers with sourced citations.
@@ -1922,13 +1966,13 @@ var openaiTools = {
1922
1966
 
1923
1967
  // src/responses/openai-responses-language-model.ts
1924
1968
  var import_provider8 = require("@ai-sdk/provider");
1925
- var import_provider_utils12 = require("@ai-sdk/provider-utils");
1926
- var import_v414 = require("zod/v4");
1969
+ var import_provider_utils13 = require("@ai-sdk/provider-utils");
1970
+ var import_v415 = require("zod/v4");
1927
1971
 
1928
1972
  // src/responses/convert-to-openai-responses-input.ts
1929
1973
  var import_provider6 = require("@ai-sdk/provider");
1930
- var import_provider_utils11 = require("@ai-sdk/provider-utils");
1931
- var import_v413 = require("zod/v4");
1974
+ var import_provider_utils12 = require("@ai-sdk/provider-utils");
1975
+ var import_v414 = require("zod/v4");
1932
1976
  function isFileId(data, prefixes) {
1933
1977
  if (!prefixes) return false;
1934
1978
  return prefixes.some((prefix) => data.startsWith(prefix));
@@ -1936,7 +1980,8 @@ function isFileId(data, prefixes) {
1936
1980
  async function convertToOpenAIResponsesInput({
1937
1981
  prompt,
1938
1982
  systemMessageMode,
1939
- fileIdPrefixes
1983
+ fileIdPrefixes,
1984
+ store
1940
1985
  }) {
1941
1986
  var _a, _b, _c, _d, _e, _f;
1942
1987
  const input = [];
@@ -1984,7 +2029,7 @@ async function convertToOpenAIResponsesInput({
1984
2029
  return {
1985
2030
  type: "input_image",
1986
2031
  ...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
1987
- image_url: `data:${mediaType};base64,${(0, import_provider_utils11.convertToBase64)(part.data)}`
2032
+ image_url: `data:${mediaType};base64,${(0, import_provider_utils12.convertToBase64)(part.data)}`
1988
2033
  },
1989
2034
  detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b2.imageDetail
1990
2035
  };
@@ -1999,7 +2044,7 @@ async function convertToOpenAIResponsesInput({
1999
2044
  type: "input_file",
2000
2045
  ...typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
2001
2046
  filename: (_c2 = part.filename) != null ? _c2 : `part-${index}.pdf`,
2002
- file_data: `data:application/pdf;base64,${(0, import_provider_utils11.convertToBase64)(part.data)}`
2047
+ file_data: `data:application/pdf;base64,${(0, import_provider_utils12.convertToBase64)(part.data)}`
2003
2048
  }
2004
2049
  };
2005
2050
  } else {
@@ -2041,14 +2086,18 @@ async function convertToOpenAIResponsesInput({
2041
2086
  break;
2042
2087
  }
2043
2088
  case "tool-result": {
2044
- warnings.push({
2045
- type: "other",
2046
- message: `tool result parts in assistant messages are not supported for OpenAI responses`
2047
- });
2089
+ if (store) {
2090
+ input.push({ type: "item_reference", id: part.toolCallId });
2091
+ } else {
2092
+ warnings.push({
2093
+ type: "other",
2094
+ message: `Results for OpenAI tool ${part.toolName} are not sent to the API when store is false`
2095
+ });
2096
+ }
2048
2097
  break;
2049
2098
  }
2050
2099
  case "reasoning": {
2051
- const providerOptions = await (0, import_provider_utils11.parseProviderOptions)({
2100
+ const providerOptions = await (0, import_provider_utils12.parseProviderOptions)({
2052
2101
  provider: "openai",
2053
2102
  providerOptions: part.providerOptions,
2054
2103
  schema: openaiResponsesReasoningProviderOptionsSchema
@@ -2119,9 +2168,9 @@ async function convertToOpenAIResponsesInput({
2119
2168
  }
2120
2169
  return { input, warnings };
2121
2170
  }
2122
- var openaiResponsesReasoningProviderOptionsSchema = import_v413.z.object({
2123
- itemId: import_v413.z.string().nullish(),
2124
- reasoningEncryptedContent: import_v413.z.string().nullish()
2171
+ var openaiResponsesReasoningProviderOptionsSchema = import_v414.z.object({
2172
+ itemId: import_v414.z.string().nullish(),
2173
+ reasoningEncryptedContent: import_v414.z.string().nullish()
2125
2174
  });
2126
2175
 
2127
2176
  // src/responses/map-openai-responses-finish-reason.ts
@@ -2206,8 +2255,23 @@ function prepareResponsesTools({
2206
2255
  });
2207
2256
  break;
2208
2257
  }
2209
- default: {
2210
- toolWarnings.push({ type: "unsupported-tool", tool });
2258
+ case "openai.image_generation": {
2259
+ const args = imageGenerationArgsSchema.parse(tool.args);
2260
+ openaiTools2.push({
2261
+ type: "image_generation",
2262
+ background: args.background,
2263
+ input_fidelity: args.inputFidelity,
2264
+ input_image_mask: args.inputImageMask ? {
2265
+ file_id: args.inputImageMask.fileId,
2266
+ image_url: args.inputImageMask.imageUrl
2267
+ } : void 0,
2268
+ model: args.model,
2269
+ size: args.size,
2270
+ quality: args.quality,
2271
+ moderation: args.moderation,
2272
+ output_format: args.outputFormat,
2273
+ output_compression: args.outputCompression
2274
+ });
2211
2275
  break;
2212
2276
  }
2213
2277
  }
@@ -2230,7 +2294,7 @@ function prepareResponsesTools({
2230
2294
  case "tool":
2231
2295
  return {
2232
2296
  tools: openaiTools2,
2233
- toolChoice: toolChoice.toolName === "code_interpreter" || toolChoice.toolName === "file_search" || toolChoice.toolName === "web_search_preview" || toolChoice.toolName === "web_search" ? { type: toolChoice.toolName } : { type: "function", name: toolChoice.toolName },
2297
+ toolChoice: toolChoice.toolName === "code_interpreter" || toolChoice.toolName === "file_search" || toolChoice.toolName === "image_generation" || toolChoice.toolName === "web_search_preview" || toolChoice.toolName === "web_search" ? { type: toolChoice.toolName } : { type: "function", name: toolChoice.toolName },
2234
2298
  toolWarnings
2235
2299
  };
2236
2300
  default: {
@@ -2243,47 +2307,52 @@ function prepareResponsesTools({
2243
2307
  }
2244
2308
 
2245
2309
  // src/responses/openai-responses-language-model.ts
2246
- var webSearchCallItem = import_v414.z.object({
2247
- type: import_v414.z.literal("web_search_call"),
2248
- id: import_v414.z.string(),
2249
- status: import_v414.z.string(),
2250
- action: import_v414.z.discriminatedUnion("type", [
2251
- import_v414.z.object({
2252
- type: import_v414.z.literal("search"),
2253
- query: import_v414.z.string().nullish()
2310
+ var webSearchCallItem = import_v415.z.object({
2311
+ type: import_v415.z.literal("web_search_call"),
2312
+ id: import_v415.z.string(),
2313
+ status: import_v415.z.string(),
2314
+ action: import_v415.z.discriminatedUnion("type", [
2315
+ import_v415.z.object({
2316
+ type: import_v415.z.literal("search"),
2317
+ query: import_v415.z.string().nullish()
2254
2318
  }),
2255
- import_v414.z.object({
2256
- type: import_v414.z.literal("open_page"),
2257
- url: import_v414.z.string()
2319
+ import_v415.z.object({
2320
+ type: import_v415.z.literal("open_page"),
2321
+ url: import_v415.z.string()
2258
2322
  }),
2259
- import_v414.z.object({
2260
- type: import_v414.z.literal("find"),
2261
- url: import_v414.z.string(),
2262
- pattern: import_v414.z.string()
2323
+ import_v415.z.object({
2324
+ type: import_v415.z.literal("find"),
2325
+ url: import_v415.z.string(),
2326
+ pattern: import_v415.z.string()
2263
2327
  })
2264
2328
  ]).nullish()
2265
2329
  });
2266
- var codeInterpreterCallItem = import_v414.z.object({
2267
- type: import_v414.z.literal("code_interpreter_call"),
2268
- id: import_v414.z.string(),
2269
- code: import_v414.z.string().nullable(),
2270
- container_id: import_v414.z.string(),
2271
- outputs: import_v414.z.array(
2272
- import_v414.z.discriminatedUnion("type", [
2273
- import_v414.z.object({ type: import_v414.z.literal("logs"), logs: import_v414.z.string() }),
2274
- import_v414.z.object({ type: import_v414.z.literal("image"), url: import_v414.z.string() })
2330
+ var codeInterpreterCallItem = import_v415.z.object({
2331
+ type: import_v415.z.literal("code_interpreter_call"),
2332
+ id: import_v415.z.string(),
2333
+ code: import_v415.z.string().nullable(),
2334
+ container_id: import_v415.z.string(),
2335
+ outputs: import_v415.z.array(
2336
+ import_v415.z.discriminatedUnion("type", [
2337
+ import_v415.z.object({ type: import_v415.z.literal("logs"), logs: import_v415.z.string() }),
2338
+ import_v415.z.object({ type: import_v415.z.literal("image"), url: import_v415.z.string() })
2275
2339
  ])
2276
2340
  ).nullable()
2277
2341
  });
2342
+ var imageGenerationCallItem = import_v415.z.object({
2343
+ type: import_v415.z.literal("image_generation_call"),
2344
+ id: import_v415.z.string(),
2345
+ result: import_v415.z.string()
2346
+ });
2278
2347
  var TOP_LOGPROBS_MAX = 20;
2279
- var LOGPROBS_SCHEMA = import_v414.z.array(
2280
- import_v414.z.object({
2281
- token: import_v414.z.string(),
2282
- logprob: import_v414.z.number(),
2283
- top_logprobs: import_v414.z.array(
2284
- import_v414.z.object({
2285
- token: import_v414.z.string(),
2286
- logprob: import_v414.z.number()
2348
+ var LOGPROBS_SCHEMA = import_v415.z.array(
2349
+ import_v415.z.object({
2350
+ token: import_v415.z.string(),
2351
+ logprob: import_v415.z.number(),
2352
+ top_logprobs: import_v415.z.array(
2353
+ import_v415.z.object({
2354
+ token: import_v415.z.string(),
2355
+ logprob: import_v415.z.number()
2287
2356
  })
2288
2357
  )
2289
2358
  })
@@ -2316,7 +2385,7 @@ var OpenAIResponsesLanguageModel = class {
2316
2385
  toolChoice,
2317
2386
  responseFormat
2318
2387
  }) {
2319
- var _a, _b, _c, _d;
2388
+ var _a, _b, _c, _d, _e;
2320
2389
  const warnings = [];
2321
2390
  const modelConfig = getResponsesModelConfig(this.modelId);
2322
2391
  if (topK != null) {
@@ -2340,28 +2409,29 @@ var OpenAIResponsesLanguageModel = class {
2340
2409
  if (stopSequences != null) {
2341
2410
  warnings.push({ type: "unsupported-setting", setting: "stopSequences" });
2342
2411
  }
2412
+ const openaiOptions = await (0, import_provider_utils13.parseProviderOptions)({
2413
+ provider: "openai",
2414
+ providerOptions,
2415
+ schema: openaiResponsesProviderOptionsSchema
2416
+ });
2343
2417
  const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
2344
2418
  prompt,
2345
2419
  systemMessageMode: modelConfig.systemMessageMode,
2346
- fileIdPrefixes: this.config.fileIdPrefixes
2420
+ fileIdPrefixes: this.config.fileIdPrefixes,
2421
+ store: (_a = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _a : true
2347
2422
  });
2348
2423
  warnings.push(...inputWarnings);
2349
- const openaiOptions = await (0, import_provider_utils12.parseProviderOptions)({
2350
- provider: "openai",
2351
- providerOptions,
2352
- schema: openaiResponsesProviderOptionsSchema
2353
- });
2354
- const strictJsonSchema = (_a = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _a : false;
2424
+ const strictJsonSchema = (_b = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _b : false;
2355
2425
  let include = openaiOptions == null ? void 0 : openaiOptions.include;
2356
2426
  const topLogprobs = typeof (openaiOptions == null ? void 0 : openaiOptions.logprobs) === "number" ? openaiOptions == null ? void 0 : openaiOptions.logprobs : (openaiOptions == null ? void 0 : openaiOptions.logprobs) === true ? TOP_LOGPROBS_MAX : void 0;
2357
2427
  include = topLogprobs ? Array.isArray(include) ? [...include, "message.output_text.logprobs"] : ["message.output_text.logprobs"] : include;
2358
- const webSearchToolName = (_b = tools == null ? void 0 : tools.find(
2428
+ const webSearchToolName = (_c = tools == null ? void 0 : tools.find(
2359
2429
  (tool) => tool.type === "provider-defined" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
2360
- )) == null ? void 0 : _b.name;
2430
+ )) == null ? void 0 : _c.name;
2361
2431
  include = webSearchToolName ? Array.isArray(include) ? [...include, "web_search_call.action.sources"] : ["web_search_call.action.sources"] : include;
2362
- const codeInterpreterToolName = (_c = tools == null ? void 0 : tools.find(
2432
+ const codeInterpreterToolName = (_d = tools == null ? void 0 : tools.find(
2363
2433
  (tool) => tool.type === "provider-defined" && tool.id === "openai.code_interpreter"
2364
- )) == null ? void 0 : _c.name;
2434
+ )) == null ? void 0 : _d.name;
2365
2435
  include = codeInterpreterToolName ? Array.isArray(include) ? [...include, "code_interpreter_call.outputs"] : ["code_interpreter_call.outputs"] : include;
2366
2436
  const baseArgs = {
2367
2437
  model: this.modelId,
@@ -2375,7 +2445,7 @@ var OpenAIResponsesLanguageModel = class {
2375
2445
  format: responseFormat.schema != null ? {
2376
2446
  type: "json_schema",
2377
2447
  strict: strictJsonSchema,
2378
- name: (_d = responseFormat.name) != null ? _d : "response",
2448
+ name: (_e = responseFormat.name) != null ? _e : "response",
2379
2449
  description: responseFormat.description,
2380
2450
  schema: responseFormat.schema
2381
2451
  } : { type: "json_object" }
@@ -2386,6 +2456,7 @@ var OpenAIResponsesLanguageModel = class {
2386
2456
  }
2387
2457
  },
2388
2458
  // provider options:
2459
+ max_tool_calls: openaiOptions == null ? void 0 : openaiOptions.maxToolCalls,
2389
2460
  metadata: openaiOptions == null ? void 0 : openaiOptions.metadata,
2390
2461
  parallel_tool_calls: openaiOptions == null ? void 0 : openaiOptions.parallelToolCalls,
2391
2462
  previous_response_id: openaiOptions == null ? void 0 : openaiOptions.previousResponseId,
@@ -2495,51 +2566,51 @@ var OpenAIResponsesLanguageModel = class {
2495
2566
  responseHeaders,
2496
2567
  value: response,
2497
2568
  rawValue: rawResponse
2498
- } = await (0, import_provider_utils12.postJsonToApi)({
2569
+ } = await (0, import_provider_utils13.postJsonToApi)({
2499
2570
  url,
2500
- headers: (0, import_provider_utils12.combineHeaders)(this.config.headers(), options.headers),
2571
+ headers: (0, import_provider_utils13.combineHeaders)(this.config.headers(), options.headers),
2501
2572
  body,
2502
2573
  failedResponseHandler: openaiFailedResponseHandler,
2503
- successfulResponseHandler: (0, import_provider_utils12.createJsonResponseHandler)(
2504
- import_v414.z.object({
2505
- id: import_v414.z.string(),
2506
- created_at: import_v414.z.number(),
2507
- error: import_v414.z.object({
2508
- code: import_v414.z.string(),
2509
- message: import_v414.z.string()
2574
+ successfulResponseHandler: (0, import_provider_utils13.createJsonResponseHandler)(
2575
+ import_v415.z.object({
2576
+ id: import_v415.z.string(),
2577
+ created_at: import_v415.z.number(),
2578
+ error: import_v415.z.object({
2579
+ code: import_v415.z.string(),
2580
+ message: import_v415.z.string()
2510
2581
  }).nullish(),
2511
- model: import_v414.z.string(),
2512
- output: import_v414.z.array(
2513
- import_v414.z.discriminatedUnion("type", [
2514
- import_v414.z.object({
2515
- type: import_v414.z.literal("message"),
2516
- role: import_v414.z.literal("assistant"),
2517
- id: import_v414.z.string(),
2518
- content: import_v414.z.array(
2519
- import_v414.z.object({
2520
- type: import_v414.z.literal("output_text"),
2521
- text: import_v414.z.string(),
2582
+ model: import_v415.z.string(),
2583
+ output: import_v415.z.array(
2584
+ import_v415.z.discriminatedUnion("type", [
2585
+ import_v415.z.object({
2586
+ type: import_v415.z.literal("message"),
2587
+ role: import_v415.z.literal("assistant"),
2588
+ id: import_v415.z.string(),
2589
+ content: import_v415.z.array(
2590
+ import_v415.z.object({
2591
+ type: import_v415.z.literal("output_text"),
2592
+ text: import_v415.z.string(),
2522
2593
  logprobs: LOGPROBS_SCHEMA.nullish(),
2523
- annotations: import_v414.z.array(
2524
- import_v414.z.discriminatedUnion("type", [
2525
- import_v414.z.object({
2526
- type: import_v414.z.literal("url_citation"),
2527
- start_index: import_v414.z.number(),
2528
- end_index: import_v414.z.number(),
2529
- url: import_v414.z.string(),
2530
- title: import_v414.z.string()
2594
+ annotations: import_v415.z.array(
2595
+ import_v415.z.discriminatedUnion("type", [
2596
+ import_v415.z.object({
2597
+ type: import_v415.z.literal("url_citation"),
2598
+ start_index: import_v415.z.number(),
2599
+ end_index: import_v415.z.number(),
2600
+ url: import_v415.z.string(),
2601
+ title: import_v415.z.string()
2531
2602
  }),
2532
- import_v414.z.object({
2533
- type: import_v414.z.literal("file_citation"),
2534
- file_id: import_v414.z.string(),
2535
- filename: import_v414.z.string().nullish(),
2536
- index: import_v414.z.number().nullish(),
2537
- start_index: import_v414.z.number().nullish(),
2538
- end_index: import_v414.z.number().nullish(),
2539
- quote: import_v414.z.string().nullish()
2603
+ import_v415.z.object({
2604
+ type: import_v415.z.literal("file_citation"),
2605
+ file_id: import_v415.z.string(),
2606
+ filename: import_v415.z.string().nullish(),
2607
+ index: import_v415.z.number().nullish(),
2608
+ start_index: import_v415.z.number().nullish(),
2609
+ end_index: import_v415.z.number().nullish(),
2610
+ quote: import_v415.z.string().nullish()
2540
2611
  }),
2541
- import_v414.z.object({
2542
- type: import_v414.z.literal("container_file_citation")
2612
+ import_v415.z.object({
2613
+ type: import_v415.z.literal("container_file_citation")
2543
2614
  })
2544
2615
  ])
2545
2616
  )
@@ -2547,50 +2618,51 @@ var OpenAIResponsesLanguageModel = class {
2547
2618
  )
2548
2619
  }),
2549
2620
  codeInterpreterCallItem,
2550
- import_v414.z.object({
2551
- type: import_v414.z.literal("function_call"),
2552
- call_id: import_v414.z.string(),
2553
- name: import_v414.z.string(),
2554
- arguments: import_v414.z.string(),
2555
- id: import_v414.z.string()
2621
+ imageGenerationCallItem,
2622
+ import_v415.z.object({
2623
+ type: import_v415.z.literal("function_call"),
2624
+ call_id: import_v415.z.string(),
2625
+ name: import_v415.z.string(),
2626
+ arguments: import_v415.z.string(),
2627
+ id: import_v415.z.string()
2556
2628
  }),
2557
2629
  webSearchCallItem,
2558
- import_v414.z.object({
2559
- type: import_v414.z.literal("computer_call"),
2560
- id: import_v414.z.string(),
2561
- status: import_v414.z.string().optional()
2630
+ import_v415.z.object({
2631
+ type: import_v415.z.literal("computer_call"),
2632
+ id: import_v415.z.string(),
2633
+ status: import_v415.z.string().optional()
2562
2634
  }),
2563
- import_v414.z.object({
2564
- type: import_v414.z.literal("file_search_call"),
2565
- id: import_v414.z.string(),
2566
- status: import_v414.z.string().optional(),
2567
- queries: import_v414.z.array(import_v414.z.string()).nullish(),
2568
- results: import_v414.z.array(
2569
- import_v414.z.object({
2570
- attributes: import_v414.z.object({
2571
- file_id: import_v414.z.string(),
2572
- filename: import_v414.z.string(),
2573
- score: import_v414.z.number(),
2574
- text: import_v414.z.string()
2635
+ import_v415.z.object({
2636
+ type: import_v415.z.literal("file_search_call"),
2637
+ id: import_v415.z.string(),
2638
+ status: import_v415.z.string().optional(),
2639
+ queries: import_v415.z.array(import_v415.z.string()).nullish(),
2640
+ results: import_v415.z.array(
2641
+ import_v415.z.object({
2642
+ attributes: import_v415.z.object({
2643
+ file_id: import_v415.z.string(),
2644
+ filename: import_v415.z.string(),
2645
+ score: import_v415.z.number(),
2646
+ text: import_v415.z.string()
2575
2647
  })
2576
2648
  })
2577
2649
  ).nullish()
2578
2650
  }),
2579
- import_v414.z.object({
2580
- type: import_v414.z.literal("reasoning"),
2581
- id: import_v414.z.string(),
2582
- encrypted_content: import_v414.z.string().nullish(),
2583
- summary: import_v414.z.array(
2584
- import_v414.z.object({
2585
- type: import_v414.z.literal("summary_text"),
2586
- text: import_v414.z.string()
2651
+ import_v415.z.object({
2652
+ type: import_v415.z.literal("reasoning"),
2653
+ id: import_v415.z.string(),
2654
+ encrypted_content: import_v415.z.string().nullish(),
2655
+ summary: import_v415.z.array(
2656
+ import_v415.z.object({
2657
+ type: import_v415.z.literal("summary_text"),
2658
+ text: import_v415.z.string()
2587
2659
  })
2588
2660
  )
2589
2661
  })
2590
2662
  ])
2591
2663
  ),
2592
- service_tier: import_v414.z.string().nullish(),
2593
- incomplete_details: import_v414.z.object({ reason: import_v414.z.string() }).nullable(),
2664
+ service_tier: import_v415.z.string().nullish(),
2665
+ incomplete_details: import_v415.z.object({ reason: import_v415.z.string() }).nullable(),
2594
2666
  usage: usageSchema2
2595
2667
  })
2596
2668
  ),
@@ -2631,6 +2703,25 @@ var OpenAIResponsesLanguageModel = class {
2631
2703
  }
2632
2704
  break;
2633
2705
  }
2706
+ case "image_generation_call": {
2707
+ content.push({
2708
+ type: "tool-call",
2709
+ toolCallId: part.id,
2710
+ toolName: "image_generation",
2711
+ input: "{}",
2712
+ providerExecuted: true
2713
+ });
2714
+ content.push({
2715
+ type: "tool-result",
2716
+ toolCallId: part.id,
2717
+ toolName: "image_generation",
2718
+ result: {
2719
+ result: part.result
2720
+ },
2721
+ providerExecuted: true
2722
+ });
2723
+ break;
2724
+ }
2634
2725
  case "message": {
2635
2726
  for (const contentPart of part.content) {
2636
2727
  if (((_c = (_b = options.providerOptions) == null ? void 0 : _b.openai) == null ? void 0 : _c.logprobs) && contentPart.logprobs) {
@@ -2650,7 +2741,7 @@ var OpenAIResponsesLanguageModel = class {
2650
2741
  content.push({
2651
2742
  type: "source",
2652
2743
  sourceType: "url",
2653
- id: (_f = (_e = (_d = this.config).generateId) == null ? void 0 : _e.call(_d)) != null ? _f : (0, import_provider_utils12.generateId)(),
2744
+ id: (_f = (_e = (_d = this.config).generateId) == null ? void 0 : _e.call(_d)) != null ? _f : (0, import_provider_utils13.generateId)(),
2654
2745
  url: annotation.url,
2655
2746
  title: annotation.title
2656
2747
  });
@@ -2658,7 +2749,7 @@ var OpenAIResponsesLanguageModel = class {
2658
2749
  content.push({
2659
2750
  type: "source",
2660
2751
  sourceType: "document",
2661
- id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : (0, import_provider_utils12.generateId)(),
2752
+ id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : (0, import_provider_utils13.generateId)(),
2662
2753
  mediaType: "text/plain",
2663
2754
  title: (_k = (_j = annotation.quote) != null ? _j : annotation.filename) != null ? _k : "Document",
2664
2755
  filename: (_l = annotation.filename) != null ? _l : annotation.file_id
@@ -2806,18 +2897,18 @@ var OpenAIResponsesLanguageModel = class {
2806
2897
  warnings,
2807
2898
  webSearchToolName
2808
2899
  } = await this.getArgs(options);
2809
- const { responseHeaders, value: response } = await (0, import_provider_utils12.postJsonToApi)({
2900
+ const { responseHeaders, value: response } = await (0, import_provider_utils13.postJsonToApi)({
2810
2901
  url: this.config.url({
2811
2902
  path: "/responses",
2812
2903
  modelId: this.modelId
2813
2904
  }),
2814
- headers: (0, import_provider_utils12.combineHeaders)(this.config.headers(), options.headers),
2905
+ headers: (0, import_provider_utils13.combineHeaders)(this.config.headers(), options.headers),
2815
2906
  body: {
2816
2907
  ...body,
2817
2908
  stream: true
2818
2909
  },
2819
2910
  failedResponseHandler: openaiFailedResponseHandler,
2820
- successfulResponseHandler: (0, import_provider_utils12.createEventSourceResponseHandler)(
2911
+ successfulResponseHandler: (0, import_provider_utils13.createEventSourceResponseHandler)(
2821
2912
  openaiResponsesChunkSchema
2822
2913
  ),
2823
2914
  abortSignal: options.abortSignal,
@@ -2894,6 +2985,14 @@ var OpenAIResponsesLanguageModel = class {
2894
2985
  id: value.item.id,
2895
2986
  toolName: "file_search"
2896
2987
  });
2988
+ } else if (value.item.type === "image_generation_call") {
2989
+ controller.enqueue({
2990
+ type: "tool-call",
2991
+ toolCallId: value.item.id,
2992
+ toolName: "image_generation",
2993
+ input: "{}",
2994
+ providerExecuted: true
2995
+ });
2897
2996
  } else if (value.item.type === "message") {
2898
2997
  controller.enqueue({
2899
2998
  type: "text-start",
@@ -3027,6 +3126,16 @@ var OpenAIResponsesLanguageModel = class {
3027
3126
  },
3028
3127
  providerExecuted: true
3029
3128
  });
3129
+ } else if (value.item.type === "image_generation_call") {
3130
+ controller.enqueue({
3131
+ type: "tool-result",
3132
+ toolCallId: value.item.id,
3133
+ toolName: "image_generation",
3134
+ result: {
3135
+ result: value.item.result
3136
+ },
3137
+ providerExecuted: true
3138
+ });
3030
3139
  } else if (value.item.type === "message") {
3031
3140
  controller.enqueue({
3032
3141
  type: "text-end",
@@ -3119,7 +3228,7 @@ var OpenAIResponsesLanguageModel = class {
3119
3228
  controller.enqueue({
3120
3229
  type: "source",
3121
3230
  sourceType: "url",
3122
- id: (_o = (_n = (_m = self.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : (0, import_provider_utils12.generateId)(),
3231
+ id: (_o = (_n = (_m = self.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : (0, import_provider_utils13.generateId)(),
3123
3232
  url: value.annotation.url,
3124
3233
  title: value.annotation.title
3125
3234
  });
@@ -3127,7 +3236,7 @@ var OpenAIResponsesLanguageModel = class {
3127
3236
  controller.enqueue({
3128
3237
  type: "source",
3129
3238
  sourceType: "document",
3130
- id: (_r = (_q = (_p = self.config).generateId) == null ? void 0 : _q.call(_p)) != null ? _r : (0, import_provider_utils12.generateId)(),
3239
+ id: (_r = (_q = (_p = self.config).generateId) == null ? void 0 : _q.call(_p)) != null ? _r : (0, import_provider_utils13.generateId)(),
3131
3240
  mediaType: "text/plain",
3132
3241
  title: (_t = (_s = value.annotation.quote) != null ? _s : value.annotation.filename) != null ? _t : "Document",
3133
3242
  filename: (_u = value.annotation.filename) != null ? _u : value.annotation.file_id
@@ -3163,177 +3272,182 @@ var OpenAIResponsesLanguageModel = class {
3163
3272
  };
3164
3273
  }
3165
3274
  };
3166
- var usageSchema2 = import_v414.z.object({
3167
- input_tokens: import_v414.z.number(),
3168
- input_tokens_details: import_v414.z.object({ cached_tokens: import_v414.z.number().nullish() }).nullish(),
3169
- output_tokens: import_v414.z.number(),
3170
- output_tokens_details: import_v414.z.object({ reasoning_tokens: import_v414.z.number().nullish() }).nullish()
3275
+ var usageSchema2 = import_v415.z.object({
3276
+ input_tokens: import_v415.z.number(),
3277
+ input_tokens_details: import_v415.z.object({ cached_tokens: import_v415.z.number().nullish() }).nullish(),
3278
+ output_tokens: import_v415.z.number(),
3279
+ output_tokens_details: import_v415.z.object({ reasoning_tokens: import_v415.z.number().nullish() }).nullish()
3171
3280
  });
3172
- var textDeltaChunkSchema = import_v414.z.object({
3173
- type: import_v414.z.literal("response.output_text.delta"),
3174
- item_id: import_v414.z.string(),
3175
- delta: import_v414.z.string(),
3281
+ var textDeltaChunkSchema = import_v415.z.object({
3282
+ type: import_v415.z.literal("response.output_text.delta"),
3283
+ item_id: import_v415.z.string(),
3284
+ delta: import_v415.z.string(),
3176
3285
  logprobs: LOGPROBS_SCHEMA.nullish()
3177
3286
  });
3178
- var errorChunkSchema = import_v414.z.object({
3179
- type: import_v414.z.literal("error"),
3180
- code: import_v414.z.string(),
3181
- message: import_v414.z.string(),
3182
- param: import_v414.z.string().nullish(),
3183
- sequence_number: import_v414.z.number()
3287
+ var errorChunkSchema = import_v415.z.object({
3288
+ type: import_v415.z.literal("error"),
3289
+ code: import_v415.z.string(),
3290
+ message: import_v415.z.string(),
3291
+ param: import_v415.z.string().nullish(),
3292
+ sequence_number: import_v415.z.number()
3184
3293
  });
3185
- var responseFinishedChunkSchema = import_v414.z.object({
3186
- type: import_v414.z.enum(["response.completed", "response.incomplete"]),
3187
- response: import_v414.z.object({
3188
- incomplete_details: import_v414.z.object({ reason: import_v414.z.string() }).nullish(),
3294
+ var responseFinishedChunkSchema = import_v415.z.object({
3295
+ type: import_v415.z.enum(["response.completed", "response.incomplete"]),
3296
+ response: import_v415.z.object({
3297
+ incomplete_details: import_v415.z.object({ reason: import_v415.z.string() }).nullish(),
3189
3298
  usage: usageSchema2,
3190
- service_tier: import_v414.z.string().nullish()
3299
+ service_tier: import_v415.z.string().nullish()
3191
3300
  })
3192
3301
  });
3193
- var responseCreatedChunkSchema = import_v414.z.object({
3194
- type: import_v414.z.literal("response.created"),
3195
- response: import_v414.z.object({
3196
- id: import_v414.z.string(),
3197
- created_at: import_v414.z.number(),
3198
- model: import_v414.z.string(),
3199
- service_tier: import_v414.z.string().nullish()
3302
+ var responseCreatedChunkSchema = import_v415.z.object({
3303
+ type: import_v415.z.literal("response.created"),
3304
+ response: import_v415.z.object({
3305
+ id: import_v415.z.string(),
3306
+ created_at: import_v415.z.number(),
3307
+ model: import_v415.z.string(),
3308
+ service_tier: import_v415.z.string().nullish()
3200
3309
  })
3201
3310
  });
3202
- var responseOutputItemAddedSchema = import_v414.z.object({
3203
- type: import_v414.z.literal("response.output_item.added"),
3204
- output_index: import_v414.z.number(),
3205
- item: import_v414.z.discriminatedUnion("type", [
3206
- import_v414.z.object({
3207
- type: import_v414.z.literal("message"),
3208
- id: import_v414.z.string()
3311
+ var responseOutputItemAddedSchema = import_v415.z.object({
3312
+ type: import_v415.z.literal("response.output_item.added"),
3313
+ output_index: import_v415.z.number(),
3314
+ item: import_v415.z.discriminatedUnion("type", [
3315
+ import_v415.z.object({
3316
+ type: import_v415.z.literal("message"),
3317
+ id: import_v415.z.string()
3209
3318
  }),
3210
- import_v414.z.object({
3211
- type: import_v414.z.literal("reasoning"),
3212
- id: import_v414.z.string(),
3213
- encrypted_content: import_v414.z.string().nullish()
3319
+ import_v415.z.object({
3320
+ type: import_v415.z.literal("reasoning"),
3321
+ id: import_v415.z.string(),
3322
+ encrypted_content: import_v415.z.string().nullish()
3214
3323
  }),
3215
- import_v414.z.object({
3216
- type: import_v414.z.literal("function_call"),
3217
- id: import_v414.z.string(),
3218
- call_id: import_v414.z.string(),
3219
- name: import_v414.z.string(),
3220
- arguments: import_v414.z.string()
3324
+ import_v415.z.object({
3325
+ type: import_v415.z.literal("function_call"),
3326
+ id: import_v415.z.string(),
3327
+ call_id: import_v415.z.string(),
3328
+ name: import_v415.z.string(),
3329
+ arguments: import_v415.z.string()
3221
3330
  }),
3222
- import_v414.z.object({
3223
- type: import_v414.z.literal("web_search_call"),
3224
- id: import_v414.z.string(),
3225
- status: import_v414.z.string(),
3226
- action: import_v414.z.object({
3227
- type: import_v414.z.literal("search"),
3228
- query: import_v414.z.string().optional()
3331
+ import_v415.z.object({
3332
+ type: import_v415.z.literal("web_search_call"),
3333
+ id: import_v415.z.string(),
3334
+ status: import_v415.z.string(),
3335
+ action: import_v415.z.object({
3336
+ type: import_v415.z.literal("search"),
3337
+ query: import_v415.z.string().optional()
3229
3338
  }).nullish()
3230
3339
  }),
3231
- import_v414.z.object({
3232
- type: import_v414.z.literal("computer_call"),
3233
- id: import_v414.z.string(),
3234
- status: import_v414.z.string()
3340
+ import_v415.z.object({
3341
+ type: import_v415.z.literal("computer_call"),
3342
+ id: import_v415.z.string(),
3343
+ status: import_v415.z.string()
3235
3344
  }),
3236
- import_v414.z.object({
3237
- type: import_v414.z.literal("file_search_call"),
3238
- id: import_v414.z.string(),
3239
- status: import_v414.z.string(),
3240
- queries: import_v414.z.array(import_v414.z.string()).nullish(),
3241
- results: import_v414.z.array(
3242
- import_v414.z.object({
3243
- attributes: import_v414.z.object({
3244
- file_id: import_v414.z.string(),
3245
- filename: import_v414.z.string(),
3246
- score: import_v414.z.number(),
3247
- text: import_v414.z.string()
3345
+ import_v415.z.object({
3346
+ type: import_v415.z.literal("file_search_call"),
3347
+ id: import_v415.z.string(),
3348
+ status: import_v415.z.string(),
3349
+ queries: import_v415.z.array(import_v415.z.string()).nullish(),
3350
+ results: import_v415.z.array(
3351
+ import_v415.z.object({
3352
+ attributes: import_v415.z.object({
3353
+ file_id: import_v415.z.string(),
3354
+ filename: import_v415.z.string(),
3355
+ score: import_v415.z.number(),
3356
+ text: import_v415.z.string()
3248
3357
  })
3249
3358
  })
3250
3359
  ).optional()
3360
+ }),
3361
+ import_v415.z.object({
3362
+ type: import_v415.z.literal("image_generation_call"),
3363
+ id: import_v415.z.string()
3251
3364
  })
3252
3365
  ])
3253
3366
  });
3254
- var responseOutputItemDoneSchema = import_v414.z.object({
3255
- type: import_v414.z.literal("response.output_item.done"),
3256
- output_index: import_v414.z.number(),
3257
- item: import_v414.z.discriminatedUnion("type", [
3258
- import_v414.z.object({
3259
- type: import_v414.z.literal("message"),
3260
- id: import_v414.z.string()
3367
+ var responseOutputItemDoneSchema = import_v415.z.object({
3368
+ type: import_v415.z.literal("response.output_item.done"),
3369
+ output_index: import_v415.z.number(),
3370
+ item: import_v415.z.discriminatedUnion("type", [
3371
+ import_v415.z.object({
3372
+ type: import_v415.z.literal("message"),
3373
+ id: import_v415.z.string()
3261
3374
  }),
3262
- import_v414.z.object({
3263
- type: import_v414.z.literal("reasoning"),
3264
- id: import_v414.z.string(),
3265
- encrypted_content: import_v414.z.string().nullish()
3375
+ import_v415.z.object({
3376
+ type: import_v415.z.literal("reasoning"),
3377
+ id: import_v415.z.string(),
3378
+ encrypted_content: import_v415.z.string().nullish()
3266
3379
  }),
3267
- import_v414.z.object({
3268
- type: import_v414.z.literal("function_call"),
3269
- id: import_v414.z.string(),
3270
- call_id: import_v414.z.string(),
3271
- name: import_v414.z.string(),
3272
- arguments: import_v414.z.string(),
3273
- status: import_v414.z.literal("completed")
3380
+ import_v415.z.object({
3381
+ type: import_v415.z.literal("function_call"),
3382
+ id: import_v415.z.string(),
3383
+ call_id: import_v415.z.string(),
3384
+ name: import_v415.z.string(),
3385
+ arguments: import_v415.z.string(),
3386
+ status: import_v415.z.literal("completed")
3274
3387
  }),
3275
3388
  codeInterpreterCallItem,
3389
+ imageGenerationCallItem,
3276
3390
  webSearchCallItem,
3277
- import_v414.z.object({
3278
- type: import_v414.z.literal("computer_call"),
3279
- id: import_v414.z.string(),
3280
- status: import_v414.z.literal("completed")
3391
+ import_v415.z.object({
3392
+ type: import_v415.z.literal("computer_call"),
3393
+ id: import_v415.z.string(),
3394
+ status: import_v415.z.literal("completed")
3281
3395
  }),
3282
- import_v414.z.object({
3283
- type: import_v414.z.literal("file_search_call"),
3284
- id: import_v414.z.string(),
3285
- status: import_v414.z.literal("completed"),
3286
- queries: import_v414.z.array(import_v414.z.string()).nullish(),
3287
- results: import_v414.z.array(
3288
- import_v414.z.object({
3289
- attributes: import_v414.z.object({
3290
- file_id: import_v414.z.string(),
3291
- filename: import_v414.z.string(),
3292
- score: import_v414.z.number(),
3293
- text: import_v414.z.string()
3396
+ import_v415.z.object({
3397
+ type: import_v415.z.literal("file_search_call"),
3398
+ id: import_v415.z.string(),
3399
+ status: import_v415.z.literal("completed"),
3400
+ queries: import_v415.z.array(import_v415.z.string()).nullish(),
3401
+ results: import_v415.z.array(
3402
+ import_v415.z.object({
3403
+ attributes: import_v415.z.object({
3404
+ file_id: import_v415.z.string(),
3405
+ filename: import_v415.z.string(),
3406
+ score: import_v415.z.number(),
3407
+ text: import_v415.z.string()
3294
3408
  })
3295
3409
  })
3296
3410
  ).nullish()
3297
3411
  })
3298
3412
  ])
3299
3413
  });
3300
- var responseFunctionCallArgumentsDeltaSchema = import_v414.z.object({
3301
- type: import_v414.z.literal("response.function_call_arguments.delta"),
3302
- item_id: import_v414.z.string(),
3303
- output_index: import_v414.z.number(),
3304
- delta: import_v414.z.string()
3414
+ var responseFunctionCallArgumentsDeltaSchema = import_v415.z.object({
3415
+ type: import_v415.z.literal("response.function_call_arguments.delta"),
3416
+ item_id: import_v415.z.string(),
3417
+ output_index: import_v415.z.number(),
3418
+ delta: import_v415.z.string()
3305
3419
  });
3306
- var responseAnnotationAddedSchema = import_v414.z.object({
3307
- type: import_v414.z.literal("response.output_text.annotation.added"),
3308
- annotation: import_v414.z.discriminatedUnion("type", [
3309
- import_v414.z.object({
3310
- type: import_v414.z.literal("url_citation"),
3311
- url: import_v414.z.string(),
3312
- title: import_v414.z.string()
3420
+ var responseAnnotationAddedSchema = import_v415.z.object({
3421
+ type: import_v415.z.literal("response.output_text.annotation.added"),
3422
+ annotation: import_v415.z.discriminatedUnion("type", [
3423
+ import_v415.z.object({
3424
+ type: import_v415.z.literal("url_citation"),
3425
+ url: import_v415.z.string(),
3426
+ title: import_v415.z.string()
3313
3427
  }),
3314
- import_v414.z.object({
3315
- type: import_v414.z.literal("file_citation"),
3316
- file_id: import_v414.z.string(),
3317
- filename: import_v414.z.string().nullish(),
3318
- index: import_v414.z.number().nullish(),
3319
- start_index: import_v414.z.number().nullish(),
3320
- end_index: import_v414.z.number().nullish(),
3321
- quote: import_v414.z.string().nullish()
3428
+ import_v415.z.object({
3429
+ type: import_v415.z.literal("file_citation"),
3430
+ file_id: import_v415.z.string(),
3431
+ filename: import_v415.z.string().nullish(),
3432
+ index: import_v415.z.number().nullish(),
3433
+ start_index: import_v415.z.number().nullish(),
3434
+ end_index: import_v415.z.number().nullish(),
3435
+ quote: import_v415.z.string().nullish()
3322
3436
  })
3323
3437
  ])
3324
3438
  });
3325
- var responseReasoningSummaryPartAddedSchema = import_v414.z.object({
3326
- type: import_v414.z.literal("response.reasoning_summary_part.added"),
3327
- item_id: import_v414.z.string(),
3328
- summary_index: import_v414.z.number()
3439
+ var responseReasoningSummaryPartAddedSchema = import_v415.z.object({
3440
+ type: import_v415.z.literal("response.reasoning_summary_part.added"),
3441
+ item_id: import_v415.z.string(),
3442
+ summary_index: import_v415.z.number()
3329
3443
  });
3330
- var responseReasoningSummaryTextDeltaSchema = import_v414.z.object({
3331
- type: import_v414.z.literal("response.reasoning_summary_text.delta"),
3332
- item_id: import_v414.z.string(),
3333
- summary_index: import_v414.z.number(),
3334
- delta: import_v414.z.string()
3444
+ var responseReasoningSummaryTextDeltaSchema = import_v415.z.object({
3445
+ type: import_v415.z.literal("response.reasoning_summary_text.delta"),
3446
+ item_id: import_v415.z.string(),
3447
+ summary_index: import_v415.z.number(),
3448
+ delta: import_v415.z.string()
3335
3449
  });
3336
- var openaiResponsesChunkSchema = import_v414.z.union([
3450
+ var openaiResponsesChunkSchema = import_v415.z.union([
3337
3451
  textDeltaChunkSchema,
3338
3452
  responseFinishedChunkSchema,
3339
3453
  responseCreatedChunkSchema,
@@ -3344,7 +3458,7 @@ var openaiResponsesChunkSchema = import_v414.z.union([
3344
3458
  responseReasoningSummaryPartAddedSchema,
3345
3459
  responseReasoningSummaryTextDeltaSchema,
3346
3460
  errorChunkSchema,
3347
- import_v414.z.object({ type: import_v414.z.string() }).loose()
3461
+ import_v415.z.object({ type: import_v415.z.string() }).loose()
3348
3462
  // fallback for unknown chunks
3349
3463
  ]);
3350
3464
  function isTextDeltaChunk(chunk) {
@@ -3417,27 +3531,15 @@ function getResponsesModelConfig(modelId) {
3417
3531
  isReasoningModel: false
3418
3532
  };
3419
3533
  }
3420
- var openaiResponsesProviderOptionsSchema = import_v414.z.object({
3421
- metadata: import_v414.z.any().nullish(),
3422
- parallelToolCalls: import_v414.z.boolean().nullish(),
3423
- previousResponseId: import_v414.z.string().nullish(),
3424
- store: import_v414.z.boolean().nullish(),
3425
- user: import_v414.z.string().nullish(),
3426
- reasoningEffort: import_v414.z.string().nullish(),
3427
- strictJsonSchema: import_v414.z.boolean().nullish(),
3428
- instructions: import_v414.z.string().nullish(),
3429
- reasoningSummary: import_v414.z.string().nullish(),
3430
- serviceTier: import_v414.z.enum(["auto", "flex", "priority"]).nullish(),
3431
- include: import_v414.z.array(
3432
- import_v414.z.enum([
3534
+ var openaiResponsesProviderOptionsSchema = import_v415.z.object({
3535
+ include: import_v415.z.array(
3536
+ import_v415.z.enum([
3433
3537
  "reasoning.encrypted_content",
3434
3538
  "file_search_call.results",
3435
3539
  "message.output_text.logprobs"
3436
3540
  ])
3437
3541
  ).nullish(),
3438
- textVerbosity: import_v414.z.enum(["low", "medium", "high"]).nullish(),
3439
- promptCacheKey: import_v414.z.string().nullish(),
3440
- safetyIdentifier: import_v414.z.string().nullish(),
3542
+ instructions: import_v415.z.string().nullish(),
3441
3543
  /**
3442
3544
  * Return the log probabilities of the tokens.
3443
3545
  *
@@ -3450,15 +3552,33 @@ var openaiResponsesProviderOptionsSchema = import_v414.z.object({
3450
3552
  * @see https://platform.openai.com/docs/api-reference/responses/create
3451
3553
  * @see https://cookbook.openai.com/examples/using_logprobs
3452
3554
  */
3453
- logprobs: import_v414.z.union([import_v414.z.boolean(), import_v414.z.number().min(1).max(TOP_LOGPROBS_MAX)]).optional()
3555
+ logprobs: import_v415.z.union([import_v415.z.boolean(), import_v415.z.number().min(1).max(TOP_LOGPROBS_MAX)]).optional(),
3556
+ /**
3557
+ * The maximum number of total calls to built-in tools that can be processed in a response.
3558
+ * This maximum number applies across all built-in tool calls, not per individual tool.
3559
+ * Any further attempts to call a tool by the model will be ignored.
3560
+ */
3561
+ maxToolCalls: import_v415.z.number().nullish(),
3562
+ metadata: import_v415.z.any().nullish(),
3563
+ parallelToolCalls: import_v415.z.boolean().nullish(),
3564
+ previousResponseId: import_v415.z.string().nullish(),
3565
+ promptCacheKey: import_v415.z.string().nullish(),
3566
+ reasoningEffort: import_v415.z.string().nullish(),
3567
+ reasoningSummary: import_v415.z.string().nullish(),
3568
+ safetyIdentifier: import_v415.z.string().nullish(),
3569
+ serviceTier: import_v415.z.enum(["auto", "flex", "priority"]).nullish(),
3570
+ store: import_v415.z.boolean().nullish(),
3571
+ strictJsonSchema: import_v415.z.boolean().nullish(),
3572
+ textVerbosity: import_v415.z.enum(["low", "medium", "high"]).nullish(),
3573
+ user: import_v415.z.string().nullish()
3454
3574
  });
3455
3575
 
3456
3576
  // src/speech/openai-speech-model.ts
3457
- var import_provider_utils13 = require("@ai-sdk/provider-utils");
3458
- var import_v415 = require("zod/v4");
3459
- var OpenAIProviderOptionsSchema = import_v415.z.object({
3460
- instructions: import_v415.z.string().nullish(),
3461
- speed: import_v415.z.number().min(0.25).max(4).default(1).nullish()
3577
+ var import_provider_utils14 = require("@ai-sdk/provider-utils");
3578
+ var import_v416 = require("zod/v4");
3579
+ var OpenAIProviderOptionsSchema = import_v416.z.object({
3580
+ instructions: import_v416.z.string().nullish(),
3581
+ speed: import_v416.z.number().min(0.25).max(4).default(1).nullish()
3462
3582
  });
3463
3583
  var OpenAISpeechModel = class {
3464
3584
  constructor(modelId, config) {
@@ -3479,7 +3599,7 @@ var OpenAISpeechModel = class {
3479
3599
  providerOptions
3480
3600
  }) {
3481
3601
  const warnings = [];
3482
- const openAIOptions = await (0, import_provider_utils13.parseProviderOptions)({
3602
+ const openAIOptions = await (0, import_provider_utils14.parseProviderOptions)({
3483
3603
  provider: "openai",
3484
3604
  providerOptions,
3485
3605
  schema: OpenAIProviderOptionsSchema
@@ -3532,15 +3652,15 @@ var OpenAISpeechModel = class {
3532
3652
  value: audio,
3533
3653
  responseHeaders,
3534
3654
  rawValue: rawResponse
3535
- } = await (0, import_provider_utils13.postJsonToApi)({
3655
+ } = await (0, import_provider_utils14.postJsonToApi)({
3536
3656
  url: this.config.url({
3537
3657
  path: "/audio/speech",
3538
3658
  modelId: this.modelId
3539
3659
  }),
3540
- headers: (0, import_provider_utils13.combineHeaders)(this.config.headers(), options.headers),
3660
+ headers: (0, import_provider_utils14.combineHeaders)(this.config.headers(), options.headers),
3541
3661
  body: requestBody,
3542
3662
  failedResponseHandler: openaiFailedResponseHandler,
3543
- successfulResponseHandler: (0, import_provider_utils13.createBinaryResponseHandler)(),
3663
+ successfulResponseHandler: (0, import_provider_utils14.createBinaryResponseHandler)(),
3544
3664
  abortSignal: options.abortSignal,
3545
3665
  fetch: this.config.fetch
3546
3666
  });
@@ -3561,34 +3681,34 @@ var OpenAISpeechModel = class {
3561
3681
  };
3562
3682
 
3563
3683
  // src/transcription/openai-transcription-model.ts
3564
- var import_provider_utils14 = require("@ai-sdk/provider-utils");
3565
- var import_v417 = require("zod/v4");
3684
+ var import_provider_utils15 = require("@ai-sdk/provider-utils");
3685
+ var import_v418 = require("zod/v4");
3566
3686
 
3567
3687
  // src/transcription/openai-transcription-options.ts
3568
- var import_v416 = require("zod/v4");
3569
- var openAITranscriptionProviderOptions = import_v416.z.object({
3688
+ var import_v417 = require("zod/v4");
3689
+ var openAITranscriptionProviderOptions = import_v417.z.object({
3570
3690
  /**
3571
3691
  * Additional information to include in the transcription response.
3572
3692
  */
3573
- include: import_v416.z.array(import_v416.z.string()).optional(),
3693
+ include: import_v417.z.array(import_v417.z.string()).optional(),
3574
3694
  /**
3575
3695
  * The language of the input audio in ISO-639-1 format.
3576
3696
  */
3577
- language: import_v416.z.string().optional(),
3697
+ language: import_v417.z.string().optional(),
3578
3698
  /**
3579
3699
  * An optional text to guide the model's style or continue a previous audio segment.
3580
3700
  */
3581
- prompt: import_v416.z.string().optional(),
3701
+ prompt: import_v417.z.string().optional(),
3582
3702
  /**
3583
3703
  * The sampling temperature, between 0 and 1.
3584
3704
  * @default 0
3585
3705
  */
3586
- temperature: import_v416.z.number().min(0).max(1).default(0).optional(),
3706
+ temperature: import_v417.z.number().min(0).max(1).default(0).optional(),
3587
3707
  /**
3588
3708
  * The timestamp granularities to populate for this transcription.
3589
3709
  * @default ['segment']
3590
3710
  */
3591
- timestampGranularities: import_v416.z.array(import_v416.z.enum(["word", "segment"])).default(["segment"]).optional()
3711
+ timestampGranularities: import_v417.z.array(import_v417.z.enum(["word", "segment"])).default(["segment"]).optional()
3592
3712
  });
3593
3713
 
3594
3714
  // src/transcription/openai-transcription-model.ts
@@ -3666,15 +3786,15 @@ var OpenAITranscriptionModel = class {
3666
3786
  providerOptions
3667
3787
  }) {
3668
3788
  const warnings = [];
3669
- const openAIOptions = await (0, import_provider_utils14.parseProviderOptions)({
3789
+ const openAIOptions = await (0, import_provider_utils15.parseProviderOptions)({
3670
3790
  provider: "openai",
3671
3791
  providerOptions,
3672
3792
  schema: openAITranscriptionProviderOptions
3673
3793
  });
3674
3794
  const formData = new FormData();
3675
- const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([(0, import_provider_utils14.convertBase64ToUint8Array)(audio)]);
3795
+ const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([(0, import_provider_utils15.convertBase64ToUint8Array)(audio)]);
3676
3796
  formData.append("model", this.modelId);
3677
- const fileExtension = (0, import_provider_utils14.mediaTypeToExtension)(mediaType);
3797
+ const fileExtension = (0, import_provider_utils15.mediaTypeToExtension)(mediaType);
3678
3798
  formData.append(
3679
3799
  "file",
3680
3800
  new File([blob], "audio", { type: mediaType }),
@@ -3719,15 +3839,15 @@ var OpenAITranscriptionModel = class {
3719
3839
  value: response,
3720
3840
  responseHeaders,
3721
3841
  rawValue: rawResponse
3722
- } = await (0, import_provider_utils14.postFormDataToApi)({
3842
+ } = await (0, import_provider_utils15.postFormDataToApi)({
3723
3843
  url: this.config.url({
3724
3844
  path: "/audio/transcriptions",
3725
3845
  modelId: this.modelId
3726
3846
  }),
3727
- headers: (0, import_provider_utils14.combineHeaders)(this.config.headers(), options.headers),
3847
+ headers: (0, import_provider_utils15.combineHeaders)(this.config.headers(), options.headers),
3728
3848
  formData,
3729
3849
  failedResponseHandler: openaiFailedResponseHandler,
3730
- successfulResponseHandler: (0, import_provider_utils14.createJsonResponseHandler)(
3850
+ successfulResponseHandler: (0, import_provider_utils15.createJsonResponseHandler)(
3731
3851
  openaiTranscriptionResponseSchema
3732
3852
  ),
3733
3853
  abortSignal: options.abortSignal,
@@ -3757,29 +3877,29 @@ var OpenAITranscriptionModel = class {
3757
3877
  };
3758
3878
  }
3759
3879
  };
3760
- var openaiTranscriptionResponseSchema = import_v417.z.object({
3761
- text: import_v417.z.string(),
3762
- language: import_v417.z.string().nullish(),
3763
- duration: import_v417.z.number().nullish(),
3764
- words: import_v417.z.array(
3765
- import_v417.z.object({
3766
- word: import_v417.z.string(),
3767
- start: import_v417.z.number(),
3768
- end: import_v417.z.number()
3880
+ var openaiTranscriptionResponseSchema = import_v418.z.object({
3881
+ text: import_v418.z.string(),
3882
+ language: import_v418.z.string().nullish(),
3883
+ duration: import_v418.z.number().nullish(),
3884
+ words: import_v418.z.array(
3885
+ import_v418.z.object({
3886
+ word: import_v418.z.string(),
3887
+ start: import_v418.z.number(),
3888
+ end: import_v418.z.number()
3769
3889
  })
3770
3890
  ).nullish(),
3771
- segments: import_v417.z.array(
3772
- import_v417.z.object({
3773
- id: import_v417.z.number(),
3774
- seek: import_v417.z.number(),
3775
- start: import_v417.z.number(),
3776
- end: import_v417.z.number(),
3777
- text: import_v417.z.string(),
3778
- tokens: import_v417.z.array(import_v417.z.number()),
3779
- temperature: import_v417.z.number(),
3780
- avg_logprob: import_v417.z.number(),
3781
- compression_ratio: import_v417.z.number(),
3782
- no_speech_prob: import_v417.z.number()
3891
+ segments: import_v418.z.array(
3892
+ import_v418.z.object({
3893
+ id: import_v418.z.number(),
3894
+ seek: import_v418.z.number(),
3895
+ start: import_v418.z.number(),
3896
+ end: import_v418.z.number(),
3897
+ text: import_v418.z.string(),
3898
+ tokens: import_v418.z.array(import_v418.z.number()),
3899
+ temperature: import_v418.z.number(),
3900
+ avg_logprob: import_v418.z.number(),
3901
+ compression_ratio: import_v418.z.number(),
3902
+ no_speech_prob: import_v418.z.number()
3783
3903
  })
3784
3904
  ).nullish()
3785
3905
  });
@@ -3787,10 +3907,10 @@ var openaiTranscriptionResponseSchema = import_v417.z.object({
3787
3907
  // src/openai-provider.ts
3788
3908
  function createOpenAI(options = {}) {
3789
3909
  var _a, _b;
3790
- const baseURL = (_a = (0, import_provider_utils15.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://api.openai.com/v1";
3910
+ const baseURL = (_a = (0, import_provider_utils16.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://api.openai.com/v1";
3791
3911
  const providerName = (_b = options.name) != null ? _b : "openai";
3792
3912
  const getHeaders = () => ({
3793
- Authorization: `Bearer ${(0, import_provider_utils15.loadApiKey)({
3913
+ Authorization: `Bearer ${(0, import_provider_utils16.loadApiKey)({
3794
3914
  apiKey: options.apiKey,
3795
3915
  environmentVariableName: "OPENAI_API_KEY",
3796
3916
  description: "OpenAI"