@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.
@@ -2137,8 +2137,8 @@ var OpenAISpeechModel = class {
2137
2137
 
2138
2138
  // src/responses/openai-responses-language-model.ts
2139
2139
  var import_provider8 = require("@ai-sdk/provider");
2140
- var import_provider_utils14 = require("@ai-sdk/provider-utils");
2141
- var import_v417 = require("zod/v4");
2140
+ var import_provider_utils15 = require("@ai-sdk/provider-utils");
2141
+ var import_v418 = require("zod/v4");
2142
2142
 
2143
2143
  // src/responses/convert-to-openai-responses-input.ts
2144
2144
  var import_provider6 = require("@ai-sdk/provider");
@@ -2151,7 +2151,8 @@ function isFileId(data, prefixes) {
2151
2151
  async function convertToOpenAIResponsesInput({
2152
2152
  prompt,
2153
2153
  systemMessageMode,
2154
- fileIdPrefixes
2154
+ fileIdPrefixes,
2155
+ store
2155
2156
  }) {
2156
2157
  var _a, _b, _c, _d, _e, _f;
2157
2158
  const input = [];
@@ -2256,10 +2257,14 @@ async function convertToOpenAIResponsesInput({
2256
2257
  break;
2257
2258
  }
2258
2259
  case "tool-result": {
2259
- warnings.push({
2260
- type: "other",
2261
- message: `tool result parts in assistant messages are not supported for OpenAI responses`
2262
- });
2260
+ if (store) {
2261
+ input.push({ type: "item_reference", id: part.toolCallId });
2262
+ } else {
2263
+ warnings.push({
2264
+ type: "other",
2265
+ message: `Results for OpenAI tool ${part.toolName} are not sent to the API when store is false`
2266
+ });
2267
+ }
2263
2268
  break;
2264
2269
  }
2265
2270
  case "reasoning": {
@@ -2428,6 +2433,33 @@ var webSearchToolFactory = (0, import_provider_utils13.createProviderDefinedTool
2428
2433
  })
2429
2434
  });
2430
2435
 
2436
+ // src/tool/image-generation.ts
2437
+ var import_provider_utils14 = require("@ai-sdk/provider-utils");
2438
+ var import_v417 = require("zod/v4");
2439
+ var imageGenerationArgsSchema = import_v417.z.object({
2440
+ background: import_v417.z.enum(["auto", "opaque", "transparent"]).optional(),
2441
+ inputFidelity: import_v417.z.enum(["low", "high"]).optional(),
2442
+ inputImageMask: import_v417.z.object({
2443
+ fileId: import_v417.z.string().optional(),
2444
+ imageUrl: import_v417.z.string().optional()
2445
+ }).optional(),
2446
+ model: import_v417.z.string().optional(),
2447
+ moderation: import_v417.z.enum(["auto"]).optional(),
2448
+ outputCompression: import_v417.z.number().int().min(0).max(100).optional(),
2449
+ outputFormat: import_v417.z.enum(["png", "jpeg", "webp"]).optional(),
2450
+ quality: import_v417.z.enum(["auto", "low", "medium", "high"]).optional(),
2451
+ size: import_v417.z.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
2452
+ }).strict();
2453
+ var imageGenerationOutputSchema = import_v417.z.object({
2454
+ result: import_v417.z.string()
2455
+ });
2456
+ var imageGenerationToolFactory = (0, import_provider_utils14.createProviderDefinedToolFactoryWithOutputSchema)({
2457
+ id: "openai.image_generation",
2458
+ name: "image_generation",
2459
+ inputSchema: import_v417.z.object({}),
2460
+ outputSchema: imageGenerationOutputSchema
2461
+ });
2462
+
2431
2463
  // src/responses/openai-responses-prepare-tools.ts
2432
2464
  function prepareResponsesTools({
2433
2465
  tools,
@@ -2491,8 +2523,23 @@ function prepareResponsesTools({
2491
2523
  });
2492
2524
  break;
2493
2525
  }
2494
- default: {
2495
- toolWarnings.push({ type: "unsupported-tool", tool });
2526
+ case "openai.image_generation": {
2527
+ const args = imageGenerationArgsSchema.parse(tool.args);
2528
+ openaiTools.push({
2529
+ type: "image_generation",
2530
+ background: args.background,
2531
+ input_fidelity: args.inputFidelity,
2532
+ input_image_mask: args.inputImageMask ? {
2533
+ file_id: args.inputImageMask.fileId,
2534
+ image_url: args.inputImageMask.imageUrl
2535
+ } : void 0,
2536
+ model: args.model,
2537
+ size: args.size,
2538
+ quality: args.quality,
2539
+ moderation: args.moderation,
2540
+ output_format: args.outputFormat,
2541
+ output_compression: args.outputCompression
2542
+ });
2496
2543
  break;
2497
2544
  }
2498
2545
  }
@@ -2515,7 +2562,7 @@ function prepareResponsesTools({
2515
2562
  case "tool":
2516
2563
  return {
2517
2564
  tools: openaiTools,
2518
- 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 },
2565
+ 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 },
2519
2566
  toolWarnings
2520
2567
  };
2521
2568
  default: {
@@ -2528,47 +2575,52 @@ function prepareResponsesTools({
2528
2575
  }
2529
2576
 
2530
2577
  // src/responses/openai-responses-language-model.ts
2531
- var webSearchCallItem = import_v417.z.object({
2532
- type: import_v417.z.literal("web_search_call"),
2533
- id: import_v417.z.string(),
2534
- status: import_v417.z.string(),
2535
- action: import_v417.z.discriminatedUnion("type", [
2536
- import_v417.z.object({
2537
- type: import_v417.z.literal("search"),
2538
- query: import_v417.z.string().nullish()
2578
+ var webSearchCallItem = import_v418.z.object({
2579
+ type: import_v418.z.literal("web_search_call"),
2580
+ id: import_v418.z.string(),
2581
+ status: import_v418.z.string(),
2582
+ action: import_v418.z.discriminatedUnion("type", [
2583
+ import_v418.z.object({
2584
+ type: import_v418.z.literal("search"),
2585
+ query: import_v418.z.string().nullish()
2539
2586
  }),
2540
- import_v417.z.object({
2541
- type: import_v417.z.literal("open_page"),
2542
- url: import_v417.z.string()
2587
+ import_v418.z.object({
2588
+ type: import_v418.z.literal("open_page"),
2589
+ url: import_v418.z.string()
2543
2590
  }),
2544
- import_v417.z.object({
2545
- type: import_v417.z.literal("find"),
2546
- url: import_v417.z.string(),
2547
- pattern: import_v417.z.string()
2591
+ import_v418.z.object({
2592
+ type: import_v418.z.literal("find"),
2593
+ url: import_v418.z.string(),
2594
+ pattern: import_v418.z.string()
2548
2595
  })
2549
2596
  ]).nullish()
2550
2597
  });
2551
- var codeInterpreterCallItem = import_v417.z.object({
2552
- type: import_v417.z.literal("code_interpreter_call"),
2553
- id: import_v417.z.string(),
2554
- code: import_v417.z.string().nullable(),
2555
- container_id: import_v417.z.string(),
2556
- outputs: import_v417.z.array(
2557
- import_v417.z.discriminatedUnion("type", [
2558
- import_v417.z.object({ type: import_v417.z.literal("logs"), logs: import_v417.z.string() }),
2559
- import_v417.z.object({ type: import_v417.z.literal("image"), url: import_v417.z.string() })
2598
+ var codeInterpreterCallItem = import_v418.z.object({
2599
+ type: import_v418.z.literal("code_interpreter_call"),
2600
+ id: import_v418.z.string(),
2601
+ code: import_v418.z.string().nullable(),
2602
+ container_id: import_v418.z.string(),
2603
+ outputs: import_v418.z.array(
2604
+ import_v418.z.discriminatedUnion("type", [
2605
+ import_v418.z.object({ type: import_v418.z.literal("logs"), logs: import_v418.z.string() }),
2606
+ import_v418.z.object({ type: import_v418.z.literal("image"), url: import_v418.z.string() })
2560
2607
  ])
2561
2608
  ).nullable()
2562
2609
  });
2610
+ var imageGenerationCallItem = import_v418.z.object({
2611
+ type: import_v418.z.literal("image_generation_call"),
2612
+ id: import_v418.z.string(),
2613
+ result: import_v418.z.string()
2614
+ });
2563
2615
  var TOP_LOGPROBS_MAX = 20;
2564
- var LOGPROBS_SCHEMA = import_v417.z.array(
2565
- import_v417.z.object({
2566
- token: import_v417.z.string(),
2567
- logprob: import_v417.z.number(),
2568
- top_logprobs: import_v417.z.array(
2569
- import_v417.z.object({
2570
- token: import_v417.z.string(),
2571
- logprob: import_v417.z.number()
2616
+ var LOGPROBS_SCHEMA = import_v418.z.array(
2617
+ import_v418.z.object({
2618
+ token: import_v418.z.string(),
2619
+ logprob: import_v418.z.number(),
2620
+ top_logprobs: import_v418.z.array(
2621
+ import_v418.z.object({
2622
+ token: import_v418.z.string(),
2623
+ logprob: import_v418.z.number()
2572
2624
  })
2573
2625
  )
2574
2626
  })
@@ -2601,7 +2653,7 @@ var OpenAIResponsesLanguageModel = class {
2601
2653
  toolChoice,
2602
2654
  responseFormat
2603
2655
  }) {
2604
- var _a, _b, _c, _d;
2656
+ var _a, _b, _c, _d, _e;
2605
2657
  const warnings = [];
2606
2658
  const modelConfig = getResponsesModelConfig(this.modelId);
2607
2659
  if (topK != null) {
@@ -2625,28 +2677,29 @@ var OpenAIResponsesLanguageModel = class {
2625
2677
  if (stopSequences != null) {
2626
2678
  warnings.push({ type: "unsupported-setting", setting: "stopSequences" });
2627
2679
  }
2680
+ const openaiOptions = await (0, import_provider_utils15.parseProviderOptions)({
2681
+ provider: "openai",
2682
+ providerOptions,
2683
+ schema: openaiResponsesProviderOptionsSchema
2684
+ });
2628
2685
  const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
2629
2686
  prompt,
2630
2687
  systemMessageMode: modelConfig.systemMessageMode,
2631
- fileIdPrefixes: this.config.fileIdPrefixes
2688
+ fileIdPrefixes: this.config.fileIdPrefixes,
2689
+ store: (_a = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _a : true
2632
2690
  });
2633
2691
  warnings.push(...inputWarnings);
2634
- const openaiOptions = await (0, import_provider_utils14.parseProviderOptions)({
2635
- provider: "openai",
2636
- providerOptions,
2637
- schema: openaiResponsesProviderOptionsSchema
2638
- });
2639
- const strictJsonSchema = (_a = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _a : false;
2692
+ const strictJsonSchema = (_b = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _b : false;
2640
2693
  let include = openaiOptions == null ? void 0 : openaiOptions.include;
2641
2694
  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;
2642
2695
  include = topLogprobs ? Array.isArray(include) ? [...include, "message.output_text.logprobs"] : ["message.output_text.logprobs"] : include;
2643
- const webSearchToolName = (_b = tools == null ? void 0 : tools.find(
2696
+ const webSearchToolName = (_c = tools == null ? void 0 : tools.find(
2644
2697
  (tool) => tool.type === "provider-defined" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
2645
- )) == null ? void 0 : _b.name;
2698
+ )) == null ? void 0 : _c.name;
2646
2699
  include = webSearchToolName ? Array.isArray(include) ? [...include, "web_search_call.action.sources"] : ["web_search_call.action.sources"] : include;
2647
- const codeInterpreterToolName = (_c = tools == null ? void 0 : tools.find(
2700
+ const codeInterpreterToolName = (_d = tools == null ? void 0 : tools.find(
2648
2701
  (tool) => tool.type === "provider-defined" && tool.id === "openai.code_interpreter"
2649
- )) == null ? void 0 : _c.name;
2702
+ )) == null ? void 0 : _d.name;
2650
2703
  include = codeInterpreterToolName ? Array.isArray(include) ? [...include, "code_interpreter_call.outputs"] : ["code_interpreter_call.outputs"] : include;
2651
2704
  const baseArgs = {
2652
2705
  model: this.modelId,
@@ -2660,7 +2713,7 @@ var OpenAIResponsesLanguageModel = class {
2660
2713
  format: responseFormat.schema != null ? {
2661
2714
  type: "json_schema",
2662
2715
  strict: strictJsonSchema,
2663
- name: (_d = responseFormat.name) != null ? _d : "response",
2716
+ name: (_e = responseFormat.name) != null ? _e : "response",
2664
2717
  description: responseFormat.description,
2665
2718
  schema: responseFormat.schema
2666
2719
  } : { type: "json_object" }
@@ -2671,6 +2724,7 @@ var OpenAIResponsesLanguageModel = class {
2671
2724
  }
2672
2725
  },
2673
2726
  // provider options:
2727
+ max_tool_calls: openaiOptions == null ? void 0 : openaiOptions.maxToolCalls,
2674
2728
  metadata: openaiOptions == null ? void 0 : openaiOptions.metadata,
2675
2729
  parallel_tool_calls: openaiOptions == null ? void 0 : openaiOptions.parallelToolCalls,
2676
2730
  previous_response_id: openaiOptions == null ? void 0 : openaiOptions.previousResponseId,
@@ -2780,51 +2834,51 @@ var OpenAIResponsesLanguageModel = class {
2780
2834
  responseHeaders,
2781
2835
  value: response,
2782
2836
  rawValue: rawResponse
2783
- } = await (0, import_provider_utils14.postJsonToApi)({
2837
+ } = await (0, import_provider_utils15.postJsonToApi)({
2784
2838
  url,
2785
- headers: (0, import_provider_utils14.combineHeaders)(this.config.headers(), options.headers),
2839
+ headers: (0, import_provider_utils15.combineHeaders)(this.config.headers(), options.headers),
2786
2840
  body,
2787
2841
  failedResponseHandler: openaiFailedResponseHandler,
2788
- successfulResponseHandler: (0, import_provider_utils14.createJsonResponseHandler)(
2789
- import_v417.z.object({
2790
- id: import_v417.z.string(),
2791
- created_at: import_v417.z.number(),
2792
- error: import_v417.z.object({
2793
- code: import_v417.z.string(),
2794
- message: import_v417.z.string()
2842
+ successfulResponseHandler: (0, import_provider_utils15.createJsonResponseHandler)(
2843
+ import_v418.z.object({
2844
+ id: import_v418.z.string(),
2845
+ created_at: import_v418.z.number(),
2846
+ error: import_v418.z.object({
2847
+ code: import_v418.z.string(),
2848
+ message: import_v418.z.string()
2795
2849
  }).nullish(),
2796
- model: import_v417.z.string(),
2797
- output: import_v417.z.array(
2798
- import_v417.z.discriminatedUnion("type", [
2799
- import_v417.z.object({
2800
- type: import_v417.z.literal("message"),
2801
- role: import_v417.z.literal("assistant"),
2802
- id: import_v417.z.string(),
2803
- content: import_v417.z.array(
2804
- import_v417.z.object({
2805
- type: import_v417.z.literal("output_text"),
2806
- text: import_v417.z.string(),
2850
+ model: import_v418.z.string(),
2851
+ output: import_v418.z.array(
2852
+ import_v418.z.discriminatedUnion("type", [
2853
+ import_v418.z.object({
2854
+ type: import_v418.z.literal("message"),
2855
+ role: import_v418.z.literal("assistant"),
2856
+ id: import_v418.z.string(),
2857
+ content: import_v418.z.array(
2858
+ import_v418.z.object({
2859
+ type: import_v418.z.literal("output_text"),
2860
+ text: import_v418.z.string(),
2807
2861
  logprobs: LOGPROBS_SCHEMA.nullish(),
2808
- annotations: import_v417.z.array(
2809
- import_v417.z.discriminatedUnion("type", [
2810
- import_v417.z.object({
2811
- type: import_v417.z.literal("url_citation"),
2812
- start_index: import_v417.z.number(),
2813
- end_index: import_v417.z.number(),
2814
- url: import_v417.z.string(),
2815
- title: import_v417.z.string()
2862
+ annotations: import_v418.z.array(
2863
+ import_v418.z.discriminatedUnion("type", [
2864
+ import_v418.z.object({
2865
+ type: import_v418.z.literal("url_citation"),
2866
+ start_index: import_v418.z.number(),
2867
+ end_index: import_v418.z.number(),
2868
+ url: import_v418.z.string(),
2869
+ title: import_v418.z.string()
2816
2870
  }),
2817
- import_v417.z.object({
2818
- type: import_v417.z.literal("file_citation"),
2819
- file_id: import_v417.z.string(),
2820
- filename: import_v417.z.string().nullish(),
2821
- index: import_v417.z.number().nullish(),
2822
- start_index: import_v417.z.number().nullish(),
2823
- end_index: import_v417.z.number().nullish(),
2824
- quote: import_v417.z.string().nullish()
2871
+ import_v418.z.object({
2872
+ type: import_v418.z.literal("file_citation"),
2873
+ file_id: import_v418.z.string(),
2874
+ filename: import_v418.z.string().nullish(),
2875
+ index: import_v418.z.number().nullish(),
2876
+ start_index: import_v418.z.number().nullish(),
2877
+ end_index: import_v418.z.number().nullish(),
2878
+ quote: import_v418.z.string().nullish()
2825
2879
  }),
2826
- import_v417.z.object({
2827
- type: import_v417.z.literal("container_file_citation")
2880
+ import_v418.z.object({
2881
+ type: import_v418.z.literal("container_file_citation")
2828
2882
  })
2829
2883
  ])
2830
2884
  )
@@ -2832,50 +2886,51 @@ var OpenAIResponsesLanguageModel = class {
2832
2886
  )
2833
2887
  }),
2834
2888
  codeInterpreterCallItem,
2835
- import_v417.z.object({
2836
- type: import_v417.z.literal("function_call"),
2837
- call_id: import_v417.z.string(),
2838
- name: import_v417.z.string(),
2839
- arguments: import_v417.z.string(),
2840
- id: import_v417.z.string()
2889
+ imageGenerationCallItem,
2890
+ import_v418.z.object({
2891
+ type: import_v418.z.literal("function_call"),
2892
+ call_id: import_v418.z.string(),
2893
+ name: import_v418.z.string(),
2894
+ arguments: import_v418.z.string(),
2895
+ id: import_v418.z.string()
2841
2896
  }),
2842
2897
  webSearchCallItem,
2843
- import_v417.z.object({
2844
- type: import_v417.z.literal("computer_call"),
2845
- id: import_v417.z.string(),
2846
- status: import_v417.z.string().optional()
2898
+ import_v418.z.object({
2899
+ type: import_v418.z.literal("computer_call"),
2900
+ id: import_v418.z.string(),
2901
+ status: import_v418.z.string().optional()
2847
2902
  }),
2848
- import_v417.z.object({
2849
- type: import_v417.z.literal("file_search_call"),
2850
- id: import_v417.z.string(),
2851
- status: import_v417.z.string().optional(),
2852
- queries: import_v417.z.array(import_v417.z.string()).nullish(),
2853
- results: import_v417.z.array(
2854
- import_v417.z.object({
2855
- attributes: import_v417.z.object({
2856
- file_id: import_v417.z.string(),
2857
- filename: import_v417.z.string(),
2858
- score: import_v417.z.number(),
2859
- text: import_v417.z.string()
2903
+ import_v418.z.object({
2904
+ type: import_v418.z.literal("file_search_call"),
2905
+ id: import_v418.z.string(),
2906
+ status: import_v418.z.string().optional(),
2907
+ queries: import_v418.z.array(import_v418.z.string()).nullish(),
2908
+ results: import_v418.z.array(
2909
+ import_v418.z.object({
2910
+ attributes: import_v418.z.object({
2911
+ file_id: import_v418.z.string(),
2912
+ filename: import_v418.z.string(),
2913
+ score: import_v418.z.number(),
2914
+ text: import_v418.z.string()
2860
2915
  })
2861
2916
  })
2862
2917
  ).nullish()
2863
2918
  }),
2864
- import_v417.z.object({
2865
- type: import_v417.z.literal("reasoning"),
2866
- id: import_v417.z.string(),
2867
- encrypted_content: import_v417.z.string().nullish(),
2868
- summary: import_v417.z.array(
2869
- import_v417.z.object({
2870
- type: import_v417.z.literal("summary_text"),
2871
- text: import_v417.z.string()
2919
+ import_v418.z.object({
2920
+ type: import_v418.z.literal("reasoning"),
2921
+ id: import_v418.z.string(),
2922
+ encrypted_content: import_v418.z.string().nullish(),
2923
+ summary: import_v418.z.array(
2924
+ import_v418.z.object({
2925
+ type: import_v418.z.literal("summary_text"),
2926
+ text: import_v418.z.string()
2872
2927
  })
2873
2928
  )
2874
2929
  })
2875
2930
  ])
2876
2931
  ),
2877
- service_tier: import_v417.z.string().nullish(),
2878
- incomplete_details: import_v417.z.object({ reason: import_v417.z.string() }).nullable(),
2932
+ service_tier: import_v418.z.string().nullish(),
2933
+ incomplete_details: import_v418.z.object({ reason: import_v418.z.string() }).nullable(),
2879
2934
  usage: usageSchema2
2880
2935
  })
2881
2936
  ),
@@ -2916,6 +2971,25 @@ var OpenAIResponsesLanguageModel = class {
2916
2971
  }
2917
2972
  break;
2918
2973
  }
2974
+ case "image_generation_call": {
2975
+ content.push({
2976
+ type: "tool-call",
2977
+ toolCallId: part.id,
2978
+ toolName: "image_generation",
2979
+ input: "{}",
2980
+ providerExecuted: true
2981
+ });
2982
+ content.push({
2983
+ type: "tool-result",
2984
+ toolCallId: part.id,
2985
+ toolName: "image_generation",
2986
+ result: {
2987
+ result: part.result
2988
+ },
2989
+ providerExecuted: true
2990
+ });
2991
+ break;
2992
+ }
2919
2993
  case "message": {
2920
2994
  for (const contentPart of part.content) {
2921
2995
  if (((_c = (_b = options.providerOptions) == null ? void 0 : _b.openai) == null ? void 0 : _c.logprobs) && contentPart.logprobs) {
@@ -2935,7 +3009,7 @@ var OpenAIResponsesLanguageModel = class {
2935
3009
  content.push({
2936
3010
  type: "source",
2937
3011
  sourceType: "url",
2938
- id: (_f = (_e = (_d = this.config).generateId) == null ? void 0 : _e.call(_d)) != null ? _f : (0, import_provider_utils14.generateId)(),
3012
+ id: (_f = (_e = (_d = this.config).generateId) == null ? void 0 : _e.call(_d)) != null ? _f : (0, import_provider_utils15.generateId)(),
2939
3013
  url: annotation.url,
2940
3014
  title: annotation.title
2941
3015
  });
@@ -2943,7 +3017,7 @@ var OpenAIResponsesLanguageModel = class {
2943
3017
  content.push({
2944
3018
  type: "source",
2945
3019
  sourceType: "document",
2946
- id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : (0, import_provider_utils14.generateId)(),
3020
+ id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : (0, import_provider_utils15.generateId)(),
2947
3021
  mediaType: "text/plain",
2948
3022
  title: (_k = (_j = annotation.quote) != null ? _j : annotation.filename) != null ? _k : "Document",
2949
3023
  filename: (_l = annotation.filename) != null ? _l : annotation.file_id
@@ -3091,18 +3165,18 @@ var OpenAIResponsesLanguageModel = class {
3091
3165
  warnings,
3092
3166
  webSearchToolName
3093
3167
  } = await this.getArgs(options);
3094
- const { responseHeaders, value: response } = await (0, import_provider_utils14.postJsonToApi)({
3168
+ const { responseHeaders, value: response } = await (0, import_provider_utils15.postJsonToApi)({
3095
3169
  url: this.config.url({
3096
3170
  path: "/responses",
3097
3171
  modelId: this.modelId
3098
3172
  }),
3099
- headers: (0, import_provider_utils14.combineHeaders)(this.config.headers(), options.headers),
3173
+ headers: (0, import_provider_utils15.combineHeaders)(this.config.headers(), options.headers),
3100
3174
  body: {
3101
3175
  ...body,
3102
3176
  stream: true
3103
3177
  },
3104
3178
  failedResponseHandler: openaiFailedResponseHandler,
3105
- successfulResponseHandler: (0, import_provider_utils14.createEventSourceResponseHandler)(
3179
+ successfulResponseHandler: (0, import_provider_utils15.createEventSourceResponseHandler)(
3106
3180
  openaiResponsesChunkSchema
3107
3181
  ),
3108
3182
  abortSignal: options.abortSignal,
@@ -3179,6 +3253,14 @@ var OpenAIResponsesLanguageModel = class {
3179
3253
  id: value.item.id,
3180
3254
  toolName: "file_search"
3181
3255
  });
3256
+ } else if (value.item.type === "image_generation_call") {
3257
+ controller.enqueue({
3258
+ type: "tool-call",
3259
+ toolCallId: value.item.id,
3260
+ toolName: "image_generation",
3261
+ input: "{}",
3262
+ providerExecuted: true
3263
+ });
3182
3264
  } else if (value.item.type === "message") {
3183
3265
  controller.enqueue({
3184
3266
  type: "text-start",
@@ -3312,6 +3394,16 @@ var OpenAIResponsesLanguageModel = class {
3312
3394
  },
3313
3395
  providerExecuted: true
3314
3396
  });
3397
+ } else if (value.item.type === "image_generation_call") {
3398
+ controller.enqueue({
3399
+ type: "tool-result",
3400
+ toolCallId: value.item.id,
3401
+ toolName: "image_generation",
3402
+ result: {
3403
+ result: value.item.result
3404
+ },
3405
+ providerExecuted: true
3406
+ });
3315
3407
  } else if (value.item.type === "message") {
3316
3408
  controller.enqueue({
3317
3409
  type: "text-end",
@@ -3404,7 +3496,7 @@ var OpenAIResponsesLanguageModel = class {
3404
3496
  controller.enqueue({
3405
3497
  type: "source",
3406
3498
  sourceType: "url",
3407
- id: (_o = (_n = (_m = self.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : (0, import_provider_utils14.generateId)(),
3499
+ id: (_o = (_n = (_m = self.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : (0, import_provider_utils15.generateId)(),
3408
3500
  url: value.annotation.url,
3409
3501
  title: value.annotation.title
3410
3502
  });
@@ -3412,7 +3504,7 @@ var OpenAIResponsesLanguageModel = class {
3412
3504
  controller.enqueue({
3413
3505
  type: "source",
3414
3506
  sourceType: "document",
3415
- id: (_r = (_q = (_p = self.config).generateId) == null ? void 0 : _q.call(_p)) != null ? _r : (0, import_provider_utils14.generateId)(),
3507
+ id: (_r = (_q = (_p = self.config).generateId) == null ? void 0 : _q.call(_p)) != null ? _r : (0, import_provider_utils15.generateId)(),
3416
3508
  mediaType: "text/plain",
3417
3509
  title: (_t = (_s = value.annotation.quote) != null ? _s : value.annotation.filename) != null ? _t : "Document",
3418
3510
  filename: (_u = value.annotation.filename) != null ? _u : value.annotation.file_id
@@ -3448,177 +3540,182 @@ var OpenAIResponsesLanguageModel = class {
3448
3540
  };
3449
3541
  }
3450
3542
  };
3451
- var usageSchema2 = import_v417.z.object({
3452
- input_tokens: import_v417.z.number(),
3453
- input_tokens_details: import_v417.z.object({ cached_tokens: import_v417.z.number().nullish() }).nullish(),
3454
- output_tokens: import_v417.z.number(),
3455
- output_tokens_details: import_v417.z.object({ reasoning_tokens: import_v417.z.number().nullish() }).nullish()
3543
+ var usageSchema2 = import_v418.z.object({
3544
+ input_tokens: import_v418.z.number(),
3545
+ input_tokens_details: import_v418.z.object({ cached_tokens: import_v418.z.number().nullish() }).nullish(),
3546
+ output_tokens: import_v418.z.number(),
3547
+ output_tokens_details: import_v418.z.object({ reasoning_tokens: import_v418.z.number().nullish() }).nullish()
3456
3548
  });
3457
- var textDeltaChunkSchema = import_v417.z.object({
3458
- type: import_v417.z.literal("response.output_text.delta"),
3459
- item_id: import_v417.z.string(),
3460
- delta: import_v417.z.string(),
3549
+ var textDeltaChunkSchema = import_v418.z.object({
3550
+ type: import_v418.z.literal("response.output_text.delta"),
3551
+ item_id: import_v418.z.string(),
3552
+ delta: import_v418.z.string(),
3461
3553
  logprobs: LOGPROBS_SCHEMA.nullish()
3462
3554
  });
3463
- var errorChunkSchema = import_v417.z.object({
3464
- type: import_v417.z.literal("error"),
3465
- code: import_v417.z.string(),
3466
- message: import_v417.z.string(),
3467
- param: import_v417.z.string().nullish(),
3468
- sequence_number: import_v417.z.number()
3555
+ var errorChunkSchema = import_v418.z.object({
3556
+ type: import_v418.z.literal("error"),
3557
+ code: import_v418.z.string(),
3558
+ message: import_v418.z.string(),
3559
+ param: import_v418.z.string().nullish(),
3560
+ sequence_number: import_v418.z.number()
3469
3561
  });
3470
- var responseFinishedChunkSchema = import_v417.z.object({
3471
- type: import_v417.z.enum(["response.completed", "response.incomplete"]),
3472
- response: import_v417.z.object({
3473
- incomplete_details: import_v417.z.object({ reason: import_v417.z.string() }).nullish(),
3562
+ var responseFinishedChunkSchema = import_v418.z.object({
3563
+ type: import_v418.z.enum(["response.completed", "response.incomplete"]),
3564
+ response: import_v418.z.object({
3565
+ incomplete_details: import_v418.z.object({ reason: import_v418.z.string() }).nullish(),
3474
3566
  usage: usageSchema2,
3475
- service_tier: import_v417.z.string().nullish()
3567
+ service_tier: import_v418.z.string().nullish()
3476
3568
  })
3477
3569
  });
3478
- var responseCreatedChunkSchema = import_v417.z.object({
3479
- type: import_v417.z.literal("response.created"),
3480
- response: import_v417.z.object({
3481
- id: import_v417.z.string(),
3482
- created_at: import_v417.z.number(),
3483
- model: import_v417.z.string(),
3484
- service_tier: import_v417.z.string().nullish()
3570
+ var responseCreatedChunkSchema = import_v418.z.object({
3571
+ type: import_v418.z.literal("response.created"),
3572
+ response: import_v418.z.object({
3573
+ id: import_v418.z.string(),
3574
+ created_at: import_v418.z.number(),
3575
+ model: import_v418.z.string(),
3576
+ service_tier: import_v418.z.string().nullish()
3485
3577
  })
3486
3578
  });
3487
- var responseOutputItemAddedSchema = import_v417.z.object({
3488
- type: import_v417.z.literal("response.output_item.added"),
3489
- output_index: import_v417.z.number(),
3490
- item: import_v417.z.discriminatedUnion("type", [
3491
- import_v417.z.object({
3492
- type: import_v417.z.literal("message"),
3493
- id: import_v417.z.string()
3579
+ var responseOutputItemAddedSchema = import_v418.z.object({
3580
+ type: import_v418.z.literal("response.output_item.added"),
3581
+ output_index: import_v418.z.number(),
3582
+ item: import_v418.z.discriminatedUnion("type", [
3583
+ import_v418.z.object({
3584
+ type: import_v418.z.literal("message"),
3585
+ id: import_v418.z.string()
3494
3586
  }),
3495
- import_v417.z.object({
3496
- type: import_v417.z.literal("reasoning"),
3497
- id: import_v417.z.string(),
3498
- encrypted_content: import_v417.z.string().nullish()
3587
+ import_v418.z.object({
3588
+ type: import_v418.z.literal("reasoning"),
3589
+ id: import_v418.z.string(),
3590
+ encrypted_content: import_v418.z.string().nullish()
3499
3591
  }),
3500
- import_v417.z.object({
3501
- type: import_v417.z.literal("function_call"),
3502
- id: import_v417.z.string(),
3503
- call_id: import_v417.z.string(),
3504
- name: import_v417.z.string(),
3505
- arguments: import_v417.z.string()
3592
+ import_v418.z.object({
3593
+ type: import_v418.z.literal("function_call"),
3594
+ id: import_v418.z.string(),
3595
+ call_id: import_v418.z.string(),
3596
+ name: import_v418.z.string(),
3597
+ arguments: import_v418.z.string()
3506
3598
  }),
3507
- import_v417.z.object({
3508
- type: import_v417.z.literal("web_search_call"),
3509
- id: import_v417.z.string(),
3510
- status: import_v417.z.string(),
3511
- action: import_v417.z.object({
3512
- type: import_v417.z.literal("search"),
3513
- query: import_v417.z.string().optional()
3599
+ import_v418.z.object({
3600
+ type: import_v418.z.literal("web_search_call"),
3601
+ id: import_v418.z.string(),
3602
+ status: import_v418.z.string(),
3603
+ action: import_v418.z.object({
3604
+ type: import_v418.z.literal("search"),
3605
+ query: import_v418.z.string().optional()
3514
3606
  }).nullish()
3515
3607
  }),
3516
- import_v417.z.object({
3517
- type: import_v417.z.literal("computer_call"),
3518
- id: import_v417.z.string(),
3519
- status: import_v417.z.string()
3608
+ import_v418.z.object({
3609
+ type: import_v418.z.literal("computer_call"),
3610
+ id: import_v418.z.string(),
3611
+ status: import_v418.z.string()
3520
3612
  }),
3521
- import_v417.z.object({
3522
- type: import_v417.z.literal("file_search_call"),
3523
- id: import_v417.z.string(),
3524
- status: import_v417.z.string(),
3525
- queries: import_v417.z.array(import_v417.z.string()).nullish(),
3526
- results: import_v417.z.array(
3527
- import_v417.z.object({
3528
- attributes: import_v417.z.object({
3529
- file_id: import_v417.z.string(),
3530
- filename: import_v417.z.string(),
3531
- score: import_v417.z.number(),
3532
- text: import_v417.z.string()
3613
+ import_v418.z.object({
3614
+ type: import_v418.z.literal("file_search_call"),
3615
+ id: import_v418.z.string(),
3616
+ status: import_v418.z.string(),
3617
+ queries: import_v418.z.array(import_v418.z.string()).nullish(),
3618
+ results: import_v418.z.array(
3619
+ import_v418.z.object({
3620
+ attributes: import_v418.z.object({
3621
+ file_id: import_v418.z.string(),
3622
+ filename: import_v418.z.string(),
3623
+ score: import_v418.z.number(),
3624
+ text: import_v418.z.string()
3533
3625
  })
3534
3626
  })
3535
3627
  ).optional()
3628
+ }),
3629
+ import_v418.z.object({
3630
+ type: import_v418.z.literal("image_generation_call"),
3631
+ id: import_v418.z.string()
3536
3632
  })
3537
3633
  ])
3538
3634
  });
3539
- var responseOutputItemDoneSchema = import_v417.z.object({
3540
- type: import_v417.z.literal("response.output_item.done"),
3541
- output_index: import_v417.z.number(),
3542
- item: import_v417.z.discriminatedUnion("type", [
3543
- import_v417.z.object({
3544
- type: import_v417.z.literal("message"),
3545
- id: import_v417.z.string()
3635
+ var responseOutputItemDoneSchema = import_v418.z.object({
3636
+ type: import_v418.z.literal("response.output_item.done"),
3637
+ output_index: import_v418.z.number(),
3638
+ item: import_v418.z.discriminatedUnion("type", [
3639
+ import_v418.z.object({
3640
+ type: import_v418.z.literal("message"),
3641
+ id: import_v418.z.string()
3546
3642
  }),
3547
- import_v417.z.object({
3548
- type: import_v417.z.literal("reasoning"),
3549
- id: import_v417.z.string(),
3550
- encrypted_content: import_v417.z.string().nullish()
3643
+ import_v418.z.object({
3644
+ type: import_v418.z.literal("reasoning"),
3645
+ id: import_v418.z.string(),
3646
+ encrypted_content: import_v418.z.string().nullish()
3551
3647
  }),
3552
- import_v417.z.object({
3553
- type: import_v417.z.literal("function_call"),
3554
- id: import_v417.z.string(),
3555
- call_id: import_v417.z.string(),
3556
- name: import_v417.z.string(),
3557
- arguments: import_v417.z.string(),
3558
- status: import_v417.z.literal("completed")
3648
+ import_v418.z.object({
3649
+ type: import_v418.z.literal("function_call"),
3650
+ id: import_v418.z.string(),
3651
+ call_id: import_v418.z.string(),
3652
+ name: import_v418.z.string(),
3653
+ arguments: import_v418.z.string(),
3654
+ status: import_v418.z.literal("completed")
3559
3655
  }),
3560
3656
  codeInterpreterCallItem,
3657
+ imageGenerationCallItem,
3561
3658
  webSearchCallItem,
3562
- import_v417.z.object({
3563
- type: import_v417.z.literal("computer_call"),
3564
- id: import_v417.z.string(),
3565
- status: import_v417.z.literal("completed")
3659
+ import_v418.z.object({
3660
+ type: import_v418.z.literal("computer_call"),
3661
+ id: import_v418.z.string(),
3662
+ status: import_v418.z.literal("completed")
3566
3663
  }),
3567
- import_v417.z.object({
3568
- type: import_v417.z.literal("file_search_call"),
3569
- id: import_v417.z.string(),
3570
- status: import_v417.z.literal("completed"),
3571
- queries: import_v417.z.array(import_v417.z.string()).nullish(),
3572
- results: import_v417.z.array(
3573
- import_v417.z.object({
3574
- attributes: import_v417.z.object({
3575
- file_id: import_v417.z.string(),
3576
- filename: import_v417.z.string(),
3577
- score: import_v417.z.number(),
3578
- text: import_v417.z.string()
3664
+ import_v418.z.object({
3665
+ type: import_v418.z.literal("file_search_call"),
3666
+ id: import_v418.z.string(),
3667
+ status: import_v418.z.literal("completed"),
3668
+ queries: import_v418.z.array(import_v418.z.string()).nullish(),
3669
+ results: import_v418.z.array(
3670
+ import_v418.z.object({
3671
+ attributes: import_v418.z.object({
3672
+ file_id: import_v418.z.string(),
3673
+ filename: import_v418.z.string(),
3674
+ score: import_v418.z.number(),
3675
+ text: import_v418.z.string()
3579
3676
  })
3580
3677
  })
3581
3678
  ).nullish()
3582
3679
  })
3583
3680
  ])
3584
3681
  });
3585
- var responseFunctionCallArgumentsDeltaSchema = import_v417.z.object({
3586
- type: import_v417.z.literal("response.function_call_arguments.delta"),
3587
- item_id: import_v417.z.string(),
3588
- output_index: import_v417.z.number(),
3589
- delta: import_v417.z.string()
3682
+ var responseFunctionCallArgumentsDeltaSchema = import_v418.z.object({
3683
+ type: import_v418.z.literal("response.function_call_arguments.delta"),
3684
+ item_id: import_v418.z.string(),
3685
+ output_index: import_v418.z.number(),
3686
+ delta: import_v418.z.string()
3590
3687
  });
3591
- var responseAnnotationAddedSchema = import_v417.z.object({
3592
- type: import_v417.z.literal("response.output_text.annotation.added"),
3593
- annotation: import_v417.z.discriminatedUnion("type", [
3594
- import_v417.z.object({
3595
- type: import_v417.z.literal("url_citation"),
3596
- url: import_v417.z.string(),
3597
- title: import_v417.z.string()
3688
+ var responseAnnotationAddedSchema = import_v418.z.object({
3689
+ type: import_v418.z.literal("response.output_text.annotation.added"),
3690
+ annotation: import_v418.z.discriminatedUnion("type", [
3691
+ import_v418.z.object({
3692
+ type: import_v418.z.literal("url_citation"),
3693
+ url: import_v418.z.string(),
3694
+ title: import_v418.z.string()
3598
3695
  }),
3599
- import_v417.z.object({
3600
- type: import_v417.z.literal("file_citation"),
3601
- file_id: import_v417.z.string(),
3602
- filename: import_v417.z.string().nullish(),
3603
- index: import_v417.z.number().nullish(),
3604
- start_index: import_v417.z.number().nullish(),
3605
- end_index: import_v417.z.number().nullish(),
3606
- quote: import_v417.z.string().nullish()
3696
+ import_v418.z.object({
3697
+ type: import_v418.z.literal("file_citation"),
3698
+ file_id: import_v418.z.string(),
3699
+ filename: import_v418.z.string().nullish(),
3700
+ index: import_v418.z.number().nullish(),
3701
+ start_index: import_v418.z.number().nullish(),
3702
+ end_index: import_v418.z.number().nullish(),
3703
+ quote: import_v418.z.string().nullish()
3607
3704
  })
3608
3705
  ])
3609
3706
  });
3610
- var responseReasoningSummaryPartAddedSchema = import_v417.z.object({
3611
- type: import_v417.z.literal("response.reasoning_summary_part.added"),
3612
- item_id: import_v417.z.string(),
3613
- summary_index: import_v417.z.number()
3707
+ var responseReasoningSummaryPartAddedSchema = import_v418.z.object({
3708
+ type: import_v418.z.literal("response.reasoning_summary_part.added"),
3709
+ item_id: import_v418.z.string(),
3710
+ summary_index: import_v418.z.number()
3614
3711
  });
3615
- var responseReasoningSummaryTextDeltaSchema = import_v417.z.object({
3616
- type: import_v417.z.literal("response.reasoning_summary_text.delta"),
3617
- item_id: import_v417.z.string(),
3618
- summary_index: import_v417.z.number(),
3619
- delta: import_v417.z.string()
3712
+ var responseReasoningSummaryTextDeltaSchema = import_v418.z.object({
3713
+ type: import_v418.z.literal("response.reasoning_summary_text.delta"),
3714
+ item_id: import_v418.z.string(),
3715
+ summary_index: import_v418.z.number(),
3716
+ delta: import_v418.z.string()
3620
3717
  });
3621
- var openaiResponsesChunkSchema = import_v417.z.union([
3718
+ var openaiResponsesChunkSchema = import_v418.z.union([
3622
3719
  textDeltaChunkSchema,
3623
3720
  responseFinishedChunkSchema,
3624
3721
  responseCreatedChunkSchema,
@@ -3629,7 +3726,7 @@ var openaiResponsesChunkSchema = import_v417.z.union([
3629
3726
  responseReasoningSummaryPartAddedSchema,
3630
3727
  responseReasoningSummaryTextDeltaSchema,
3631
3728
  errorChunkSchema,
3632
- import_v417.z.object({ type: import_v417.z.string() }).loose()
3729
+ import_v418.z.object({ type: import_v418.z.string() }).loose()
3633
3730
  // fallback for unknown chunks
3634
3731
  ]);
3635
3732
  function isTextDeltaChunk(chunk) {
@@ -3702,27 +3799,15 @@ function getResponsesModelConfig(modelId) {
3702
3799
  isReasoningModel: false
3703
3800
  };
3704
3801
  }
3705
- var openaiResponsesProviderOptionsSchema = import_v417.z.object({
3706
- metadata: import_v417.z.any().nullish(),
3707
- parallelToolCalls: import_v417.z.boolean().nullish(),
3708
- previousResponseId: import_v417.z.string().nullish(),
3709
- store: import_v417.z.boolean().nullish(),
3710
- user: import_v417.z.string().nullish(),
3711
- reasoningEffort: import_v417.z.string().nullish(),
3712
- strictJsonSchema: import_v417.z.boolean().nullish(),
3713
- instructions: import_v417.z.string().nullish(),
3714
- reasoningSummary: import_v417.z.string().nullish(),
3715
- serviceTier: import_v417.z.enum(["auto", "flex", "priority"]).nullish(),
3716
- include: import_v417.z.array(
3717
- import_v417.z.enum([
3802
+ var openaiResponsesProviderOptionsSchema = import_v418.z.object({
3803
+ include: import_v418.z.array(
3804
+ import_v418.z.enum([
3718
3805
  "reasoning.encrypted_content",
3719
3806
  "file_search_call.results",
3720
3807
  "message.output_text.logprobs"
3721
3808
  ])
3722
3809
  ).nullish(),
3723
- textVerbosity: import_v417.z.enum(["low", "medium", "high"]).nullish(),
3724
- promptCacheKey: import_v417.z.string().nullish(),
3725
- safetyIdentifier: import_v417.z.string().nullish(),
3810
+ instructions: import_v418.z.string().nullish(),
3726
3811
  /**
3727
3812
  * Return the log probabilities of the tokens.
3728
3813
  *
@@ -3735,7 +3820,25 @@ var openaiResponsesProviderOptionsSchema = import_v417.z.object({
3735
3820
  * @see https://platform.openai.com/docs/api-reference/responses/create
3736
3821
  * @see https://cookbook.openai.com/examples/using_logprobs
3737
3822
  */
3738
- logprobs: import_v417.z.union([import_v417.z.boolean(), import_v417.z.number().min(1).max(TOP_LOGPROBS_MAX)]).optional()
3823
+ logprobs: import_v418.z.union([import_v418.z.boolean(), import_v418.z.number().min(1).max(TOP_LOGPROBS_MAX)]).optional(),
3824
+ /**
3825
+ * The maximum number of total calls to built-in tools that can be processed in a response.
3826
+ * This maximum number applies across all built-in tool calls, not per individual tool.
3827
+ * Any further attempts to call a tool by the model will be ignored.
3828
+ */
3829
+ maxToolCalls: import_v418.z.number().nullish(),
3830
+ metadata: import_v418.z.any().nullish(),
3831
+ parallelToolCalls: import_v418.z.boolean().nullish(),
3832
+ previousResponseId: import_v418.z.string().nullish(),
3833
+ promptCacheKey: import_v418.z.string().nullish(),
3834
+ reasoningEffort: import_v418.z.string().nullish(),
3835
+ reasoningSummary: import_v418.z.string().nullish(),
3836
+ safetyIdentifier: import_v418.z.string().nullish(),
3837
+ serviceTier: import_v418.z.enum(["auto", "flex", "priority"]).nullish(),
3838
+ store: import_v418.z.boolean().nullish(),
3839
+ strictJsonSchema: import_v418.z.boolean().nullish(),
3840
+ textVerbosity: import_v418.z.enum(["low", "medium", "high"]).nullish(),
3841
+ user: import_v418.z.string().nullish()
3739
3842
  });
3740
3843
  // Annotate the CommonJS export names for ESM import in node:
3741
3844
  0 && (module.exports = {