@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.mjs CHANGED
@@ -1839,39 +1839,69 @@ var codeInterpreter = (args = {}) => {
1839
1839
  return codeInterpreterToolFactory(args);
1840
1840
  };
1841
1841
 
1842
+ // src/tool/image-generation.ts
1843
+ import { createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema2 } from "@ai-sdk/provider-utils";
1844
+ import { z as z12 } from "zod/v4";
1845
+ var imageGenerationArgsSchema = z12.object({
1846
+ background: z12.enum(["auto", "opaque", "transparent"]).optional(),
1847
+ inputFidelity: z12.enum(["low", "high"]).optional(),
1848
+ inputImageMask: z12.object({
1849
+ fileId: z12.string().optional(),
1850
+ imageUrl: z12.string().optional()
1851
+ }).optional(),
1852
+ model: z12.string().optional(),
1853
+ moderation: z12.enum(["auto"]).optional(),
1854
+ outputCompression: z12.number().int().min(0).max(100).optional(),
1855
+ outputFormat: z12.enum(["png", "jpeg", "webp"]).optional(),
1856
+ quality: z12.enum(["auto", "low", "medium", "high"]).optional(),
1857
+ size: z12.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
1858
+ }).strict();
1859
+ var imageGenerationOutputSchema = z12.object({
1860
+ result: z12.string()
1861
+ });
1862
+ var imageGenerationToolFactory = createProviderDefinedToolFactoryWithOutputSchema2({
1863
+ id: "openai.image_generation",
1864
+ name: "image_generation",
1865
+ inputSchema: z12.object({}),
1866
+ outputSchema: imageGenerationOutputSchema
1867
+ });
1868
+ var imageGeneration = (args = {}) => {
1869
+ return imageGenerationToolFactory(args);
1870
+ };
1871
+
1842
1872
  // src/tool/web-search.ts
1843
1873
  import { createProviderDefinedToolFactory as createProviderDefinedToolFactory3 } from "@ai-sdk/provider-utils";
1844
- import { z as z12 } from "zod/v4";
1845
- var webSearchArgsSchema = z12.object({
1846
- filters: z12.object({
1847
- allowedDomains: z12.array(z12.string()).optional()
1874
+ import { z as z13 } from "zod/v4";
1875
+ var webSearchArgsSchema = z13.object({
1876
+ filters: z13.object({
1877
+ allowedDomains: z13.array(z13.string()).optional()
1848
1878
  }).optional(),
1849
- searchContextSize: z12.enum(["low", "medium", "high"]).optional(),
1850
- userLocation: z12.object({
1851
- type: z12.literal("approximate"),
1852
- country: z12.string().optional(),
1853
- city: z12.string().optional(),
1854
- region: z12.string().optional(),
1855
- timezone: z12.string().optional()
1879
+ searchContextSize: z13.enum(["low", "medium", "high"]).optional(),
1880
+ userLocation: z13.object({
1881
+ type: z13.literal("approximate"),
1882
+ country: z13.string().optional(),
1883
+ city: z13.string().optional(),
1884
+ region: z13.string().optional(),
1885
+ timezone: z13.string().optional()
1856
1886
  }).optional()
1857
1887
  });
1858
1888
  var webSearchToolFactory = createProviderDefinedToolFactory3({
1859
1889
  id: "openai.web_search",
1860
1890
  name: "web_search",
1861
- inputSchema: z12.object({
1862
- action: z12.discriminatedUnion("type", [
1863
- z12.object({
1864
- type: z12.literal("search"),
1865
- query: z12.string().nullish()
1891
+ inputSchema: z13.object({
1892
+ action: z13.discriminatedUnion("type", [
1893
+ z13.object({
1894
+ type: z13.literal("search"),
1895
+ query: z13.string().nullish()
1866
1896
  }),
1867
- z12.object({
1868
- type: z12.literal("open_page"),
1869
- url: z12.string()
1897
+ z13.object({
1898
+ type: z13.literal("open_page"),
1899
+ url: z13.string()
1870
1900
  }),
1871
- z12.object({
1872
- type: z12.literal("find"),
1873
- url: z12.string(),
1874
- pattern: z12.string()
1901
+ z13.object({
1902
+ type: z13.literal("find"),
1903
+ url: z13.string(),
1904
+ pattern: z13.string()
1875
1905
  })
1876
1906
  ]).nullish()
1877
1907
  })
@@ -1905,6 +1935,20 @@ var openaiTools = {
1905
1935
  * @param filters - The filters to use for the file search.
1906
1936
  */
1907
1937
  fileSearch,
1938
+ /**
1939
+ * The image generation tool allows you to generate images using a text prompt,
1940
+ * and optionally image inputs. It leverages the GPT Image model,
1941
+ * and automatically optimizes text inputs for improved performance.
1942
+ *
1943
+ * Must have name `image_generation`.
1944
+ *
1945
+ * @param size - Image dimensions (e.g., 1024x1024, 1024x1536)
1946
+ * @param quality - Rendering quality (e.g. low, medium, high)
1947
+ * @param format - File output format
1948
+ * @param compression - Compression level (0-100%) for JPEG and WebP formats
1949
+ * @param background - Transparent or opaque
1950
+ */
1951
+ imageGeneration,
1908
1952
  /**
1909
1953
  * Web search allows models to access up-to-date information from the internet
1910
1954
  * and provide answers with sourced citations.
@@ -1942,14 +1986,14 @@ import {
1942
1986
  parseProviderOptions as parseProviderOptions5,
1943
1987
  postJsonToApi as postJsonToApi5
1944
1988
  } from "@ai-sdk/provider-utils";
1945
- import { z as z14 } from "zod/v4";
1989
+ import { z as z15 } from "zod/v4";
1946
1990
 
1947
1991
  // src/responses/convert-to-openai-responses-input.ts
1948
1992
  import {
1949
1993
  UnsupportedFunctionalityError as UnsupportedFunctionalityError4
1950
1994
  } from "@ai-sdk/provider";
1951
1995
  import { convertToBase64 as convertToBase642, parseProviderOptions as parseProviderOptions4 } from "@ai-sdk/provider-utils";
1952
- import { z as z13 } from "zod/v4";
1996
+ import { z as z14 } from "zod/v4";
1953
1997
  function isFileId(data, prefixes) {
1954
1998
  if (!prefixes) return false;
1955
1999
  return prefixes.some((prefix) => data.startsWith(prefix));
@@ -1957,7 +2001,8 @@ function isFileId(data, prefixes) {
1957
2001
  async function convertToOpenAIResponsesInput({
1958
2002
  prompt,
1959
2003
  systemMessageMode,
1960
- fileIdPrefixes
2004
+ fileIdPrefixes,
2005
+ store
1961
2006
  }) {
1962
2007
  var _a, _b, _c, _d, _e, _f;
1963
2008
  const input = [];
@@ -2062,10 +2107,14 @@ async function convertToOpenAIResponsesInput({
2062
2107
  break;
2063
2108
  }
2064
2109
  case "tool-result": {
2065
- warnings.push({
2066
- type: "other",
2067
- message: `tool result parts in assistant messages are not supported for OpenAI responses`
2068
- });
2110
+ if (store) {
2111
+ input.push({ type: "item_reference", id: part.toolCallId });
2112
+ } else {
2113
+ warnings.push({
2114
+ type: "other",
2115
+ message: `Results for OpenAI tool ${part.toolName} are not sent to the API when store is false`
2116
+ });
2117
+ }
2069
2118
  break;
2070
2119
  }
2071
2120
  case "reasoning": {
@@ -2140,9 +2189,9 @@ async function convertToOpenAIResponsesInput({
2140
2189
  }
2141
2190
  return { input, warnings };
2142
2191
  }
2143
- var openaiResponsesReasoningProviderOptionsSchema = z13.object({
2144
- itemId: z13.string().nullish(),
2145
- reasoningEncryptedContent: z13.string().nullish()
2192
+ var openaiResponsesReasoningProviderOptionsSchema = z14.object({
2193
+ itemId: z14.string().nullish(),
2194
+ reasoningEncryptedContent: z14.string().nullish()
2146
2195
  });
2147
2196
 
2148
2197
  // src/responses/map-openai-responses-finish-reason.ts
@@ -2229,8 +2278,23 @@ function prepareResponsesTools({
2229
2278
  });
2230
2279
  break;
2231
2280
  }
2232
- default: {
2233
- toolWarnings.push({ type: "unsupported-tool", tool });
2281
+ case "openai.image_generation": {
2282
+ const args = imageGenerationArgsSchema.parse(tool.args);
2283
+ openaiTools2.push({
2284
+ type: "image_generation",
2285
+ background: args.background,
2286
+ input_fidelity: args.inputFidelity,
2287
+ input_image_mask: args.inputImageMask ? {
2288
+ file_id: args.inputImageMask.fileId,
2289
+ image_url: args.inputImageMask.imageUrl
2290
+ } : void 0,
2291
+ model: args.model,
2292
+ size: args.size,
2293
+ quality: args.quality,
2294
+ moderation: args.moderation,
2295
+ output_format: args.outputFormat,
2296
+ output_compression: args.outputCompression
2297
+ });
2234
2298
  break;
2235
2299
  }
2236
2300
  }
@@ -2253,7 +2317,7 @@ function prepareResponsesTools({
2253
2317
  case "tool":
2254
2318
  return {
2255
2319
  tools: openaiTools2,
2256
- 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 },
2320
+ 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 },
2257
2321
  toolWarnings
2258
2322
  };
2259
2323
  default: {
@@ -2266,47 +2330,52 @@ function prepareResponsesTools({
2266
2330
  }
2267
2331
 
2268
2332
  // src/responses/openai-responses-language-model.ts
2269
- var webSearchCallItem = z14.object({
2270
- type: z14.literal("web_search_call"),
2271
- id: z14.string(),
2272
- status: z14.string(),
2273
- action: z14.discriminatedUnion("type", [
2274
- z14.object({
2275
- type: z14.literal("search"),
2276
- query: z14.string().nullish()
2333
+ var webSearchCallItem = z15.object({
2334
+ type: z15.literal("web_search_call"),
2335
+ id: z15.string(),
2336
+ status: z15.string(),
2337
+ action: z15.discriminatedUnion("type", [
2338
+ z15.object({
2339
+ type: z15.literal("search"),
2340
+ query: z15.string().nullish()
2277
2341
  }),
2278
- z14.object({
2279
- type: z14.literal("open_page"),
2280
- url: z14.string()
2342
+ z15.object({
2343
+ type: z15.literal("open_page"),
2344
+ url: z15.string()
2281
2345
  }),
2282
- z14.object({
2283
- type: z14.literal("find"),
2284
- url: z14.string(),
2285
- pattern: z14.string()
2346
+ z15.object({
2347
+ type: z15.literal("find"),
2348
+ url: z15.string(),
2349
+ pattern: z15.string()
2286
2350
  })
2287
2351
  ]).nullish()
2288
2352
  });
2289
- var codeInterpreterCallItem = z14.object({
2290
- type: z14.literal("code_interpreter_call"),
2291
- id: z14.string(),
2292
- code: z14.string().nullable(),
2293
- container_id: z14.string(),
2294
- outputs: z14.array(
2295
- z14.discriminatedUnion("type", [
2296
- z14.object({ type: z14.literal("logs"), logs: z14.string() }),
2297
- z14.object({ type: z14.literal("image"), url: z14.string() })
2353
+ var codeInterpreterCallItem = z15.object({
2354
+ type: z15.literal("code_interpreter_call"),
2355
+ id: z15.string(),
2356
+ code: z15.string().nullable(),
2357
+ container_id: z15.string(),
2358
+ outputs: z15.array(
2359
+ z15.discriminatedUnion("type", [
2360
+ z15.object({ type: z15.literal("logs"), logs: z15.string() }),
2361
+ z15.object({ type: z15.literal("image"), url: z15.string() })
2298
2362
  ])
2299
2363
  ).nullable()
2300
2364
  });
2365
+ var imageGenerationCallItem = z15.object({
2366
+ type: z15.literal("image_generation_call"),
2367
+ id: z15.string(),
2368
+ result: z15.string()
2369
+ });
2301
2370
  var TOP_LOGPROBS_MAX = 20;
2302
- var LOGPROBS_SCHEMA = z14.array(
2303
- z14.object({
2304
- token: z14.string(),
2305
- logprob: z14.number(),
2306
- top_logprobs: z14.array(
2307
- z14.object({
2308
- token: z14.string(),
2309
- logprob: z14.number()
2371
+ var LOGPROBS_SCHEMA = z15.array(
2372
+ z15.object({
2373
+ token: z15.string(),
2374
+ logprob: z15.number(),
2375
+ top_logprobs: z15.array(
2376
+ z15.object({
2377
+ token: z15.string(),
2378
+ logprob: z15.number()
2310
2379
  })
2311
2380
  )
2312
2381
  })
@@ -2339,7 +2408,7 @@ var OpenAIResponsesLanguageModel = class {
2339
2408
  toolChoice,
2340
2409
  responseFormat
2341
2410
  }) {
2342
- var _a, _b, _c, _d;
2411
+ var _a, _b, _c, _d, _e;
2343
2412
  const warnings = [];
2344
2413
  const modelConfig = getResponsesModelConfig(this.modelId);
2345
2414
  if (topK != null) {
@@ -2363,28 +2432,29 @@ var OpenAIResponsesLanguageModel = class {
2363
2432
  if (stopSequences != null) {
2364
2433
  warnings.push({ type: "unsupported-setting", setting: "stopSequences" });
2365
2434
  }
2366
- const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
2367
- prompt,
2368
- systemMessageMode: modelConfig.systemMessageMode,
2369
- fileIdPrefixes: this.config.fileIdPrefixes
2370
- });
2371
- warnings.push(...inputWarnings);
2372
2435
  const openaiOptions = await parseProviderOptions5({
2373
2436
  provider: "openai",
2374
2437
  providerOptions,
2375
2438
  schema: openaiResponsesProviderOptionsSchema
2376
2439
  });
2377
- const strictJsonSchema = (_a = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _a : false;
2440
+ const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
2441
+ prompt,
2442
+ systemMessageMode: modelConfig.systemMessageMode,
2443
+ fileIdPrefixes: this.config.fileIdPrefixes,
2444
+ store: (_a = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _a : true
2445
+ });
2446
+ warnings.push(...inputWarnings);
2447
+ const strictJsonSchema = (_b = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _b : false;
2378
2448
  let include = openaiOptions == null ? void 0 : openaiOptions.include;
2379
2449
  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;
2380
2450
  include = topLogprobs ? Array.isArray(include) ? [...include, "message.output_text.logprobs"] : ["message.output_text.logprobs"] : include;
2381
- const webSearchToolName = (_b = tools == null ? void 0 : tools.find(
2451
+ const webSearchToolName = (_c = tools == null ? void 0 : tools.find(
2382
2452
  (tool) => tool.type === "provider-defined" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
2383
- )) == null ? void 0 : _b.name;
2453
+ )) == null ? void 0 : _c.name;
2384
2454
  include = webSearchToolName ? Array.isArray(include) ? [...include, "web_search_call.action.sources"] : ["web_search_call.action.sources"] : include;
2385
- const codeInterpreterToolName = (_c = tools == null ? void 0 : tools.find(
2455
+ const codeInterpreterToolName = (_d = tools == null ? void 0 : tools.find(
2386
2456
  (tool) => tool.type === "provider-defined" && tool.id === "openai.code_interpreter"
2387
- )) == null ? void 0 : _c.name;
2457
+ )) == null ? void 0 : _d.name;
2388
2458
  include = codeInterpreterToolName ? Array.isArray(include) ? [...include, "code_interpreter_call.outputs"] : ["code_interpreter_call.outputs"] : include;
2389
2459
  const baseArgs = {
2390
2460
  model: this.modelId,
@@ -2398,7 +2468,7 @@ var OpenAIResponsesLanguageModel = class {
2398
2468
  format: responseFormat.schema != null ? {
2399
2469
  type: "json_schema",
2400
2470
  strict: strictJsonSchema,
2401
- name: (_d = responseFormat.name) != null ? _d : "response",
2471
+ name: (_e = responseFormat.name) != null ? _e : "response",
2402
2472
  description: responseFormat.description,
2403
2473
  schema: responseFormat.schema
2404
2474
  } : { type: "json_object" }
@@ -2409,6 +2479,7 @@ var OpenAIResponsesLanguageModel = class {
2409
2479
  }
2410
2480
  },
2411
2481
  // provider options:
2482
+ max_tool_calls: openaiOptions == null ? void 0 : openaiOptions.maxToolCalls,
2412
2483
  metadata: openaiOptions == null ? void 0 : openaiOptions.metadata,
2413
2484
  parallel_tool_calls: openaiOptions == null ? void 0 : openaiOptions.parallelToolCalls,
2414
2485
  previous_response_id: openaiOptions == null ? void 0 : openaiOptions.previousResponseId,
@@ -2524,45 +2595,45 @@ var OpenAIResponsesLanguageModel = class {
2524
2595
  body,
2525
2596
  failedResponseHandler: openaiFailedResponseHandler,
2526
2597
  successfulResponseHandler: createJsonResponseHandler5(
2527
- z14.object({
2528
- id: z14.string(),
2529
- created_at: z14.number(),
2530
- error: z14.object({
2531
- code: z14.string(),
2532
- message: z14.string()
2598
+ z15.object({
2599
+ id: z15.string(),
2600
+ created_at: z15.number(),
2601
+ error: z15.object({
2602
+ code: z15.string(),
2603
+ message: z15.string()
2533
2604
  }).nullish(),
2534
- model: z14.string(),
2535
- output: z14.array(
2536
- z14.discriminatedUnion("type", [
2537
- z14.object({
2538
- type: z14.literal("message"),
2539
- role: z14.literal("assistant"),
2540
- id: z14.string(),
2541
- content: z14.array(
2542
- z14.object({
2543
- type: z14.literal("output_text"),
2544
- text: z14.string(),
2605
+ model: z15.string(),
2606
+ output: z15.array(
2607
+ z15.discriminatedUnion("type", [
2608
+ z15.object({
2609
+ type: z15.literal("message"),
2610
+ role: z15.literal("assistant"),
2611
+ id: z15.string(),
2612
+ content: z15.array(
2613
+ z15.object({
2614
+ type: z15.literal("output_text"),
2615
+ text: z15.string(),
2545
2616
  logprobs: LOGPROBS_SCHEMA.nullish(),
2546
- annotations: z14.array(
2547
- z14.discriminatedUnion("type", [
2548
- z14.object({
2549
- type: z14.literal("url_citation"),
2550
- start_index: z14.number(),
2551
- end_index: z14.number(),
2552
- url: z14.string(),
2553
- title: z14.string()
2617
+ annotations: z15.array(
2618
+ z15.discriminatedUnion("type", [
2619
+ z15.object({
2620
+ type: z15.literal("url_citation"),
2621
+ start_index: z15.number(),
2622
+ end_index: z15.number(),
2623
+ url: z15.string(),
2624
+ title: z15.string()
2554
2625
  }),
2555
- z14.object({
2556
- type: z14.literal("file_citation"),
2557
- file_id: z14.string(),
2558
- filename: z14.string().nullish(),
2559
- index: z14.number().nullish(),
2560
- start_index: z14.number().nullish(),
2561
- end_index: z14.number().nullish(),
2562
- quote: z14.string().nullish()
2626
+ z15.object({
2627
+ type: z15.literal("file_citation"),
2628
+ file_id: z15.string(),
2629
+ filename: z15.string().nullish(),
2630
+ index: z15.number().nullish(),
2631
+ start_index: z15.number().nullish(),
2632
+ end_index: z15.number().nullish(),
2633
+ quote: z15.string().nullish()
2563
2634
  }),
2564
- z14.object({
2565
- type: z14.literal("container_file_citation")
2635
+ z15.object({
2636
+ type: z15.literal("container_file_citation")
2566
2637
  })
2567
2638
  ])
2568
2639
  )
@@ -2570,50 +2641,51 @@ var OpenAIResponsesLanguageModel = class {
2570
2641
  )
2571
2642
  }),
2572
2643
  codeInterpreterCallItem,
2573
- z14.object({
2574
- type: z14.literal("function_call"),
2575
- call_id: z14.string(),
2576
- name: z14.string(),
2577
- arguments: z14.string(),
2578
- id: z14.string()
2644
+ imageGenerationCallItem,
2645
+ z15.object({
2646
+ type: z15.literal("function_call"),
2647
+ call_id: z15.string(),
2648
+ name: z15.string(),
2649
+ arguments: z15.string(),
2650
+ id: z15.string()
2579
2651
  }),
2580
2652
  webSearchCallItem,
2581
- z14.object({
2582
- type: z14.literal("computer_call"),
2583
- id: z14.string(),
2584
- status: z14.string().optional()
2653
+ z15.object({
2654
+ type: z15.literal("computer_call"),
2655
+ id: z15.string(),
2656
+ status: z15.string().optional()
2585
2657
  }),
2586
- z14.object({
2587
- type: z14.literal("file_search_call"),
2588
- id: z14.string(),
2589
- status: z14.string().optional(),
2590
- queries: z14.array(z14.string()).nullish(),
2591
- results: z14.array(
2592
- z14.object({
2593
- attributes: z14.object({
2594
- file_id: z14.string(),
2595
- filename: z14.string(),
2596
- score: z14.number(),
2597
- text: z14.string()
2658
+ z15.object({
2659
+ type: z15.literal("file_search_call"),
2660
+ id: z15.string(),
2661
+ status: z15.string().optional(),
2662
+ queries: z15.array(z15.string()).nullish(),
2663
+ results: z15.array(
2664
+ z15.object({
2665
+ attributes: z15.object({
2666
+ file_id: z15.string(),
2667
+ filename: z15.string(),
2668
+ score: z15.number(),
2669
+ text: z15.string()
2598
2670
  })
2599
2671
  })
2600
2672
  ).nullish()
2601
2673
  }),
2602
- z14.object({
2603
- type: z14.literal("reasoning"),
2604
- id: z14.string(),
2605
- encrypted_content: z14.string().nullish(),
2606
- summary: z14.array(
2607
- z14.object({
2608
- type: z14.literal("summary_text"),
2609
- text: z14.string()
2674
+ z15.object({
2675
+ type: z15.literal("reasoning"),
2676
+ id: z15.string(),
2677
+ encrypted_content: z15.string().nullish(),
2678
+ summary: z15.array(
2679
+ z15.object({
2680
+ type: z15.literal("summary_text"),
2681
+ text: z15.string()
2610
2682
  })
2611
2683
  )
2612
2684
  })
2613
2685
  ])
2614
2686
  ),
2615
- service_tier: z14.string().nullish(),
2616
- incomplete_details: z14.object({ reason: z14.string() }).nullable(),
2687
+ service_tier: z15.string().nullish(),
2688
+ incomplete_details: z15.object({ reason: z15.string() }).nullable(),
2617
2689
  usage: usageSchema2
2618
2690
  })
2619
2691
  ),
@@ -2654,6 +2726,25 @@ var OpenAIResponsesLanguageModel = class {
2654
2726
  }
2655
2727
  break;
2656
2728
  }
2729
+ case "image_generation_call": {
2730
+ content.push({
2731
+ type: "tool-call",
2732
+ toolCallId: part.id,
2733
+ toolName: "image_generation",
2734
+ input: "{}",
2735
+ providerExecuted: true
2736
+ });
2737
+ content.push({
2738
+ type: "tool-result",
2739
+ toolCallId: part.id,
2740
+ toolName: "image_generation",
2741
+ result: {
2742
+ result: part.result
2743
+ },
2744
+ providerExecuted: true
2745
+ });
2746
+ break;
2747
+ }
2657
2748
  case "message": {
2658
2749
  for (const contentPart of part.content) {
2659
2750
  if (((_c = (_b = options.providerOptions) == null ? void 0 : _b.openai) == null ? void 0 : _c.logprobs) && contentPart.logprobs) {
@@ -2917,6 +3008,14 @@ var OpenAIResponsesLanguageModel = class {
2917
3008
  id: value.item.id,
2918
3009
  toolName: "file_search"
2919
3010
  });
3011
+ } else if (value.item.type === "image_generation_call") {
3012
+ controller.enqueue({
3013
+ type: "tool-call",
3014
+ toolCallId: value.item.id,
3015
+ toolName: "image_generation",
3016
+ input: "{}",
3017
+ providerExecuted: true
3018
+ });
2920
3019
  } else if (value.item.type === "message") {
2921
3020
  controller.enqueue({
2922
3021
  type: "text-start",
@@ -3050,6 +3149,16 @@ var OpenAIResponsesLanguageModel = class {
3050
3149
  },
3051
3150
  providerExecuted: true
3052
3151
  });
3152
+ } else if (value.item.type === "image_generation_call") {
3153
+ controller.enqueue({
3154
+ type: "tool-result",
3155
+ toolCallId: value.item.id,
3156
+ toolName: "image_generation",
3157
+ result: {
3158
+ result: value.item.result
3159
+ },
3160
+ providerExecuted: true
3161
+ });
3053
3162
  } else if (value.item.type === "message") {
3054
3163
  controller.enqueue({
3055
3164
  type: "text-end",
@@ -3186,177 +3295,182 @@ var OpenAIResponsesLanguageModel = class {
3186
3295
  };
3187
3296
  }
3188
3297
  };
3189
- var usageSchema2 = z14.object({
3190
- input_tokens: z14.number(),
3191
- input_tokens_details: z14.object({ cached_tokens: z14.number().nullish() }).nullish(),
3192
- output_tokens: z14.number(),
3193
- output_tokens_details: z14.object({ reasoning_tokens: z14.number().nullish() }).nullish()
3298
+ var usageSchema2 = z15.object({
3299
+ input_tokens: z15.number(),
3300
+ input_tokens_details: z15.object({ cached_tokens: z15.number().nullish() }).nullish(),
3301
+ output_tokens: z15.number(),
3302
+ output_tokens_details: z15.object({ reasoning_tokens: z15.number().nullish() }).nullish()
3194
3303
  });
3195
- var textDeltaChunkSchema = z14.object({
3196
- type: z14.literal("response.output_text.delta"),
3197
- item_id: z14.string(),
3198
- delta: z14.string(),
3304
+ var textDeltaChunkSchema = z15.object({
3305
+ type: z15.literal("response.output_text.delta"),
3306
+ item_id: z15.string(),
3307
+ delta: z15.string(),
3199
3308
  logprobs: LOGPROBS_SCHEMA.nullish()
3200
3309
  });
3201
- var errorChunkSchema = z14.object({
3202
- type: z14.literal("error"),
3203
- code: z14.string(),
3204
- message: z14.string(),
3205
- param: z14.string().nullish(),
3206
- sequence_number: z14.number()
3310
+ var errorChunkSchema = z15.object({
3311
+ type: z15.literal("error"),
3312
+ code: z15.string(),
3313
+ message: z15.string(),
3314
+ param: z15.string().nullish(),
3315
+ sequence_number: z15.number()
3207
3316
  });
3208
- var responseFinishedChunkSchema = z14.object({
3209
- type: z14.enum(["response.completed", "response.incomplete"]),
3210
- response: z14.object({
3211
- incomplete_details: z14.object({ reason: z14.string() }).nullish(),
3317
+ var responseFinishedChunkSchema = z15.object({
3318
+ type: z15.enum(["response.completed", "response.incomplete"]),
3319
+ response: z15.object({
3320
+ incomplete_details: z15.object({ reason: z15.string() }).nullish(),
3212
3321
  usage: usageSchema2,
3213
- service_tier: z14.string().nullish()
3322
+ service_tier: z15.string().nullish()
3214
3323
  })
3215
3324
  });
3216
- var responseCreatedChunkSchema = z14.object({
3217
- type: z14.literal("response.created"),
3218
- response: z14.object({
3219
- id: z14.string(),
3220
- created_at: z14.number(),
3221
- model: z14.string(),
3222
- service_tier: z14.string().nullish()
3325
+ var responseCreatedChunkSchema = z15.object({
3326
+ type: z15.literal("response.created"),
3327
+ response: z15.object({
3328
+ id: z15.string(),
3329
+ created_at: z15.number(),
3330
+ model: z15.string(),
3331
+ service_tier: z15.string().nullish()
3223
3332
  })
3224
3333
  });
3225
- var responseOutputItemAddedSchema = z14.object({
3226
- type: z14.literal("response.output_item.added"),
3227
- output_index: z14.number(),
3228
- item: z14.discriminatedUnion("type", [
3229
- z14.object({
3230
- type: z14.literal("message"),
3231
- id: z14.string()
3334
+ var responseOutputItemAddedSchema = z15.object({
3335
+ type: z15.literal("response.output_item.added"),
3336
+ output_index: z15.number(),
3337
+ item: z15.discriminatedUnion("type", [
3338
+ z15.object({
3339
+ type: z15.literal("message"),
3340
+ id: z15.string()
3232
3341
  }),
3233
- z14.object({
3234
- type: z14.literal("reasoning"),
3235
- id: z14.string(),
3236
- encrypted_content: z14.string().nullish()
3342
+ z15.object({
3343
+ type: z15.literal("reasoning"),
3344
+ id: z15.string(),
3345
+ encrypted_content: z15.string().nullish()
3237
3346
  }),
3238
- z14.object({
3239
- type: z14.literal("function_call"),
3240
- id: z14.string(),
3241
- call_id: z14.string(),
3242
- name: z14.string(),
3243
- arguments: z14.string()
3347
+ z15.object({
3348
+ type: z15.literal("function_call"),
3349
+ id: z15.string(),
3350
+ call_id: z15.string(),
3351
+ name: z15.string(),
3352
+ arguments: z15.string()
3244
3353
  }),
3245
- z14.object({
3246
- type: z14.literal("web_search_call"),
3247
- id: z14.string(),
3248
- status: z14.string(),
3249
- action: z14.object({
3250
- type: z14.literal("search"),
3251
- query: z14.string().optional()
3354
+ z15.object({
3355
+ type: z15.literal("web_search_call"),
3356
+ id: z15.string(),
3357
+ status: z15.string(),
3358
+ action: z15.object({
3359
+ type: z15.literal("search"),
3360
+ query: z15.string().optional()
3252
3361
  }).nullish()
3253
3362
  }),
3254
- z14.object({
3255
- type: z14.literal("computer_call"),
3256
- id: z14.string(),
3257
- status: z14.string()
3363
+ z15.object({
3364
+ type: z15.literal("computer_call"),
3365
+ id: z15.string(),
3366
+ status: z15.string()
3258
3367
  }),
3259
- z14.object({
3260
- type: z14.literal("file_search_call"),
3261
- id: z14.string(),
3262
- status: z14.string(),
3263
- queries: z14.array(z14.string()).nullish(),
3264
- results: z14.array(
3265
- z14.object({
3266
- attributes: z14.object({
3267
- file_id: z14.string(),
3268
- filename: z14.string(),
3269
- score: z14.number(),
3270
- text: z14.string()
3368
+ z15.object({
3369
+ type: z15.literal("file_search_call"),
3370
+ id: z15.string(),
3371
+ status: z15.string(),
3372
+ queries: z15.array(z15.string()).nullish(),
3373
+ results: z15.array(
3374
+ z15.object({
3375
+ attributes: z15.object({
3376
+ file_id: z15.string(),
3377
+ filename: z15.string(),
3378
+ score: z15.number(),
3379
+ text: z15.string()
3271
3380
  })
3272
3381
  })
3273
3382
  ).optional()
3383
+ }),
3384
+ z15.object({
3385
+ type: z15.literal("image_generation_call"),
3386
+ id: z15.string()
3274
3387
  })
3275
3388
  ])
3276
3389
  });
3277
- var responseOutputItemDoneSchema = z14.object({
3278
- type: z14.literal("response.output_item.done"),
3279
- output_index: z14.number(),
3280
- item: z14.discriminatedUnion("type", [
3281
- z14.object({
3282
- type: z14.literal("message"),
3283
- id: z14.string()
3390
+ var responseOutputItemDoneSchema = z15.object({
3391
+ type: z15.literal("response.output_item.done"),
3392
+ output_index: z15.number(),
3393
+ item: z15.discriminatedUnion("type", [
3394
+ z15.object({
3395
+ type: z15.literal("message"),
3396
+ id: z15.string()
3284
3397
  }),
3285
- z14.object({
3286
- type: z14.literal("reasoning"),
3287
- id: z14.string(),
3288
- encrypted_content: z14.string().nullish()
3398
+ z15.object({
3399
+ type: z15.literal("reasoning"),
3400
+ id: z15.string(),
3401
+ encrypted_content: z15.string().nullish()
3289
3402
  }),
3290
- z14.object({
3291
- type: z14.literal("function_call"),
3292
- id: z14.string(),
3293
- call_id: z14.string(),
3294
- name: z14.string(),
3295
- arguments: z14.string(),
3296
- status: z14.literal("completed")
3403
+ z15.object({
3404
+ type: z15.literal("function_call"),
3405
+ id: z15.string(),
3406
+ call_id: z15.string(),
3407
+ name: z15.string(),
3408
+ arguments: z15.string(),
3409
+ status: z15.literal("completed")
3297
3410
  }),
3298
3411
  codeInterpreterCallItem,
3412
+ imageGenerationCallItem,
3299
3413
  webSearchCallItem,
3300
- z14.object({
3301
- type: z14.literal("computer_call"),
3302
- id: z14.string(),
3303
- status: z14.literal("completed")
3414
+ z15.object({
3415
+ type: z15.literal("computer_call"),
3416
+ id: z15.string(),
3417
+ status: z15.literal("completed")
3304
3418
  }),
3305
- z14.object({
3306
- type: z14.literal("file_search_call"),
3307
- id: z14.string(),
3308
- status: z14.literal("completed"),
3309
- queries: z14.array(z14.string()).nullish(),
3310
- results: z14.array(
3311
- z14.object({
3312
- attributes: z14.object({
3313
- file_id: z14.string(),
3314
- filename: z14.string(),
3315
- score: z14.number(),
3316
- text: z14.string()
3419
+ z15.object({
3420
+ type: z15.literal("file_search_call"),
3421
+ id: z15.string(),
3422
+ status: z15.literal("completed"),
3423
+ queries: z15.array(z15.string()).nullish(),
3424
+ results: z15.array(
3425
+ z15.object({
3426
+ attributes: z15.object({
3427
+ file_id: z15.string(),
3428
+ filename: z15.string(),
3429
+ score: z15.number(),
3430
+ text: z15.string()
3317
3431
  })
3318
3432
  })
3319
3433
  ).nullish()
3320
3434
  })
3321
3435
  ])
3322
3436
  });
3323
- var responseFunctionCallArgumentsDeltaSchema = z14.object({
3324
- type: z14.literal("response.function_call_arguments.delta"),
3325
- item_id: z14.string(),
3326
- output_index: z14.number(),
3327
- delta: z14.string()
3437
+ var responseFunctionCallArgumentsDeltaSchema = z15.object({
3438
+ type: z15.literal("response.function_call_arguments.delta"),
3439
+ item_id: z15.string(),
3440
+ output_index: z15.number(),
3441
+ delta: z15.string()
3328
3442
  });
3329
- var responseAnnotationAddedSchema = z14.object({
3330
- type: z14.literal("response.output_text.annotation.added"),
3331
- annotation: z14.discriminatedUnion("type", [
3332
- z14.object({
3333
- type: z14.literal("url_citation"),
3334
- url: z14.string(),
3335
- title: z14.string()
3443
+ var responseAnnotationAddedSchema = z15.object({
3444
+ type: z15.literal("response.output_text.annotation.added"),
3445
+ annotation: z15.discriminatedUnion("type", [
3446
+ z15.object({
3447
+ type: z15.literal("url_citation"),
3448
+ url: z15.string(),
3449
+ title: z15.string()
3336
3450
  }),
3337
- z14.object({
3338
- type: z14.literal("file_citation"),
3339
- file_id: z14.string(),
3340
- filename: z14.string().nullish(),
3341
- index: z14.number().nullish(),
3342
- start_index: z14.number().nullish(),
3343
- end_index: z14.number().nullish(),
3344
- quote: z14.string().nullish()
3451
+ z15.object({
3452
+ type: z15.literal("file_citation"),
3453
+ file_id: z15.string(),
3454
+ filename: z15.string().nullish(),
3455
+ index: z15.number().nullish(),
3456
+ start_index: z15.number().nullish(),
3457
+ end_index: z15.number().nullish(),
3458
+ quote: z15.string().nullish()
3345
3459
  })
3346
3460
  ])
3347
3461
  });
3348
- var responseReasoningSummaryPartAddedSchema = z14.object({
3349
- type: z14.literal("response.reasoning_summary_part.added"),
3350
- item_id: z14.string(),
3351
- summary_index: z14.number()
3462
+ var responseReasoningSummaryPartAddedSchema = z15.object({
3463
+ type: z15.literal("response.reasoning_summary_part.added"),
3464
+ item_id: z15.string(),
3465
+ summary_index: z15.number()
3352
3466
  });
3353
- var responseReasoningSummaryTextDeltaSchema = z14.object({
3354
- type: z14.literal("response.reasoning_summary_text.delta"),
3355
- item_id: z14.string(),
3356
- summary_index: z14.number(),
3357
- delta: z14.string()
3467
+ var responseReasoningSummaryTextDeltaSchema = z15.object({
3468
+ type: z15.literal("response.reasoning_summary_text.delta"),
3469
+ item_id: z15.string(),
3470
+ summary_index: z15.number(),
3471
+ delta: z15.string()
3358
3472
  });
3359
- var openaiResponsesChunkSchema = z14.union([
3473
+ var openaiResponsesChunkSchema = z15.union([
3360
3474
  textDeltaChunkSchema,
3361
3475
  responseFinishedChunkSchema,
3362
3476
  responseCreatedChunkSchema,
@@ -3367,7 +3481,7 @@ var openaiResponsesChunkSchema = z14.union([
3367
3481
  responseReasoningSummaryPartAddedSchema,
3368
3482
  responseReasoningSummaryTextDeltaSchema,
3369
3483
  errorChunkSchema,
3370
- z14.object({ type: z14.string() }).loose()
3484
+ z15.object({ type: z15.string() }).loose()
3371
3485
  // fallback for unknown chunks
3372
3486
  ]);
3373
3487
  function isTextDeltaChunk(chunk) {
@@ -3440,27 +3554,15 @@ function getResponsesModelConfig(modelId) {
3440
3554
  isReasoningModel: false
3441
3555
  };
3442
3556
  }
3443
- var openaiResponsesProviderOptionsSchema = z14.object({
3444
- metadata: z14.any().nullish(),
3445
- parallelToolCalls: z14.boolean().nullish(),
3446
- previousResponseId: z14.string().nullish(),
3447
- store: z14.boolean().nullish(),
3448
- user: z14.string().nullish(),
3449
- reasoningEffort: z14.string().nullish(),
3450
- strictJsonSchema: z14.boolean().nullish(),
3451
- instructions: z14.string().nullish(),
3452
- reasoningSummary: z14.string().nullish(),
3453
- serviceTier: z14.enum(["auto", "flex", "priority"]).nullish(),
3454
- include: z14.array(
3455
- z14.enum([
3557
+ var openaiResponsesProviderOptionsSchema = z15.object({
3558
+ include: z15.array(
3559
+ z15.enum([
3456
3560
  "reasoning.encrypted_content",
3457
3561
  "file_search_call.results",
3458
3562
  "message.output_text.logprobs"
3459
3563
  ])
3460
3564
  ).nullish(),
3461
- textVerbosity: z14.enum(["low", "medium", "high"]).nullish(),
3462
- promptCacheKey: z14.string().nullish(),
3463
- safetyIdentifier: z14.string().nullish(),
3565
+ instructions: z15.string().nullish(),
3464
3566
  /**
3465
3567
  * Return the log probabilities of the tokens.
3466
3568
  *
@@ -3473,7 +3575,25 @@ var openaiResponsesProviderOptionsSchema = z14.object({
3473
3575
  * @see https://platform.openai.com/docs/api-reference/responses/create
3474
3576
  * @see https://cookbook.openai.com/examples/using_logprobs
3475
3577
  */
3476
- logprobs: z14.union([z14.boolean(), z14.number().min(1).max(TOP_LOGPROBS_MAX)]).optional()
3578
+ logprobs: z15.union([z15.boolean(), z15.number().min(1).max(TOP_LOGPROBS_MAX)]).optional(),
3579
+ /**
3580
+ * The maximum number of total calls to built-in tools that can be processed in a response.
3581
+ * This maximum number applies across all built-in tool calls, not per individual tool.
3582
+ * Any further attempts to call a tool by the model will be ignored.
3583
+ */
3584
+ maxToolCalls: z15.number().nullish(),
3585
+ metadata: z15.any().nullish(),
3586
+ parallelToolCalls: z15.boolean().nullish(),
3587
+ previousResponseId: z15.string().nullish(),
3588
+ promptCacheKey: z15.string().nullish(),
3589
+ reasoningEffort: z15.string().nullish(),
3590
+ reasoningSummary: z15.string().nullish(),
3591
+ safetyIdentifier: z15.string().nullish(),
3592
+ serviceTier: z15.enum(["auto", "flex", "priority"]).nullish(),
3593
+ store: z15.boolean().nullish(),
3594
+ strictJsonSchema: z15.boolean().nullish(),
3595
+ textVerbosity: z15.enum(["low", "medium", "high"]).nullish(),
3596
+ user: z15.string().nullish()
3477
3597
  });
3478
3598
 
3479
3599
  // src/speech/openai-speech-model.ts
@@ -3483,10 +3603,10 @@ import {
3483
3603
  parseProviderOptions as parseProviderOptions6,
3484
3604
  postJsonToApi as postJsonToApi6
3485
3605
  } from "@ai-sdk/provider-utils";
3486
- import { z as z15 } from "zod/v4";
3487
- var OpenAIProviderOptionsSchema = z15.object({
3488
- instructions: z15.string().nullish(),
3489
- speed: z15.number().min(0.25).max(4).default(1).nullish()
3606
+ import { z as z16 } from "zod/v4";
3607
+ var OpenAIProviderOptionsSchema = z16.object({
3608
+ instructions: z16.string().nullish(),
3609
+ speed: z16.number().min(0.25).max(4).default(1).nullish()
3490
3610
  });
3491
3611
  var OpenAISpeechModel = class {
3492
3612
  constructor(modelId, config) {
@@ -3597,33 +3717,33 @@ import {
3597
3717
  parseProviderOptions as parseProviderOptions7,
3598
3718
  postFormDataToApi
3599
3719
  } from "@ai-sdk/provider-utils";
3600
- import { z as z17 } from "zod/v4";
3720
+ import { z as z18 } from "zod/v4";
3601
3721
 
3602
3722
  // src/transcription/openai-transcription-options.ts
3603
- import { z as z16 } from "zod/v4";
3604
- var openAITranscriptionProviderOptions = z16.object({
3723
+ import { z as z17 } from "zod/v4";
3724
+ var openAITranscriptionProviderOptions = z17.object({
3605
3725
  /**
3606
3726
  * Additional information to include in the transcription response.
3607
3727
  */
3608
- include: z16.array(z16.string()).optional(),
3728
+ include: z17.array(z17.string()).optional(),
3609
3729
  /**
3610
3730
  * The language of the input audio in ISO-639-1 format.
3611
3731
  */
3612
- language: z16.string().optional(),
3732
+ language: z17.string().optional(),
3613
3733
  /**
3614
3734
  * An optional text to guide the model's style or continue a previous audio segment.
3615
3735
  */
3616
- prompt: z16.string().optional(),
3736
+ prompt: z17.string().optional(),
3617
3737
  /**
3618
3738
  * The sampling temperature, between 0 and 1.
3619
3739
  * @default 0
3620
3740
  */
3621
- temperature: z16.number().min(0).max(1).default(0).optional(),
3741
+ temperature: z17.number().min(0).max(1).default(0).optional(),
3622
3742
  /**
3623
3743
  * The timestamp granularities to populate for this transcription.
3624
3744
  * @default ['segment']
3625
3745
  */
3626
- timestampGranularities: z16.array(z16.enum(["word", "segment"])).default(["segment"]).optional()
3746
+ timestampGranularities: z17.array(z17.enum(["word", "segment"])).default(["segment"]).optional()
3627
3747
  });
3628
3748
 
3629
3749
  // src/transcription/openai-transcription-model.ts
@@ -3792,29 +3912,29 @@ var OpenAITranscriptionModel = class {
3792
3912
  };
3793
3913
  }
3794
3914
  };
3795
- var openaiTranscriptionResponseSchema = z17.object({
3796
- text: z17.string(),
3797
- language: z17.string().nullish(),
3798
- duration: z17.number().nullish(),
3799
- words: z17.array(
3800
- z17.object({
3801
- word: z17.string(),
3802
- start: z17.number(),
3803
- end: z17.number()
3915
+ var openaiTranscriptionResponseSchema = z18.object({
3916
+ text: z18.string(),
3917
+ language: z18.string().nullish(),
3918
+ duration: z18.number().nullish(),
3919
+ words: z18.array(
3920
+ z18.object({
3921
+ word: z18.string(),
3922
+ start: z18.number(),
3923
+ end: z18.number()
3804
3924
  })
3805
3925
  ).nullish(),
3806
- segments: z17.array(
3807
- z17.object({
3808
- id: z17.number(),
3809
- seek: z17.number(),
3810
- start: z17.number(),
3811
- end: z17.number(),
3812
- text: z17.string(),
3813
- tokens: z17.array(z17.number()),
3814
- temperature: z17.number(),
3815
- avg_logprob: z17.number(),
3816
- compression_ratio: z17.number(),
3817
- no_speech_prob: z17.number()
3926
+ segments: z18.array(
3927
+ z18.object({
3928
+ id: z18.number(),
3929
+ seek: z18.number(),
3930
+ start: z18.number(),
3931
+ end: z18.number(),
3932
+ text: z18.string(),
3933
+ tokens: z18.array(z18.number()),
3934
+ temperature: z18.number(),
3935
+ avg_logprob: z18.number(),
3936
+ compression_ratio: z18.number(),
3937
+ no_speech_prob: z18.number()
3818
3938
  })
3819
3939
  ).nullish()
3820
3940
  });