@ai-sdk/openai 2.0.29 → 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.
@@ -2155,37 +2155,37 @@ import {
2155
2155
  parseProviderOptions as parseProviderOptions7,
2156
2156
  postJsonToApi as postJsonToApi6
2157
2157
  } from "@ai-sdk/provider-utils";
2158
- import { z as z17 } from "zod/v4";
2158
+ import { z as z18 } from "zod/v4";
2159
2159
 
2160
- // src/responses/convert-to-openai-responses-messages.ts
2160
+ // src/responses/convert-to-openai-responses-input.ts
2161
2161
  import {
2162
2162
  UnsupportedFunctionalityError as UnsupportedFunctionalityError4
2163
2163
  } from "@ai-sdk/provider";
2164
- import { parseProviderOptions as parseProviderOptions6 } from "@ai-sdk/provider-utils";
2164
+ import { convertToBase64 as convertToBase642, parseProviderOptions as parseProviderOptions6 } from "@ai-sdk/provider-utils";
2165
2165
  import { z as z14 } from "zod/v4";
2166
- import { convertToBase64 as convertToBase642 } from "@ai-sdk/provider-utils";
2167
2166
  function isFileId(data, prefixes) {
2168
2167
  if (!prefixes) return false;
2169
2168
  return prefixes.some((prefix) => data.startsWith(prefix));
2170
2169
  }
2171
- async function convertToOpenAIResponsesMessages({
2170
+ async function convertToOpenAIResponsesInput({
2172
2171
  prompt,
2173
2172
  systemMessageMode,
2174
- fileIdPrefixes
2173
+ fileIdPrefixes,
2174
+ store
2175
2175
  }) {
2176
2176
  var _a, _b, _c, _d, _e, _f;
2177
- const messages = [];
2177
+ const input = [];
2178
2178
  const warnings = [];
2179
2179
  for (const { role, content } of prompt) {
2180
2180
  switch (role) {
2181
2181
  case "system": {
2182
2182
  switch (systemMessageMode) {
2183
2183
  case "system": {
2184
- messages.push({ role: "system", content });
2184
+ input.push({ role: "system", content });
2185
2185
  break;
2186
2186
  }
2187
2187
  case "developer": {
2188
- messages.push({ role: "developer", content });
2188
+ input.push({ role: "developer", content });
2189
2189
  break;
2190
2190
  }
2191
2191
  case "remove": {
@@ -2205,7 +2205,7 @@ async function convertToOpenAIResponsesMessages({
2205
2205
  break;
2206
2206
  }
2207
2207
  case "user": {
2208
- messages.push({
2208
+ input.push({
2209
2209
  role: "user",
2210
2210
  content: content.map((part, index) => {
2211
2211
  var _a2, _b2, _c2;
@@ -2250,10 +2250,11 @@ async function convertToOpenAIResponsesMessages({
2250
2250
  }
2251
2251
  case "assistant": {
2252
2252
  const reasoningMessages = {};
2253
+ const toolCallParts = {};
2253
2254
  for (const part of content) {
2254
2255
  switch (part.type) {
2255
2256
  case "text": {
2256
- messages.push({
2257
+ input.push({
2257
2258
  role: "assistant",
2258
2259
  content: [{ type: "output_text", text: part.text }],
2259
2260
  id: (_c = (_b = (_a = part.providerOptions) == null ? void 0 : _a.openai) == null ? void 0 : _b.itemId) != null ? _c : void 0
@@ -2261,10 +2262,11 @@ async function convertToOpenAIResponsesMessages({
2261
2262
  break;
2262
2263
  }
2263
2264
  case "tool-call": {
2265
+ toolCallParts[part.toolCallId] = part;
2264
2266
  if (part.providerExecuted) {
2265
2267
  break;
2266
2268
  }
2267
- messages.push({
2269
+ input.push({
2268
2270
  type: "function_call",
2269
2271
  call_id: part.toolCallId,
2270
2272
  name: part.toolName,
@@ -2274,10 +2276,14 @@ async function convertToOpenAIResponsesMessages({
2274
2276
  break;
2275
2277
  }
2276
2278
  case "tool-result": {
2277
- warnings.push({
2278
- type: "other",
2279
- message: `tool result parts in assistant messages are not supported for OpenAI responses`
2280
- });
2279
+ if (store) {
2280
+ input.push({ type: "item_reference", id: part.toolCallId });
2281
+ } else {
2282
+ warnings.push({
2283
+ type: "other",
2284
+ message: `Results for OpenAI tool ${part.toolName} are not sent to the API when store is false`
2285
+ });
2286
+ }
2281
2287
  break;
2282
2288
  }
2283
2289
  case "reasoning": {
@@ -2305,7 +2311,7 @@ async function convertToOpenAIResponsesMessages({
2305
2311
  encrypted_content: providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent,
2306
2312
  summary: summaryParts
2307
2313
  };
2308
- messages.push(reasoningMessages[reasoningId]);
2314
+ input.push(reasoningMessages[reasoningId]);
2309
2315
  } else {
2310
2316
  existingReasoningMessage.summary.push(...summaryParts);
2311
2317
  }
@@ -2336,7 +2342,7 @@ async function convertToOpenAIResponsesMessages({
2336
2342
  contentValue = JSON.stringify(output.value);
2337
2343
  break;
2338
2344
  }
2339
- messages.push({
2345
+ input.push({
2340
2346
  type: "function_call_output",
2341
2347
  call_id: part.toolCallId,
2342
2348
  output: contentValue
@@ -2350,7 +2356,7 @@ async function convertToOpenAIResponsesMessages({
2350
2356
  }
2351
2357
  }
2352
2358
  }
2353
- return { messages, warnings };
2359
+ return { input, warnings };
2354
2360
  }
2355
2361
  var openaiResponsesReasoningProviderOptionsSchema = z14.object({
2356
2362
  itemId: z14.string().nullish(),
@@ -2448,6 +2454,33 @@ var webSearchToolFactory = createProviderDefinedToolFactory3({
2448
2454
  })
2449
2455
  });
2450
2456
 
2457
+ // src/tool/image-generation.ts
2458
+ import { createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema2 } from "@ai-sdk/provider-utils";
2459
+ import { z as z17 } from "zod/v4";
2460
+ var imageGenerationArgsSchema = z17.object({
2461
+ background: z17.enum(["auto", "opaque", "transparent"]).optional(),
2462
+ inputFidelity: z17.enum(["low", "high"]).optional(),
2463
+ inputImageMask: z17.object({
2464
+ fileId: z17.string().optional(),
2465
+ imageUrl: z17.string().optional()
2466
+ }).optional(),
2467
+ model: z17.string().optional(),
2468
+ moderation: z17.enum(["auto"]).optional(),
2469
+ outputCompression: z17.number().int().min(0).max(100).optional(),
2470
+ outputFormat: z17.enum(["png", "jpeg", "webp"]).optional(),
2471
+ quality: z17.enum(["auto", "low", "medium", "high"]).optional(),
2472
+ size: z17.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
2473
+ }).strict();
2474
+ var imageGenerationOutputSchema = z17.object({
2475
+ result: z17.string()
2476
+ });
2477
+ var imageGenerationToolFactory = createProviderDefinedToolFactoryWithOutputSchema2({
2478
+ id: "openai.image_generation",
2479
+ name: "image_generation",
2480
+ inputSchema: z17.object({}),
2481
+ outputSchema: imageGenerationOutputSchema
2482
+ });
2483
+
2451
2484
  // src/responses/openai-responses-prepare-tools.ts
2452
2485
  function prepareResponsesTools({
2453
2486
  tools,
@@ -2511,8 +2544,23 @@ function prepareResponsesTools({
2511
2544
  });
2512
2545
  break;
2513
2546
  }
2514
- default: {
2515
- toolWarnings.push({ type: "unsupported-tool", tool });
2547
+ case "openai.image_generation": {
2548
+ const args = imageGenerationArgsSchema.parse(tool.args);
2549
+ openaiTools.push({
2550
+ type: "image_generation",
2551
+ background: args.background,
2552
+ input_fidelity: args.inputFidelity,
2553
+ input_image_mask: args.inputImageMask ? {
2554
+ file_id: args.inputImageMask.fileId,
2555
+ image_url: args.inputImageMask.imageUrl
2556
+ } : void 0,
2557
+ model: args.model,
2558
+ size: args.size,
2559
+ quality: args.quality,
2560
+ moderation: args.moderation,
2561
+ output_format: args.outputFormat,
2562
+ output_compression: args.outputCompression
2563
+ });
2516
2564
  break;
2517
2565
  }
2518
2566
  }
@@ -2535,7 +2583,7 @@ function prepareResponsesTools({
2535
2583
  case "tool":
2536
2584
  return {
2537
2585
  tools: openaiTools,
2538
- 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 },
2586
+ 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 },
2539
2587
  toolWarnings
2540
2588
  };
2541
2589
  default: {
@@ -2548,47 +2596,52 @@ function prepareResponsesTools({
2548
2596
  }
2549
2597
 
2550
2598
  // src/responses/openai-responses-language-model.ts
2551
- var webSearchCallItem = z17.object({
2552
- type: z17.literal("web_search_call"),
2553
- id: z17.string(),
2554
- status: z17.string(),
2555
- action: z17.discriminatedUnion("type", [
2556
- z17.object({
2557
- type: z17.literal("search"),
2558
- query: z17.string().nullish()
2599
+ var webSearchCallItem = z18.object({
2600
+ type: z18.literal("web_search_call"),
2601
+ id: z18.string(),
2602
+ status: z18.string(),
2603
+ action: z18.discriminatedUnion("type", [
2604
+ z18.object({
2605
+ type: z18.literal("search"),
2606
+ query: z18.string().nullish()
2559
2607
  }),
2560
- z17.object({
2561
- type: z17.literal("open_page"),
2562
- url: z17.string()
2608
+ z18.object({
2609
+ type: z18.literal("open_page"),
2610
+ url: z18.string()
2563
2611
  }),
2564
- z17.object({
2565
- type: z17.literal("find"),
2566
- url: z17.string(),
2567
- pattern: z17.string()
2612
+ z18.object({
2613
+ type: z18.literal("find"),
2614
+ url: z18.string(),
2615
+ pattern: z18.string()
2568
2616
  })
2569
2617
  ]).nullish()
2570
2618
  });
2571
- var codeInterpreterCallItem = z17.object({
2572
- type: z17.literal("code_interpreter_call"),
2573
- id: z17.string(),
2574
- code: z17.string().nullable(),
2575
- container_id: z17.string(),
2576
- outputs: z17.array(
2577
- z17.discriminatedUnion("type", [
2578
- z17.object({ type: z17.literal("logs"), logs: z17.string() }),
2579
- z17.object({ type: z17.literal("image"), url: z17.string() })
2619
+ var codeInterpreterCallItem = z18.object({
2620
+ type: z18.literal("code_interpreter_call"),
2621
+ id: z18.string(),
2622
+ code: z18.string().nullable(),
2623
+ container_id: z18.string(),
2624
+ outputs: z18.array(
2625
+ z18.discriminatedUnion("type", [
2626
+ z18.object({ type: z18.literal("logs"), logs: z18.string() }),
2627
+ z18.object({ type: z18.literal("image"), url: z18.string() })
2580
2628
  ])
2581
2629
  ).nullable()
2582
2630
  });
2631
+ var imageGenerationCallItem = z18.object({
2632
+ type: z18.literal("image_generation_call"),
2633
+ id: z18.string(),
2634
+ result: z18.string()
2635
+ });
2583
2636
  var TOP_LOGPROBS_MAX = 20;
2584
- var LOGPROBS_SCHEMA = z17.array(
2585
- z17.object({
2586
- token: z17.string(),
2587
- logprob: z17.number(),
2588
- top_logprobs: z17.array(
2589
- z17.object({
2590
- token: z17.string(),
2591
- logprob: z17.number()
2637
+ var LOGPROBS_SCHEMA = z18.array(
2638
+ z18.object({
2639
+ token: z18.string(),
2640
+ logprob: z18.number(),
2641
+ top_logprobs: z18.array(
2642
+ z18.object({
2643
+ token: z18.string(),
2644
+ logprob: z18.number()
2592
2645
  })
2593
2646
  )
2594
2647
  })
@@ -2621,7 +2674,7 @@ var OpenAIResponsesLanguageModel = class {
2621
2674
  toolChoice,
2622
2675
  responseFormat
2623
2676
  }) {
2624
- var _a, _b, _c, _d;
2677
+ var _a, _b, _c, _d, _e;
2625
2678
  const warnings = [];
2626
2679
  const modelConfig = getResponsesModelConfig(this.modelId);
2627
2680
  if (topK != null) {
@@ -2645,32 +2698,33 @@ var OpenAIResponsesLanguageModel = class {
2645
2698
  if (stopSequences != null) {
2646
2699
  warnings.push({ type: "unsupported-setting", setting: "stopSequences" });
2647
2700
  }
2648
- const { messages, warnings: messageWarnings } = await convertToOpenAIResponsesMessages({
2649
- prompt,
2650
- systemMessageMode: modelConfig.systemMessageMode,
2651
- fileIdPrefixes: this.config.fileIdPrefixes
2652
- });
2653
- warnings.push(...messageWarnings);
2654
2701
  const openaiOptions = await parseProviderOptions7({
2655
2702
  provider: "openai",
2656
2703
  providerOptions,
2657
2704
  schema: openaiResponsesProviderOptionsSchema
2658
2705
  });
2659
- const strictJsonSchema = (_a = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _a : false;
2706
+ const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
2707
+ prompt,
2708
+ systemMessageMode: modelConfig.systemMessageMode,
2709
+ fileIdPrefixes: this.config.fileIdPrefixes,
2710
+ store: (_a = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _a : true
2711
+ });
2712
+ warnings.push(...inputWarnings);
2713
+ const strictJsonSchema = (_b = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _b : false;
2660
2714
  let include = openaiOptions == null ? void 0 : openaiOptions.include;
2661
2715
  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;
2662
2716
  include = topLogprobs ? Array.isArray(include) ? [...include, "message.output_text.logprobs"] : ["message.output_text.logprobs"] : include;
2663
- const webSearchToolName = (_b = tools == null ? void 0 : tools.find(
2717
+ const webSearchToolName = (_c = tools == null ? void 0 : tools.find(
2664
2718
  (tool) => tool.type === "provider-defined" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
2665
- )) == null ? void 0 : _b.name;
2719
+ )) == null ? void 0 : _c.name;
2666
2720
  include = webSearchToolName ? Array.isArray(include) ? [...include, "web_search_call.action.sources"] : ["web_search_call.action.sources"] : include;
2667
- const codeInterpreterToolName = (_c = tools == null ? void 0 : tools.find(
2721
+ const codeInterpreterToolName = (_d = tools == null ? void 0 : tools.find(
2668
2722
  (tool) => tool.type === "provider-defined" && tool.id === "openai.code_interpreter"
2669
- )) == null ? void 0 : _c.name;
2723
+ )) == null ? void 0 : _d.name;
2670
2724
  include = codeInterpreterToolName ? Array.isArray(include) ? [...include, "code_interpreter_call.outputs"] : ["code_interpreter_call.outputs"] : include;
2671
2725
  const baseArgs = {
2672
2726
  model: this.modelId,
2673
- input: messages,
2727
+ input,
2674
2728
  temperature,
2675
2729
  top_p: topP,
2676
2730
  max_output_tokens: maxOutputTokens,
@@ -2680,7 +2734,7 @@ var OpenAIResponsesLanguageModel = class {
2680
2734
  format: responseFormat.schema != null ? {
2681
2735
  type: "json_schema",
2682
2736
  strict: strictJsonSchema,
2683
- name: (_d = responseFormat.name) != null ? _d : "response",
2737
+ name: (_e = responseFormat.name) != null ? _e : "response",
2684
2738
  description: responseFormat.description,
2685
2739
  schema: responseFormat.schema
2686
2740
  } : { type: "json_object" }
@@ -2691,6 +2745,7 @@ var OpenAIResponsesLanguageModel = class {
2691
2745
  }
2692
2746
  },
2693
2747
  // provider options:
2748
+ max_tool_calls: openaiOptions == null ? void 0 : openaiOptions.maxToolCalls,
2694
2749
  metadata: openaiOptions == null ? void 0 : openaiOptions.metadata,
2695
2750
  parallel_tool_calls: openaiOptions == null ? void 0 : openaiOptions.parallelToolCalls,
2696
2751
  previous_response_id: openaiOptions == null ? void 0 : openaiOptions.previousResponseId,
@@ -2806,45 +2861,45 @@ var OpenAIResponsesLanguageModel = class {
2806
2861
  body,
2807
2862
  failedResponseHandler: openaiFailedResponseHandler,
2808
2863
  successfulResponseHandler: createJsonResponseHandler6(
2809
- z17.object({
2810
- id: z17.string(),
2811
- created_at: z17.number(),
2812
- error: z17.object({
2813
- code: z17.string(),
2814
- message: z17.string()
2864
+ z18.object({
2865
+ id: z18.string(),
2866
+ created_at: z18.number(),
2867
+ error: z18.object({
2868
+ code: z18.string(),
2869
+ message: z18.string()
2815
2870
  }).nullish(),
2816
- model: z17.string(),
2817
- output: z17.array(
2818
- z17.discriminatedUnion("type", [
2819
- z17.object({
2820
- type: z17.literal("message"),
2821
- role: z17.literal("assistant"),
2822
- id: z17.string(),
2823
- content: z17.array(
2824
- z17.object({
2825
- type: z17.literal("output_text"),
2826
- text: z17.string(),
2871
+ model: z18.string(),
2872
+ output: z18.array(
2873
+ z18.discriminatedUnion("type", [
2874
+ z18.object({
2875
+ type: z18.literal("message"),
2876
+ role: z18.literal("assistant"),
2877
+ id: z18.string(),
2878
+ content: z18.array(
2879
+ z18.object({
2880
+ type: z18.literal("output_text"),
2881
+ text: z18.string(),
2827
2882
  logprobs: LOGPROBS_SCHEMA.nullish(),
2828
- annotations: z17.array(
2829
- z17.discriminatedUnion("type", [
2830
- z17.object({
2831
- type: z17.literal("url_citation"),
2832
- start_index: z17.number(),
2833
- end_index: z17.number(),
2834
- url: z17.string(),
2835
- title: z17.string()
2883
+ annotations: z18.array(
2884
+ z18.discriminatedUnion("type", [
2885
+ z18.object({
2886
+ type: z18.literal("url_citation"),
2887
+ start_index: z18.number(),
2888
+ end_index: z18.number(),
2889
+ url: z18.string(),
2890
+ title: z18.string()
2836
2891
  }),
2837
- z17.object({
2838
- type: z17.literal("file_citation"),
2839
- file_id: z17.string(),
2840
- filename: z17.string().nullish(),
2841
- index: z17.number().nullish(),
2842
- start_index: z17.number().nullish(),
2843
- end_index: z17.number().nullish(),
2844
- quote: z17.string().nullish()
2892
+ z18.object({
2893
+ type: z18.literal("file_citation"),
2894
+ file_id: z18.string(),
2895
+ filename: z18.string().nullish(),
2896
+ index: z18.number().nullish(),
2897
+ start_index: z18.number().nullish(),
2898
+ end_index: z18.number().nullish(),
2899
+ quote: z18.string().nullish()
2845
2900
  }),
2846
- z17.object({
2847
- type: z17.literal("container_file_citation")
2901
+ z18.object({
2902
+ type: z18.literal("container_file_citation")
2848
2903
  })
2849
2904
  ])
2850
2905
  )
@@ -2852,50 +2907,51 @@ var OpenAIResponsesLanguageModel = class {
2852
2907
  )
2853
2908
  }),
2854
2909
  codeInterpreterCallItem,
2855
- z17.object({
2856
- type: z17.literal("function_call"),
2857
- call_id: z17.string(),
2858
- name: z17.string(),
2859
- arguments: z17.string(),
2860
- id: z17.string()
2910
+ imageGenerationCallItem,
2911
+ z18.object({
2912
+ type: z18.literal("function_call"),
2913
+ call_id: z18.string(),
2914
+ name: z18.string(),
2915
+ arguments: z18.string(),
2916
+ id: z18.string()
2861
2917
  }),
2862
2918
  webSearchCallItem,
2863
- z17.object({
2864
- type: z17.literal("computer_call"),
2865
- id: z17.string(),
2866
- status: z17.string().optional()
2919
+ z18.object({
2920
+ type: z18.literal("computer_call"),
2921
+ id: z18.string(),
2922
+ status: z18.string().optional()
2867
2923
  }),
2868
- z17.object({
2869
- type: z17.literal("file_search_call"),
2870
- id: z17.string(),
2871
- status: z17.string().optional(),
2872
- queries: z17.array(z17.string()).nullish(),
2873
- results: z17.array(
2874
- z17.object({
2875
- attributes: z17.object({
2876
- file_id: z17.string(),
2877
- filename: z17.string(),
2878
- score: z17.number(),
2879
- text: z17.string()
2924
+ z18.object({
2925
+ type: z18.literal("file_search_call"),
2926
+ id: z18.string(),
2927
+ status: z18.string().optional(),
2928
+ queries: z18.array(z18.string()).nullish(),
2929
+ results: z18.array(
2930
+ z18.object({
2931
+ attributes: z18.object({
2932
+ file_id: z18.string(),
2933
+ filename: z18.string(),
2934
+ score: z18.number(),
2935
+ text: z18.string()
2880
2936
  })
2881
2937
  })
2882
2938
  ).nullish()
2883
2939
  }),
2884
- z17.object({
2885
- type: z17.literal("reasoning"),
2886
- id: z17.string(),
2887
- encrypted_content: z17.string().nullish(),
2888
- summary: z17.array(
2889
- z17.object({
2890
- type: z17.literal("summary_text"),
2891
- text: z17.string()
2940
+ z18.object({
2941
+ type: z18.literal("reasoning"),
2942
+ id: z18.string(),
2943
+ encrypted_content: z18.string().nullish(),
2944
+ summary: z18.array(
2945
+ z18.object({
2946
+ type: z18.literal("summary_text"),
2947
+ text: z18.string()
2892
2948
  })
2893
2949
  )
2894
2950
  })
2895
2951
  ])
2896
2952
  ),
2897
- service_tier: z17.string().nullish(),
2898
- incomplete_details: z17.object({ reason: z17.string() }).nullable(),
2953
+ service_tier: z18.string().nullish(),
2954
+ incomplete_details: z18.object({ reason: z18.string() }).nullable(),
2899
2955
  usage: usageSchema2
2900
2956
  })
2901
2957
  ),
@@ -2936,6 +2992,25 @@ var OpenAIResponsesLanguageModel = class {
2936
2992
  }
2937
2993
  break;
2938
2994
  }
2995
+ case "image_generation_call": {
2996
+ content.push({
2997
+ type: "tool-call",
2998
+ toolCallId: part.id,
2999
+ toolName: "image_generation",
3000
+ input: "{}",
3001
+ providerExecuted: true
3002
+ });
3003
+ content.push({
3004
+ type: "tool-result",
3005
+ toolCallId: part.id,
3006
+ toolName: "image_generation",
3007
+ result: {
3008
+ result: part.result
3009
+ },
3010
+ providerExecuted: true
3011
+ });
3012
+ break;
3013
+ }
2939
3014
  case "message": {
2940
3015
  for (const contentPart of part.content) {
2941
3016
  if (((_c = (_b = options.providerOptions) == null ? void 0 : _b.openai) == null ? void 0 : _c.logprobs) && contentPart.logprobs) {
@@ -3199,6 +3274,14 @@ var OpenAIResponsesLanguageModel = class {
3199
3274
  id: value.item.id,
3200
3275
  toolName: "file_search"
3201
3276
  });
3277
+ } else if (value.item.type === "image_generation_call") {
3278
+ controller.enqueue({
3279
+ type: "tool-call",
3280
+ toolCallId: value.item.id,
3281
+ toolName: "image_generation",
3282
+ input: "{}",
3283
+ providerExecuted: true
3284
+ });
3202
3285
  } else if (value.item.type === "message") {
3203
3286
  controller.enqueue({
3204
3287
  type: "text-start",
@@ -3332,6 +3415,16 @@ var OpenAIResponsesLanguageModel = class {
3332
3415
  },
3333
3416
  providerExecuted: true
3334
3417
  });
3418
+ } else if (value.item.type === "image_generation_call") {
3419
+ controller.enqueue({
3420
+ type: "tool-result",
3421
+ toolCallId: value.item.id,
3422
+ toolName: "image_generation",
3423
+ result: {
3424
+ result: value.item.result
3425
+ },
3426
+ providerExecuted: true
3427
+ });
3335
3428
  } else if (value.item.type === "message") {
3336
3429
  controller.enqueue({
3337
3430
  type: "text-end",
@@ -3468,177 +3561,182 @@ var OpenAIResponsesLanguageModel = class {
3468
3561
  };
3469
3562
  }
3470
3563
  };
3471
- var usageSchema2 = z17.object({
3472
- input_tokens: z17.number(),
3473
- input_tokens_details: z17.object({ cached_tokens: z17.number().nullish() }).nullish(),
3474
- output_tokens: z17.number(),
3475
- output_tokens_details: z17.object({ reasoning_tokens: z17.number().nullish() }).nullish()
3564
+ var usageSchema2 = z18.object({
3565
+ input_tokens: z18.number(),
3566
+ input_tokens_details: z18.object({ cached_tokens: z18.number().nullish() }).nullish(),
3567
+ output_tokens: z18.number(),
3568
+ output_tokens_details: z18.object({ reasoning_tokens: z18.number().nullish() }).nullish()
3476
3569
  });
3477
- var textDeltaChunkSchema = z17.object({
3478
- type: z17.literal("response.output_text.delta"),
3479
- item_id: z17.string(),
3480
- delta: z17.string(),
3570
+ var textDeltaChunkSchema = z18.object({
3571
+ type: z18.literal("response.output_text.delta"),
3572
+ item_id: z18.string(),
3573
+ delta: z18.string(),
3481
3574
  logprobs: LOGPROBS_SCHEMA.nullish()
3482
3575
  });
3483
- var errorChunkSchema = z17.object({
3484
- type: z17.literal("error"),
3485
- code: z17.string(),
3486
- message: z17.string(),
3487
- param: z17.string().nullish(),
3488
- sequence_number: z17.number()
3576
+ var errorChunkSchema = z18.object({
3577
+ type: z18.literal("error"),
3578
+ code: z18.string(),
3579
+ message: z18.string(),
3580
+ param: z18.string().nullish(),
3581
+ sequence_number: z18.number()
3489
3582
  });
3490
- var responseFinishedChunkSchema = z17.object({
3491
- type: z17.enum(["response.completed", "response.incomplete"]),
3492
- response: z17.object({
3493
- incomplete_details: z17.object({ reason: z17.string() }).nullish(),
3583
+ var responseFinishedChunkSchema = z18.object({
3584
+ type: z18.enum(["response.completed", "response.incomplete"]),
3585
+ response: z18.object({
3586
+ incomplete_details: z18.object({ reason: z18.string() }).nullish(),
3494
3587
  usage: usageSchema2,
3495
- service_tier: z17.string().nullish()
3588
+ service_tier: z18.string().nullish()
3496
3589
  })
3497
3590
  });
3498
- var responseCreatedChunkSchema = z17.object({
3499
- type: z17.literal("response.created"),
3500
- response: z17.object({
3501
- id: z17.string(),
3502
- created_at: z17.number(),
3503
- model: z17.string(),
3504
- service_tier: z17.string().nullish()
3591
+ var responseCreatedChunkSchema = z18.object({
3592
+ type: z18.literal("response.created"),
3593
+ response: z18.object({
3594
+ id: z18.string(),
3595
+ created_at: z18.number(),
3596
+ model: z18.string(),
3597
+ service_tier: z18.string().nullish()
3505
3598
  })
3506
3599
  });
3507
- var responseOutputItemAddedSchema = z17.object({
3508
- type: z17.literal("response.output_item.added"),
3509
- output_index: z17.number(),
3510
- item: z17.discriminatedUnion("type", [
3511
- z17.object({
3512
- type: z17.literal("message"),
3513
- id: z17.string()
3600
+ var responseOutputItemAddedSchema = z18.object({
3601
+ type: z18.literal("response.output_item.added"),
3602
+ output_index: z18.number(),
3603
+ item: z18.discriminatedUnion("type", [
3604
+ z18.object({
3605
+ type: z18.literal("message"),
3606
+ id: z18.string()
3514
3607
  }),
3515
- z17.object({
3516
- type: z17.literal("reasoning"),
3517
- id: z17.string(),
3518
- encrypted_content: z17.string().nullish()
3608
+ z18.object({
3609
+ type: z18.literal("reasoning"),
3610
+ id: z18.string(),
3611
+ encrypted_content: z18.string().nullish()
3519
3612
  }),
3520
- z17.object({
3521
- type: z17.literal("function_call"),
3522
- id: z17.string(),
3523
- call_id: z17.string(),
3524
- name: z17.string(),
3525
- arguments: z17.string()
3613
+ z18.object({
3614
+ type: z18.literal("function_call"),
3615
+ id: z18.string(),
3616
+ call_id: z18.string(),
3617
+ name: z18.string(),
3618
+ arguments: z18.string()
3526
3619
  }),
3527
- z17.object({
3528
- type: z17.literal("web_search_call"),
3529
- id: z17.string(),
3530
- status: z17.string(),
3531
- action: z17.object({
3532
- type: z17.literal("search"),
3533
- query: z17.string().optional()
3620
+ z18.object({
3621
+ type: z18.literal("web_search_call"),
3622
+ id: z18.string(),
3623
+ status: z18.string(),
3624
+ action: z18.object({
3625
+ type: z18.literal("search"),
3626
+ query: z18.string().optional()
3534
3627
  }).nullish()
3535
3628
  }),
3536
- z17.object({
3537
- type: z17.literal("computer_call"),
3538
- id: z17.string(),
3539
- status: z17.string()
3629
+ z18.object({
3630
+ type: z18.literal("computer_call"),
3631
+ id: z18.string(),
3632
+ status: z18.string()
3540
3633
  }),
3541
- z17.object({
3542
- type: z17.literal("file_search_call"),
3543
- id: z17.string(),
3544
- status: z17.string(),
3545
- queries: z17.array(z17.string()).nullish(),
3546
- results: z17.array(
3547
- z17.object({
3548
- attributes: z17.object({
3549
- file_id: z17.string(),
3550
- filename: z17.string(),
3551
- score: z17.number(),
3552
- text: z17.string()
3634
+ z18.object({
3635
+ type: z18.literal("file_search_call"),
3636
+ id: z18.string(),
3637
+ status: z18.string(),
3638
+ queries: z18.array(z18.string()).nullish(),
3639
+ results: z18.array(
3640
+ z18.object({
3641
+ attributes: z18.object({
3642
+ file_id: z18.string(),
3643
+ filename: z18.string(),
3644
+ score: z18.number(),
3645
+ text: z18.string()
3553
3646
  })
3554
3647
  })
3555
3648
  ).optional()
3649
+ }),
3650
+ z18.object({
3651
+ type: z18.literal("image_generation_call"),
3652
+ id: z18.string()
3556
3653
  })
3557
3654
  ])
3558
3655
  });
3559
- var responseOutputItemDoneSchema = z17.object({
3560
- type: z17.literal("response.output_item.done"),
3561
- output_index: z17.number(),
3562
- item: z17.discriminatedUnion("type", [
3563
- z17.object({
3564
- type: z17.literal("message"),
3565
- id: z17.string()
3656
+ var responseOutputItemDoneSchema = z18.object({
3657
+ type: z18.literal("response.output_item.done"),
3658
+ output_index: z18.number(),
3659
+ item: z18.discriminatedUnion("type", [
3660
+ z18.object({
3661
+ type: z18.literal("message"),
3662
+ id: z18.string()
3566
3663
  }),
3567
- z17.object({
3568
- type: z17.literal("reasoning"),
3569
- id: z17.string(),
3570
- encrypted_content: z17.string().nullish()
3664
+ z18.object({
3665
+ type: z18.literal("reasoning"),
3666
+ id: z18.string(),
3667
+ encrypted_content: z18.string().nullish()
3571
3668
  }),
3572
- z17.object({
3573
- type: z17.literal("function_call"),
3574
- id: z17.string(),
3575
- call_id: z17.string(),
3576
- name: z17.string(),
3577
- arguments: z17.string(),
3578
- status: z17.literal("completed")
3669
+ z18.object({
3670
+ type: z18.literal("function_call"),
3671
+ id: z18.string(),
3672
+ call_id: z18.string(),
3673
+ name: z18.string(),
3674
+ arguments: z18.string(),
3675
+ status: z18.literal("completed")
3579
3676
  }),
3580
3677
  codeInterpreterCallItem,
3678
+ imageGenerationCallItem,
3581
3679
  webSearchCallItem,
3582
- z17.object({
3583
- type: z17.literal("computer_call"),
3584
- id: z17.string(),
3585
- status: z17.literal("completed")
3680
+ z18.object({
3681
+ type: z18.literal("computer_call"),
3682
+ id: z18.string(),
3683
+ status: z18.literal("completed")
3586
3684
  }),
3587
- z17.object({
3588
- type: z17.literal("file_search_call"),
3589
- id: z17.string(),
3590
- status: z17.literal("completed"),
3591
- queries: z17.array(z17.string()).nullish(),
3592
- results: z17.array(
3593
- z17.object({
3594
- attributes: z17.object({
3595
- file_id: z17.string(),
3596
- filename: z17.string(),
3597
- score: z17.number(),
3598
- text: z17.string()
3685
+ z18.object({
3686
+ type: z18.literal("file_search_call"),
3687
+ id: z18.string(),
3688
+ status: z18.literal("completed"),
3689
+ queries: z18.array(z18.string()).nullish(),
3690
+ results: z18.array(
3691
+ z18.object({
3692
+ attributes: z18.object({
3693
+ file_id: z18.string(),
3694
+ filename: z18.string(),
3695
+ score: z18.number(),
3696
+ text: z18.string()
3599
3697
  })
3600
3698
  })
3601
3699
  ).nullish()
3602
3700
  })
3603
3701
  ])
3604
3702
  });
3605
- var responseFunctionCallArgumentsDeltaSchema = z17.object({
3606
- type: z17.literal("response.function_call_arguments.delta"),
3607
- item_id: z17.string(),
3608
- output_index: z17.number(),
3609
- delta: z17.string()
3703
+ var responseFunctionCallArgumentsDeltaSchema = z18.object({
3704
+ type: z18.literal("response.function_call_arguments.delta"),
3705
+ item_id: z18.string(),
3706
+ output_index: z18.number(),
3707
+ delta: z18.string()
3610
3708
  });
3611
- var responseAnnotationAddedSchema = z17.object({
3612
- type: z17.literal("response.output_text.annotation.added"),
3613
- annotation: z17.discriminatedUnion("type", [
3614
- z17.object({
3615
- type: z17.literal("url_citation"),
3616
- url: z17.string(),
3617
- title: z17.string()
3709
+ var responseAnnotationAddedSchema = z18.object({
3710
+ type: z18.literal("response.output_text.annotation.added"),
3711
+ annotation: z18.discriminatedUnion("type", [
3712
+ z18.object({
3713
+ type: z18.literal("url_citation"),
3714
+ url: z18.string(),
3715
+ title: z18.string()
3618
3716
  }),
3619
- z17.object({
3620
- type: z17.literal("file_citation"),
3621
- file_id: z17.string(),
3622
- filename: z17.string().nullish(),
3623
- index: z17.number().nullish(),
3624
- start_index: z17.number().nullish(),
3625
- end_index: z17.number().nullish(),
3626
- quote: z17.string().nullish()
3717
+ z18.object({
3718
+ type: z18.literal("file_citation"),
3719
+ file_id: z18.string(),
3720
+ filename: z18.string().nullish(),
3721
+ index: z18.number().nullish(),
3722
+ start_index: z18.number().nullish(),
3723
+ end_index: z18.number().nullish(),
3724
+ quote: z18.string().nullish()
3627
3725
  })
3628
3726
  ])
3629
3727
  });
3630
- var responseReasoningSummaryPartAddedSchema = z17.object({
3631
- type: z17.literal("response.reasoning_summary_part.added"),
3632
- item_id: z17.string(),
3633
- summary_index: z17.number()
3728
+ var responseReasoningSummaryPartAddedSchema = z18.object({
3729
+ type: z18.literal("response.reasoning_summary_part.added"),
3730
+ item_id: z18.string(),
3731
+ summary_index: z18.number()
3634
3732
  });
3635
- var responseReasoningSummaryTextDeltaSchema = z17.object({
3636
- type: z17.literal("response.reasoning_summary_text.delta"),
3637
- item_id: z17.string(),
3638
- summary_index: z17.number(),
3639
- delta: z17.string()
3733
+ var responseReasoningSummaryTextDeltaSchema = z18.object({
3734
+ type: z18.literal("response.reasoning_summary_text.delta"),
3735
+ item_id: z18.string(),
3736
+ summary_index: z18.number(),
3737
+ delta: z18.string()
3640
3738
  });
3641
- var openaiResponsesChunkSchema = z17.union([
3739
+ var openaiResponsesChunkSchema = z18.union([
3642
3740
  textDeltaChunkSchema,
3643
3741
  responseFinishedChunkSchema,
3644
3742
  responseCreatedChunkSchema,
@@ -3649,7 +3747,7 @@ var openaiResponsesChunkSchema = z17.union([
3649
3747
  responseReasoningSummaryPartAddedSchema,
3650
3748
  responseReasoningSummaryTextDeltaSchema,
3651
3749
  errorChunkSchema,
3652
- z17.object({ type: z17.string() }).loose()
3750
+ z18.object({ type: z18.string() }).loose()
3653
3751
  // fallback for unknown chunks
3654
3752
  ]);
3655
3753
  function isTextDeltaChunk(chunk) {
@@ -3722,27 +3820,15 @@ function getResponsesModelConfig(modelId) {
3722
3820
  isReasoningModel: false
3723
3821
  };
3724
3822
  }
3725
- var openaiResponsesProviderOptionsSchema = z17.object({
3726
- metadata: z17.any().nullish(),
3727
- parallelToolCalls: z17.boolean().nullish(),
3728
- previousResponseId: z17.string().nullish(),
3729
- store: z17.boolean().nullish(),
3730
- user: z17.string().nullish(),
3731
- reasoningEffort: z17.string().nullish(),
3732
- strictJsonSchema: z17.boolean().nullish(),
3733
- instructions: z17.string().nullish(),
3734
- reasoningSummary: z17.string().nullish(),
3735
- serviceTier: z17.enum(["auto", "flex", "priority"]).nullish(),
3736
- include: z17.array(
3737
- z17.enum([
3823
+ var openaiResponsesProviderOptionsSchema = z18.object({
3824
+ include: z18.array(
3825
+ z18.enum([
3738
3826
  "reasoning.encrypted_content",
3739
3827
  "file_search_call.results",
3740
3828
  "message.output_text.logprobs"
3741
3829
  ])
3742
3830
  ).nullish(),
3743
- textVerbosity: z17.enum(["low", "medium", "high"]).nullish(),
3744
- promptCacheKey: z17.string().nullish(),
3745
- safetyIdentifier: z17.string().nullish(),
3831
+ instructions: z18.string().nullish(),
3746
3832
  /**
3747
3833
  * Return the log probabilities of the tokens.
3748
3834
  *
@@ -3755,7 +3841,25 @@ var openaiResponsesProviderOptionsSchema = z17.object({
3755
3841
  * @see https://platform.openai.com/docs/api-reference/responses/create
3756
3842
  * @see https://cookbook.openai.com/examples/using_logprobs
3757
3843
  */
3758
- logprobs: z17.union([z17.boolean(), z17.number().min(1).max(TOP_LOGPROBS_MAX)]).optional()
3844
+ logprobs: z18.union([z18.boolean(), z18.number().min(1).max(TOP_LOGPROBS_MAX)]).optional(),
3845
+ /**
3846
+ * The maximum number of total calls to built-in tools that can be processed in a response.
3847
+ * This maximum number applies across all built-in tool calls, not per individual tool.
3848
+ * Any further attempts to call a tool by the model will be ignored.
3849
+ */
3850
+ maxToolCalls: z18.number().nullish(),
3851
+ metadata: z18.any().nullish(),
3852
+ parallelToolCalls: z18.boolean().nullish(),
3853
+ previousResponseId: z18.string().nullish(),
3854
+ promptCacheKey: z18.string().nullish(),
3855
+ reasoningEffort: z18.string().nullish(),
3856
+ reasoningSummary: z18.string().nullish(),
3857
+ safetyIdentifier: z18.string().nullish(),
3858
+ serviceTier: z18.enum(["auto", "flex", "priority"]).nullish(),
3859
+ store: z18.boolean().nullish(),
3860
+ strictJsonSchema: z18.boolean().nullish(),
3861
+ textVerbosity: z18.enum(["low", "medium", "high"]).nullish(),
3862
+ user: z18.string().nullish()
3759
3863
  });
3760
3864
  export {
3761
3865
  OpenAIChatLanguageModel,