@ai-sdk/openai 4.0.60 → 4.0.62

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.
@@ -160,7 +160,7 @@ declare const modelMaxImagesPerCall: Record<OpenAIImageModelId, number>;
160
160
  declare function hasDefaultResponseFormat(modelId: string): boolean;
161
161
  declare function getMaxImagesPerCall(modelId: OpenAIImageModelId): number;
162
162
  declare const openaiImageModelOptions: _ai_sdk_provider_utils.LazySchema<{
163
- quality?: "low" | "medium" | "high" | "auto" | "standard" | "hd" | undefined;
163
+ quality?: "low" | "medium" | "high" | "xhigh" | "max" | "auto" | "standard" | "hd" | undefined;
164
164
  background?: "auto" | "transparent" | "opaque" | undefined;
165
165
  outputFormat?: "png" | "jpeg" | "webp" | undefined;
166
166
  outputCompression?: number | undefined;
@@ -168,7 +168,7 @@ declare const openaiImageModelOptions: _ai_sdk_provider_utils.LazySchema<{
168
168
  }>;
169
169
  type OpenAIImageModelOptions = InferSchema<typeof openaiImageModelOptions>;
170
170
  declare const openaiImageModelGenerationOptions: _ai_sdk_provider_utils.LazySchema<{
171
- quality?: "low" | "medium" | "high" | "auto" | "standard" | "hd" | undefined;
171
+ quality?: "low" | "medium" | "high" | "xhigh" | "max" | "auto" | "standard" | "hd" | undefined;
172
172
  background?: "auto" | "transparent" | "opaque" | undefined;
173
173
  outputFormat?: "png" | "jpeg" | "webp" | undefined;
174
174
  outputCompression?: number | undefined;
@@ -178,7 +178,7 @@ declare const openaiImageModelGenerationOptions: _ai_sdk_provider_utils.LazySche
178
178
  }>;
179
179
  type OpenAIImageModelGenerationOptions = InferSchema<typeof openaiImageModelGenerationOptions>;
180
180
  declare const openaiImageModelEditOptions: _ai_sdk_provider_utils.LazySchema<{
181
- quality?: "low" | "medium" | "high" | "auto" | "standard" | "hd" | undefined;
181
+ quality?: "low" | "medium" | "high" | "xhigh" | "max" | "auto" | "standard" | "hd" | undefined;
182
182
  background?: "auto" | "transparent" | "opaque" | undefined;
183
183
  outputFormat?: "png" | "jpeg" | "webp" | undefined;
184
184
  outputCompression?: number | undefined;
@@ -486,6 +486,7 @@ type OpenAIResponsesFunctionCall = {
486
486
  call_id: string;
487
487
  name: string;
488
488
  arguments: string;
489
+ async?: boolean;
489
490
  id?: string;
490
491
  namespace?: string;
491
492
  caller?: OpenAIResponsesToolCaller;
@@ -547,6 +548,7 @@ type OpenAIResponsesCustomToolCall = {
547
548
  call_id: string;
548
549
  name: string;
549
550
  input: string;
551
+ async?: boolean;
550
552
  };
551
553
  type OpenAIResponsesCustomToolCallOutput = {
552
554
  type: 'custom_tool_call_output';
@@ -704,6 +706,7 @@ type OpenAIResponsesFunctionTool = {
704
706
  name: string;
705
707
  description: string | undefined;
706
708
  parameters: JSONSchema7;
709
+ async?: boolean;
707
710
  strict?: boolean;
708
711
  defer_loading?: boolean;
709
712
  allowed_callers?: Array<'direct' | 'programmatic'>;
@@ -788,7 +791,7 @@ type OpenAIResponsesTool = OpenAIResponsesFunctionTool | {
788
791
  output_compression: number | undefined;
789
792
  output_format: 'png' | 'jpeg' | 'webp' | undefined;
790
793
  partial_images: number | undefined;
791
- quality: 'auto' | 'low' | 'medium' | 'high' | undefined;
794
+ quality: 'auto' | 'low' | 'medium' | 'high' | 'xhigh' | 'max' | undefined;
792
795
  size: 'auto' | '1024x1024' | '1024x1536' | '1536x1024' | (string & {}) | undefined;
793
796
  }
794
797
  /**
@@ -815,6 +818,7 @@ type OpenAIResponsesTool = OpenAIResponsesFunctionTool | {
815
818
  type: 'custom';
816
819
  name: string;
817
820
  description?: string;
821
+ async?: boolean;
818
822
  format?: {
819
823
  type: 'grammar';
820
824
  syntax: 'regex' | 'lark';
@@ -1108,6 +1112,7 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
1108
1112
  call_id: string;
1109
1113
  name: string;
1110
1114
  arguments: string;
1115
+ async?: boolean | null | undefined;
1111
1116
  namespace?: string | null | undefined;
1112
1117
  caller?: {
1113
1118
  type: "direct";
@@ -1184,6 +1189,7 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
1184
1189
  call_id: string;
1185
1190
  name: string;
1186
1191
  input: string;
1192
+ async?: boolean | null | undefined;
1187
1193
  } | {
1188
1194
  type: "shell_call";
1189
1195
  id: string;
@@ -1360,6 +1366,7 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
1360
1366
  name: string;
1361
1367
  arguments: string;
1362
1368
  status: "completed" | "in_progress" | "incomplete";
1369
+ async?: boolean | null | undefined;
1363
1370
  namespace?: string | null | undefined;
1364
1371
  caller?: {
1365
1372
  type: "direct";
@@ -1374,6 +1381,7 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
1374
1381
  name: string;
1375
1382
  input: string;
1376
1383
  status: "completed";
1384
+ async?: boolean | null | undefined;
1377
1385
  } | {
1378
1386
  type: "code_interpreter_call";
1379
1387
  id: string;
@@ -1818,6 +1826,7 @@ declare const webSearch: (args?: Parameters<typeof webSearchToolFactory>[0]) =>
1818
1826
 
1819
1827
  type OpenAIResponsesModelId = 'gpt-3.5-turbo-0125' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo' | 'gpt-4.1-2025-04-14' | 'gpt-4.1-mini-2025-04-14' | 'gpt-4.1-mini' | 'gpt-4.1-nano-2025-04-14' | 'gpt-4.1-nano' | 'gpt-4.1' | 'gpt-4o-2024-05-13' | 'gpt-4o-2024-08-06' | 'gpt-4o-2024-11-20' | 'gpt-4o-mini-2024-07-18' | 'gpt-4o-mini' | 'gpt-4o' | 'gpt-5.1' | 'gpt-5.1-2025-11-13' | 'gpt-5.1-chat-latest' | 'gpt-5.1-codex-mini' | 'gpt-5.1-codex' | 'gpt-5.1-codex-max' | 'gpt-5.2' | 'gpt-5.2-2025-12-11' | 'gpt-5.2-chat-latest' | 'gpt-5.2-pro' | 'gpt-5.2-pro-2025-12-11' | 'gpt-5.2-codex' | 'gpt-5.3-chat-latest' | 'gpt-5.3-codex' | 'gpt-5.4' | 'gpt-5.4-2026-03-05' | 'gpt-5.4-mini' | 'gpt-5.4-mini-2026-03-17' | 'gpt-5.4-nano' | 'gpt-5.4-nano-2026-03-17' | 'gpt-5.4-pro' | 'gpt-5.4-pro-2026-03-05' | 'gpt-5.5' | 'gpt-5.5-2026-04-23' | 'gpt-5.6' | 'gpt-5.6-luna' | 'gpt-5.6-sol' | 'gpt-5.6-terra' | 'gpt-6-astra' | 'gpt-5-2025-08-07' | 'gpt-5-chat-latest' | 'gpt-5-codex' | 'gpt-5-mini-2025-08-07' | 'gpt-5-mini' | 'gpt-5-nano-2025-08-07' | 'gpt-5-nano' | 'gpt-5-pro-2025-10-06' | 'gpt-5-pro' | 'gpt-5' | 'o1-2024-12-17' | 'o1' | 'o3-2025-04-16' | 'o3-mini-2025-01-31' | 'o3-mini' | 'o3' | 'o4-mini' | 'o4-mini-2025-04-16' | (string & {});
1820
1828
 
1829
+ declare const openaiResponsesSupportedUrls: Record<string, RegExp[]>;
1821
1830
  declare class OpenAIResponsesLanguageModel implements LanguageModelV4 {
1822
1831
  readonly specificationVersion = "v4";
1823
1832
  readonly modelId: OpenAIResponsesModelId;
@@ -1833,7 +1842,11 @@ declare class OpenAIResponsesLanguageModel implements LanguageModelV4 {
1833
1842
  constructor(modelId: OpenAIResponsesModelId, config: OpenAIConfig);
1834
1843
  readonly supportedUrls: Record<string, RegExp[]>;
1835
1844
  get provider(): string;
1836
- protected getArgs({ maxOutputTokens, temperature, stopSequences, topP, topK, presencePenalty, frequencyPenalty, seed, prompt, reasoning, providerOptions, tools, toolChoice, responseFormat, }: LanguageModelV4CallOptions): Promise<{
1845
+ static prepareRequest({ modelId, config, options: { maxOutputTokens, temperature, stopSequences, topP, topK, presencePenalty, frequencyPenalty, seed, prompt, reasoning, providerOptions, tools, toolChoice, responseFormat, }, }: {
1846
+ modelId: OpenAIResponsesModelId;
1847
+ config: OpenAIConfig;
1848
+ options: LanguageModelV4CallOptions;
1849
+ }): Promise<{
1837
1850
  webSearchToolName: string | undefined;
1838
1851
  args: {
1839
1852
  tools: OpenAIResponsesTool[] | undefined;
@@ -1923,6 +1936,7 @@ declare class OpenAIResponsesLanguageModel implements LanguageModelV4 {
1923
1936
  providerOptionsName: string;
1924
1937
  isShellProviderExecuted: boolean;
1925
1938
  }>;
1939
+ private getArgs;
1926
1940
  doGenerate(options: LanguageModelV4CallOptions): Promise<LanguageModelV4GenerateResult>;
1927
1941
  doStream(options: LanguageModelV4CallOptions): Promise<LanguageModelV4StreamResult>;
1928
1942
  }
@@ -1948,6 +1962,20 @@ type OpenaiResponsesReasoningProviderMetadata = {
1948
1962
  type OpenaiResponsesProviderMetadata = {
1949
1963
  openai: ResponsesProviderMetadata;
1950
1964
  };
1965
+ type ResponsesToolCallProviderMetadata = {
1966
+ itemId: string;
1967
+ async?: boolean;
1968
+ namespace?: string;
1969
+ caller?: {
1970
+ type: 'direct';
1971
+ } | {
1972
+ type: 'program';
1973
+ callerId: string;
1974
+ };
1975
+ };
1976
+ type OpenaiResponsesToolCallProviderMetadata = {
1977
+ openai: ResponsesToolCallProviderMetadata;
1978
+ };
1951
1979
  type ResponsesCompactionProviderMetadata = {
1952
1980
  type: 'compaction';
1953
1981
  itemId: string;
@@ -2287,7 +2315,7 @@ declare const imageGenerationArgsSchema: _ai_sdk_provider_utils.LazySchema<{
2287
2315
  outputCompression?: number | undefined;
2288
2316
  outputFormat?: "png" | "jpeg" | "webp" | undefined;
2289
2317
  partialImages?: number | undefined;
2290
- quality?: "low" | "medium" | "high" | "auto" | undefined;
2318
+ quality?: "low" | "medium" | "high" | "xhigh" | "max" | "auto" | undefined;
2291
2319
  size?: string | undefined;
2292
2320
  }>;
2293
2321
  declare const imageGenerationOutputSchema: _ai_sdk_provider_utils.LazySchema<{
@@ -2343,9 +2371,10 @@ type ImageGenerationArgs = {
2343
2371
  partialImages?: number;
2344
2372
  /**
2345
2373
  * The quality of the generated image.
2346
- * One of low, medium, high, or auto. Default: auto.
2374
+ * One of low, medium, high, xhigh, max, or auto. Default: auto.
2375
+ * xhigh and max are supported by GPT Image 2.5 models.
2347
2376
  */
2348
- quality?: 'auto' | 'low' | 'medium' | 'high';
2377
+ quality?: 'auto' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
2349
2378
  /**
2350
2379
  * The size of the generated image.
2351
2380
  * One of 1024x1024, 1024x1536, 1536x1024, or auto. gpt-image-2 also accepts
@@ -2472,4 +2501,4 @@ declare const webSearchPreview: _ai_sdk_provider_utils.ProviderExecutedToolFacto
2472
2501
  };
2473
2502
  }, {}>;
2474
2503
 
2475
- export { type ApplyPatchOperation, OpenAIChatLanguageModel, type OpenAIChatModelId, OpenAICompletionLanguageModel, type OpenAICompletionModelId, OpenAIEmbeddingModel, type OpenAIEmbeddingModelId, type OpenAIEmbeddingModelOptions, OpenAIImageModel, type OpenAIImageModelEditOptions, type OpenAIImageModelGenerationOptions, type OpenAIImageModelId, type OpenAIImageModelOptions, type OpenAILanguageModelChatOptions, type OpenAILanguageModelCompletionOptions, OpenAIResponsesLanguageModel, OpenAISpeechModel, type OpenAISpeechModelId, type OpenAISpeechModelOptions, type OpenAITranscriptionCallOptions, OpenAITranscriptionModel, type OpenAITranscriptionModelId, type OpenAITranscriptionModelOptions, type OpenAITranscriptionStreamOptions, type OpenaiResponsesCompactionProviderMetadata, type OpenaiResponsesProviderMetadata, type OpenaiResponsesReasoningProviderMetadata, type OpenaiResponsesSourceDocumentProviderMetadata, type OpenaiResponsesTextProviderMetadata, type ResponsesCompactionProviderMetadata, type ResponsesProviderMetadata, type ResponsesReasoningProviderMetadata, type ResponsesSourceDocumentProviderMetadata, type ResponsesTextProviderMetadata, applyPatch, applyPatchArgsSchema, applyPatchInputSchema, applyPatchOutputSchema, applyPatchToolFactory, codeInterpreter, codeInterpreterArgsSchema, codeInterpreterInputSchema, codeInterpreterOutputSchema, codeInterpreterToolFactory, fileSearch, fileSearchArgsSchema, fileSearchOutputSchema, getMaxImagesPerCall, hasDefaultResponseFormat, imageGeneration, imageGenerationArgsSchema, imageGenerationOutputSchema, mapWebSearchOutput, modelMaxImagesPerCall, openAITranscriptionModelOptions, openaiEmbeddingModelOptions, openaiImageModelEditOptions, openaiImageModelGenerationOptions, openaiImageModelOptions, openaiLanguageModelChatOptions, openaiLanguageModelCompletionOptions, openaiSpeechModelOptionsSchema, programmaticToolCalling, programmaticToolCallingInputSchema, programmaticToolCallingOutputSchema, webSearch, webSearchArgsSchema, webSearchOutputSchema, webSearchPreview, webSearchPreviewArgsSchema, webSearchPreviewInputSchema, webSearchToolFactory };
2504
+ export { type ApplyPatchOperation, OpenAIChatLanguageModel, type OpenAIChatModelId, OpenAICompletionLanguageModel, type OpenAICompletionModelId, OpenAIEmbeddingModel, type OpenAIEmbeddingModelId, type OpenAIEmbeddingModelOptions, OpenAIImageModel, type OpenAIImageModelEditOptions, type OpenAIImageModelGenerationOptions, type OpenAIImageModelId, type OpenAIImageModelOptions, type OpenAILanguageModelChatOptions, type OpenAILanguageModelCompletionOptions, OpenAIResponsesLanguageModel, OpenAISpeechModel, type OpenAISpeechModelId, type OpenAISpeechModelOptions, type OpenAITranscriptionCallOptions, OpenAITranscriptionModel, type OpenAITranscriptionModelId, type OpenAITranscriptionModelOptions, type OpenAITranscriptionStreamOptions, type OpenaiResponsesCompactionProviderMetadata, type OpenaiResponsesProviderMetadata, type OpenaiResponsesReasoningProviderMetadata, type OpenaiResponsesSourceDocumentProviderMetadata, type OpenaiResponsesTextProviderMetadata, type OpenaiResponsesToolCallProviderMetadata, type ResponsesCompactionProviderMetadata, type ResponsesProviderMetadata, type ResponsesReasoningProviderMetadata, type ResponsesSourceDocumentProviderMetadata, type ResponsesTextProviderMetadata, type ResponsesToolCallProviderMetadata, applyPatch, applyPatchArgsSchema, applyPatchInputSchema, applyPatchOutputSchema, applyPatchToolFactory, codeInterpreter, codeInterpreterArgsSchema, codeInterpreterInputSchema, codeInterpreterOutputSchema, codeInterpreterToolFactory, fileSearch, fileSearchArgsSchema, fileSearchOutputSchema, getMaxImagesPerCall, hasDefaultResponseFormat, imageGeneration, imageGenerationArgsSchema, imageGenerationOutputSchema, mapWebSearchOutput, modelMaxImagesPerCall, openAITranscriptionModelOptions, openaiEmbeddingModelOptions, openaiImageModelEditOptions, openaiImageModelGenerationOptions, openaiImageModelOptions, openaiLanguageModelChatOptions, openaiLanguageModelCompletionOptions, openaiResponsesSupportedUrls, openaiSpeechModelOptionsSchema, programmaticToolCalling, programmaticToolCallingInputSchema, programmaticToolCallingOutputSchema, webSearch, webSearchArgsSchema, webSearchOutputSchema, webSearchPreview, webSearchPreviewArgsSchema, webSearchPreviewInputSchema, webSearchToolFactory };
@@ -49,6 +49,7 @@ function getOpenAILanguageModelCapabilities(modelId) {
49
49
  supportsFlexProcessing,
50
50
  supportsPriorityProcessing,
51
51
  supportsConfigurationUpdate: isGpt6OrLaterModel,
52
+ supportsAsyncToolCalling: isGpt6OrLaterModel,
52
53
  supportedReasoningEfforts: isGpt6OrLaterModel ? ["low", "medium", "high", "xhigh", "max"] : void 0,
53
54
  isReasoningModel,
54
55
  systemMessageMode,
@@ -2129,9 +2130,10 @@ var baseImageModelOptionsObject = z9.object({
2129
2130
  /**
2130
2131
  * Quality of the generated image(s).
2131
2132
  *
2132
- * Valid values: `standard`, `hd`, `low`, `medium`, `high`, `auto`.
2133
+ * Valid values: `standard`, `hd`, `low`, `medium`, `high`, `xhigh`, `max`, `auto`.
2134
+ * `xhigh` and `max` are supported by GPT Image 2.5 models.
2133
2135
  */
2134
- quality: z9.enum(["standard", "hd", "low", "medium", "high", "auto"]).optional(),
2136
+ quality: z9.enum(["standard", "hd", "low", "medium", "high", "xhigh", "max", "auto"]).optional(),
2135
2137
  /**
2136
2138
  * Background behavior for the generated image(s).
2137
2139
  *
@@ -3873,7 +3875,7 @@ async function convertToOpenAIResponsesInput({
3873
3875
  customProviderToolNames,
3874
3876
  outputSchemaToolNames
3875
3877
  }) {
3876
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K;
3878
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P;
3877
3879
  let input = [];
3878
3880
  const warnings = [];
3879
3881
  const processedApprovalIds = /* @__PURE__ */ new Set();
@@ -4093,7 +4095,8 @@ async function convertToOpenAIResponsesInput({
4093
4095
  }
4094
4096
  const id = (_f = (_c = (_b = part.providerOptions) == null ? void 0 : _b[providerOptionsName]) == null ? void 0 : _c.itemId) != null ? _f : (_e = (_d = part.providerMetadata) == null ? void 0 : _d[providerOptionsName]) == null ? void 0 : _e.itemId;
4095
4097
  const namespace = (_k = (_h = (_g = part.providerOptions) == null ? void 0 : _g[providerOptionsName]) == null ? void 0 : _h.namespace) != null ? _k : (_j = (_i = part.providerMetadata) == null ? void 0 : _i[providerOptionsName]) == null ? void 0 : _j.namespace;
4096
- const caller = (_m = (_l = part.providerOptions) == null ? void 0 : _l[providerOptionsName]) == null ? void 0 : _m.caller;
4098
+ const isAsync = (_p = (_m = (_l = part.providerOptions) == null ? void 0 : _l[providerOptionsName]) == null ? void 0 : _m.async) != null ? _p : (_o = (_n = part.providerMetadata) == null ? void 0 : _n[providerOptionsName]) == null ? void 0 : _o.async;
4099
+ const caller = (_r = (_q = part.providerOptions) == null ? void 0 : _q[providerOptionsName]) == null ? void 0 : _r.caller;
4097
4100
  if (hasConversation && id != null) {
4098
4101
  break;
4099
4102
  }
@@ -4117,7 +4120,7 @@ async function convertToOpenAIResponsesInput({
4117
4120
  type: "tool_search_call",
4118
4121
  id: id != null ? id : part.toolCallId,
4119
4122
  execution,
4120
- call_id: (_n = parsedInput.call_id) != null ? _n : null,
4123
+ call_id: (_s = parsedInput.call_id) != null ? _s : null,
4121
4124
  status: "completed",
4122
4125
  arguments: parsedInput.arguments
4123
4126
  });
@@ -4149,7 +4152,7 @@ async function convertToOpenAIResponsesInput({
4149
4152
  break;
4150
4153
  }
4151
4154
  }
4152
- const isProviderDefinedToolCall = hasLocalShellTool && resolvedToolName === "local_shell" || hasShellTool && resolvedToolName === "shell" || hasApplyPatchTool && resolvedToolName === "apply_patch" || hasComputerTool && resolvedToolName === "computer" || ((_o = customProviderToolNames == null ? void 0 : customProviderToolNames.has(resolvedToolName)) != null ? _o : false);
4155
+ const isProviderDefinedToolCall = hasLocalShellTool && resolvedToolName === "local_shell" || hasShellTool && resolvedToolName === "shell" || hasApplyPatchTool && resolvedToolName === "apply_patch" || hasComputerTool && resolvedToolName === "computer" || ((_t = customProviderToolNames == null ? void 0 : customProviderToolNames.has(resolvedToolName)) != null ? _t : false);
4153
4156
  if (hasPreviousResponseId && store && id != null && isProviderDefinedToolCall) {
4154
4157
  break;
4155
4158
  }
@@ -4262,6 +4265,7 @@ async function convertToOpenAIResponsesInput({
4262
4265
  call_id: part.toolCallId,
4263
4266
  name: resolvedToolName,
4264
4267
  input: typeof part.input === "string" ? part.input : JSON.stringify(part.input),
4268
+ ...isAsync != null && { async: isAsync },
4265
4269
  id
4266
4270
  });
4267
4271
  break;
@@ -4271,6 +4275,7 @@ async function convertToOpenAIResponsesInput({
4271
4275
  call_id: part.toolCallId,
4272
4276
  name: resolvedToolName,
4273
4277
  arguments: serializeToolCallArguments2(part.input),
4278
+ ...isAsync != null && { async: isAsync },
4274
4279
  ...namespace != null && { namespace },
4275
4280
  ...caller != null && {
4276
4281
  caller: mapToolCaller(caller)
@@ -4290,7 +4295,7 @@ async function convertToOpenAIResponsesInput({
4290
4295
  part.toolName
4291
4296
  );
4292
4297
  if (part.toolName === toolSearchToolName) {
4293
- const itemId = (_u = (_t = (_q = (_p = part.providerOptions) == null ? void 0 : _p[providerOptionsName]) == null ? void 0 : _q.itemId) != null ? _t : (_s = (_r = part.providerMetadata) == null ? void 0 : _r[providerOptionsName]) == null ? void 0 : _s.itemId) != null ? _u : part.toolCallId;
4298
+ const itemId = (_z = (_y = (_v = (_u = part.providerOptions) == null ? void 0 : _u[providerOptionsName]) == null ? void 0 : _v.itemId) != null ? _y : (_x = (_w = part.providerMetadata) == null ? void 0 : _w[providerOptionsName]) == null ? void 0 : _x.itemId) != null ? _z : part.toolCallId;
4294
4299
  if (store) {
4295
4300
  input.push({ type: "item_reference", id: itemId });
4296
4301
  } else if (part.output.type === "json") {
@@ -4310,7 +4315,7 @@ async function convertToOpenAIResponsesInput({
4310
4315
  break;
4311
4316
  }
4312
4317
  if (resolvedResultToolName === "programmatic_tool_calling") {
4313
- const itemId = (_A = (_z = (_w = (_v = part.providerOptions) == null ? void 0 : _v[providerOptionsName]) == null ? void 0 : _w.itemId) != null ? _z : (_y = (_x = part.providerMetadata) == null ? void 0 : _x[providerOptionsName]) == null ? void 0 : _y.itemId) != null ? _A : part.toolCallId;
4318
+ const itemId = (_F = (_E = (_B = (_A = part.providerOptions) == null ? void 0 : _A[providerOptionsName]) == null ? void 0 : _B.itemId) != null ? _E : (_D = (_C = part.providerMetadata) == null ? void 0 : _C[providerOptionsName]) == null ? void 0 : _D.itemId) != null ? _F : part.toolCallId;
4314
4319
  if (store) {
4315
4320
  input.push({ type: "item_reference", id: itemId });
4316
4321
  } else if (part.output.type === "json") {
@@ -4350,7 +4355,7 @@ async function convertToOpenAIResponsesInput({
4350
4355
  break;
4351
4356
  }
4352
4357
  if (store) {
4353
- const itemId = (_D = (_C = (_B = part.providerOptions) == null ? void 0 : _B[providerOptionsName]) == null ? void 0 : _C.itemId) != null ? _D : part.toolCallId;
4358
+ const itemId = (_I = (_H = (_G = part.providerOptions) == null ? void 0 : _G[providerOptionsName]) == null ? void 0 : _H.itemId) != null ? _I : part.toolCallId;
4354
4359
  input.push({ type: "item_reference", id: itemId });
4355
4360
  } else {
4356
4361
  warnings.push({
@@ -4435,7 +4440,7 @@ async function convertToOpenAIResponsesInput({
4435
4440
  }
4436
4441
  case "custom": {
4437
4442
  if (part.kind === "openai.compaction") {
4438
- const providerOptions2 = (_E = part.providerOptions) == null ? void 0 : _E[providerOptionsName];
4443
+ const providerOptions2 = (_J = part.providerOptions) == null ? void 0 : _J[providerOptionsName];
4439
4444
  const id = providerOptions2 == null ? void 0 : providerOptions2.itemId;
4440
4445
  if (hasConversation && id != null) {
4441
4446
  break;
@@ -4541,7 +4546,7 @@ ${text}`,
4541
4546
  }
4542
4547
  const output = part.output;
4543
4548
  if (output.type === "execution-denied") {
4544
- const approvalId = (_G = (_F = output.providerOptions) == null ? void 0 : _F.openai) == null ? void 0 : _G.approvalId;
4549
+ const approvalId = (_L = (_K = output.providerOptions) == null ? void 0 : _K.openai) == null ? void 0 : _L.approvalId;
4545
4550
  if (approvalId) {
4546
4551
  continue;
4547
4552
  }
@@ -4621,7 +4626,7 @@ ${text}`,
4621
4626
  file_id: parsedOutput.output.fileId,
4622
4627
  detail: parsedOutput.output.detail
4623
4628
  },
4624
- acknowledged_safety_checks: (_H = parsedOutput.acknowledgedSafetyChecks) == null ? void 0 : _H.map((safetyCheck) => ({
4629
+ acknowledged_safety_checks: (_M = parsedOutput.acknowledgedSafetyChecks) == null ? void 0 : _M.map((safetyCheck) => ({
4625
4630
  id: safetyCheck.id,
4626
4631
  code: safetyCheck.code,
4627
4632
  message: safetyCheck.message
@@ -4650,7 +4655,7 @@ ${text}`,
4650
4655
  break;
4651
4656
  case "execution-denied":
4652
4657
  outputValue = convertScalarOutput(
4653
- (_I = output.reason) != null ? _I : "Tool call execution denied."
4658
+ (_N = output.reason) != null ? _N : "Tool call execution denied."
4654
4659
  );
4655
4660
  break;
4656
4661
  case "json":
@@ -4756,7 +4761,7 @@ ${text}`,
4756
4761
  warnings
4757
4762
  });
4758
4763
  const caller = mapToolCaller(
4759
- (_K = (_J = part.providerOptions) == null ? void 0 : _J[providerOptionsName]) == null ? void 0 : _K.caller
4764
+ (_P = (_O = part.providerOptions) == null ? void 0 : _O[providerOptionsName]) == null ? void 0 : _P.caller
4760
4765
  );
4761
4766
  input.push({
4762
4767
  type: "function_call_output",
@@ -5108,6 +5113,7 @@ var openaiResponsesChunkSchema = lazySchema18(
5108
5113
  call_id: z20.string(),
5109
5114
  name: z20.string(),
5110
5115
  arguments: z20.string(),
5116
+ async: z20.boolean().nullish(),
5111
5117
  namespace: z20.string().nullish(),
5112
5118
  caller: openaiResponsesToolCallerSchema.nullish()
5113
5119
  }),
@@ -5182,7 +5188,8 @@ var openaiResponsesChunkSchema = lazySchema18(
5182
5188
  id: z20.string(),
5183
5189
  call_id: z20.string(),
5184
5190
  name: z20.string(),
5185
- input: z20.string()
5191
+ input: z20.string(),
5192
+ async: z20.boolean().nullish()
5186
5193
  }),
5187
5194
  z20.object({
5188
5195
  type: z20.literal("shell_call"),
@@ -5255,6 +5262,7 @@ var openaiResponsesChunkSchema = lazySchema18(
5255
5262
  call_id: z20.string(),
5256
5263
  name: z20.string(),
5257
5264
  arguments: z20.string(),
5265
+ async: z20.boolean().nullish(),
5258
5266
  status: z20.enum(["in_progress", "completed", "incomplete"]),
5259
5267
  namespace: z20.string().nullish(),
5260
5268
  caller: openaiResponsesToolCallerSchema.nullish()
@@ -5267,6 +5275,7 @@ var openaiResponsesChunkSchema = lazySchema18(
5267
5275
  call_id: z20.string(),
5268
5276
  name: z20.string(),
5269
5277
  input: z20.string(),
5278
+ async: z20.boolean().nullish(),
5270
5279
  status: z20.literal("completed")
5271
5280
  }),
5272
5281
  z20.object({
@@ -5704,6 +5713,7 @@ var openaiResponsesResponseSchema = lazySchema18(
5704
5713
  name: z20.string(),
5705
5714
  arguments: z20.string(),
5706
5715
  id: z20.string(),
5716
+ async: z20.boolean().nullish(),
5707
5717
  namespace: z20.string().nullish(),
5708
5718
  caller: openaiResponsesToolCallerSchema.nullish()
5709
5719
  }),
@@ -5714,7 +5724,8 @@ var openaiResponsesResponseSchema = lazySchema18(
5714
5724
  call_id: z20.string(),
5715
5725
  name: z20.string(),
5716
5726
  input: z20.string(),
5717
- id: z20.string()
5727
+ id: z20.string(),
5728
+ async: z20.boolean().nullish()
5718
5729
  }),
5719
5730
  openaiResponsesComputerCallSchema,
5720
5731
  z20.object({
@@ -6288,7 +6299,7 @@ var imageGenerationArgsSchema = lazySchema22(
6288
6299
  outputCompression: z24.number().int().min(0).max(100).optional(),
6289
6300
  outputFormat: z24.enum(["png", "jpeg", "webp"]).optional(),
6290
6301
  partialImages: z24.number().int().min(0).max(3).optional(),
6291
- quality: z24.enum(["auto", "low", "medium", "high"]).optional(),
6302
+ quality: z24.enum(["auto", "low", "medium", "high", "xhigh", "max"]).optional(),
6292
6303
  size: z24.union([
6293
6304
  z24.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]),
6294
6305
  z24.string().regex(/^\d+x\d+$/)
@@ -6320,6 +6331,7 @@ var customArgsSchema = lazySchema23(
6320
6331
  () => zodSchema23(
6321
6332
  z25.object({
6322
6333
  description: z25.string().optional(),
6334
+ async: z25.boolean().optional(),
6323
6335
  format: z25.union([
6324
6336
  z25.object({
6325
6337
  type: z25.literal("grammar"),
@@ -6525,7 +6537,8 @@ async function prepareResponsesTools({
6525
6537
  allowedTools,
6526
6538
  toolNameMapping,
6527
6539
  customProviderToolNames,
6528
- outputSchemaToolNames
6540
+ outputSchemaToolNames,
6541
+ supportsAsyncToolCalling = true
6529
6542
  }) {
6530
6543
  var _a2, _b, _c, _d;
6531
6544
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
@@ -6559,7 +6572,13 @@ async function prepareResponsesTools({
6559
6572
  }
6560
6573
  const openaiFunctionTool = prepareFunctionTool({
6561
6574
  tool,
6562
- options: openaiOptions
6575
+ options: openaiOptions,
6576
+ async: resolveAsyncToolOption({
6577
+ value: openaiOptions == null ? void 0 : openaiOptions.async,
6578
+ supportsAsyncToolCalling,
6579
+ toolName: tool.name,
6580
+ toolWarnings
6581
+ })
6563
6582
  });
6564
6583
  const namespace = openaiOptions == null ? void 0 : openaiOptions.namespace;
6565
6584
  if (namespace == null) {
@@ -6748,6 +6767,12 @@ async function prepareResponsesTools({
6748
6767
  type: "custom",
6749
6768
  name: tool.name,
6750
6769
  description: args.description,
6770
+ ...resolveAsyncToolOption({
6771
+ value: args.async,
6772
+ supportsAsyncToolCalling,
6773
+ toolName: tool.name,
6774
+ toolWarnings
6775
+ }) != null ? { async: args.async } : {},
6751
6776
  format: args.format
6752
6777
  });
6753
6778
  resolvedCustomProviderToolNames.add(tool.name);
@@ -6927,7 +6952,8 @@ function toAllowedToolResolution(tool) {
6927
6952
  }
6928
6953
  function prepareFunctionTool({
6929
6954
  tool,
6930
- options
6955
+ options,
6956
+ async
6931
6957
  }) {
6932
6958
  const deferLoading = options == null ? void 0 : options.deferLoading;
6933
6959
  return {
@@ -6935,12 +6961,29 @@ function prepareFunctionTool({
6935
6961
  name: tool.name,
6936
6962
  description: tool.description,
6937
6963
  parameters: tool.inputSchema,
6964
+ ...async != null ? { async } : {},
6938
6965
  ...tool.strict != null ? { strict: tool.strict } : {},
6939
6966
  ...deferLoading != null ? { defer_loading: deferLoading } : {},
6940
6967
  ...(options == null ? void 0 : options.allowedCallers) != null ? { allowed_callers: options.allowedCallers } : {},
6941
6968
  ...(options == null ? void 0 : options.outputSchema) != null ? { output_schema: options.outputSchema } : {}
6942
6969
  };
6943
6970
  }
6971
+ function resolveAsyncToolOption({
6972
+ value,
6973
+ supportsAsyncToolCalling,
6974
+ toolName,
6975
+ toolWarnings
6976
+ }) {
6977
+ if (value !== true || supportsAsyncToolCalling) {
6978
+ return value;
6979
+ }
6980
+ toolWarnings.push({
6981
+ type: "unsupported",
6982
+ feature: `async tool calling for "${toolName}"`,
6983
+ details: "Async tool calling is only supported by GPT-6 and later models."
6984
+ });
6985
+ return void 0;
6986
+ }
6944
6987
  function mapShellEnvironment(environment) {
6945
6988
  if (environment.type === "containerReference") {
6946
6989
  const env2 = environment;
@@ -7078,13 +7121,14 @@ function mapComputerCallInput({
7078
7121
  status
7079
7122
  };
7080
7123
  }
7124
+ var openaiResponsesSupportedUrls = {
7125
+ "image/*": [/^https?:\/\/.*$/],
7126
+ "application/pdf": [/^https?:\/\/.*$/]
7127
+ };
7081
7128
  var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7082
7129
  constructor(modelId, config) {
7083
7130
  this.specificationVersion = "v4";
7084
- this.supportedUrls = {
7085
- "image/*": [/^https?:\/\/.*$/],
7086
- "application/pdf": [/^https?:\/\/.*$/]
7087
- };
7131
+ this.supportedUrls = openaiResponsesSupportedUrls;
7088
7132
  this.modelId = modelId;
7089
7133
  this.config = config;
7090
7134
  }
@@ -7103,25 +7147,29 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7103
7147
  get provider() {
7104
7148
  return this.config.provider;
7105
7149
  }
7106
- async getArgs({
7107
- maxOutputTokens,
7108
- temperature,
7109
- stopSequences,
7110
- topP,
7111
- topK,
7112
- presencePenalty,
7113
- frequencyPenalty,
7114
- seed,
7115
- prompt,
7116
- reasoning,
7117
- providerOptions,
7118
- tools,
7119
- toolChoice,
7120
- responseFormat
7150
+ static async prepareRequest({
7151
+ modelId,
7152
+ config,
7153
+ options: {
7154
+ maxOutputTokens,
7155
+ temperature,
7156
+ stopSequences,
7157
+ topP,
7158
+ topK,
7159
+ presencePenalty,
7160
+ frequencyPenalty,
7161
+ seed,
7162
+ prompt,
7163
+ reasoning,
7164
+ providerOptions,
7165
+ tools,
7166
+ toolChoice,
7167
+ responseFormat
7168
+ }
7121
7169
  }) {
7122
7170
  var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
7123
7171
  const warnings = [];
7124
- const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
7172
+ const modelCapabilities = getOpenAILanguageModelCapabilities(modelId);
7125
7173
  if (topK != null) {
7126
7174
  warnings.push({ type: "unsupported", feature: "topK" });
7127
7175
  }
@@ -7137,7 +7185,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7137
7185
  if (stopSequences != null) {
7138
7186
  warnings.push({ type: "unsupported", feature: "stopSequences" });
7139
7187
  }
7140
- const providerOptionsName = this.config.provider.includes("azure") ? "azure" : "openai";
7188
+ const providerOptionsName = config.provider.includes("azure") ? "azure" : "openai";
7141
7189
  let openaiOptions = await parseProviderOptions8({
7142
7190
  provider: providerOptionsName,
7143
7191
  providerOptions,
@@ -7157,7 +7205,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7157
7205
  warnings.push({
7158
7206
  type: "unsupported",
7159
7207
  feature: "reasoningEffort",
7160
- details: `${this.modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
7208
+ details: `${modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
7161
7209
  });
7162
7210
  resolvedReasoningEffort = void 0;
7163
7211
  }
@@ -7199,14 +7247,15 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7199
7247
  allowedTools: (_c = openaiOptions == null ? void 0 : openaiOptions.allowedTools) != null ? _c : void 0,
7200
7248
  toolNameMapping,
7201
7249
  customProviderToolNames,
7202
- outputSchemaToolNames
7250
+ outputSchemaToolNames,
7251
+ supportsAsyncToolCalling: modelCapabilities.supportsAsyncToolCalling
7203
7252
  });
7204
7253
  const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
7205
7254
  prompt,
7206
7255
  toolNameMapping,
7207
7256
  systemMessageMode: (_d = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _d : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
7208
7257
  providerOptionsName,
7209
- fileIdPrefixes: this.config.fileIdPrefixes,
7258
+ fileIdPrefixes: config.fileIdPrefixes,
7210
7259
  passThroughUnsupportedFiles: (_e = openaiOptions == null ? void 0 : openaiOptions.passThroughUnsupportedFiles) != null ? _e : false,
7211
7260
  store: (_f = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _f : true,
7212
7261
  hasConversation: (openaiOptions == null ? void 0 : openaiOptions.conversation) != null,
@@ -7271,7 +7320,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7271
7320
  addInclude("reasoning.encrypted_content");
7272
7321
  }
7273
7322
  const baseArgs = {
7274
- model: this.modelId,
7323
+ model: modelId,
7275
7324
  input,
7276
7325
  temperature,
7277
7326
  top_p: topP,
@@ -7437,6 +7486,13 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7437
7486
  isShellProviderExecuted
7438
7487
  };
7439
7488
  }
7489
+ getArgs(options) {
7490
+ return _OpenAIResponsesLanguageModel.prepareRequest({
7491
+ modelId: this.modelId,
7492
+ config: this.config,
7493
+ options
7494
+ });
7495
+ }
7440
7496
  async doGenerate(options) {
7441
7497
  var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H;
7442
7498
  const {
@@ -7733,6 +7789,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7733
7789
  providerMetadata: {
7734
7790
  [providerOptionsName]: {
7735
7791
  itemId: part.id,
7792
+ ...part.async != null && { async: part.async },
7736
7793
  ...part.namespace != null && { namespace: part.namespace },
7737
7794
  ...part.caller != null && {
7738
7795
  caller: part.caller.type === "program" ? {
@@ -7794,7 +7851,8 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7794
7851
  input: JSON.stringify(part.input),
7795
7852
  providerMetadata: {
7796
7853
  [providerOptionsName]: {
7797
- itemId: part.id
7854
+ itemId: part.id,
7855
+ ...part.async != null && { async: part.async }
7798
7856
  }
7799
7857
  }
7800
7858
  });
@@ -8121,7 +8179,8 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
8121
8179
  toolName: value.item.name,
8122
8180
  toolCallId: value.item.call_id,
8123
8181
  suppressInputStreaming,
8124
- bufferedInputDeltas: suppressInputStreaming ? [] : void 0
8182
+ bufferedInputDeltas: suppressInputStreaming ? [] : void 0,
8183
+ async: value.item.async
8125
8184
  };
8126
8185
  if (!suppressInputStreaming) {
8127
8186
  controller.enqueue({
@@ -8136,7 +8195,8 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
8136
8195
  );
8137
8196
  ongoingToolCalls[value.output_index] = {
8138
8197
  toolName,
8139
- toolCallId: value.item.call_id
8198
+ toolCallId: value.item.call_id,
8199
+ async: value.item.async
8140
8200
  };
8141
8201
  controller.enqueue({
8142
8202
  type: "tool-input-start",
@@ -8387,6 +8447,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
8387
8447
  providerMetadata: {
8388
8448
  [providerOptionsName]: {
8389
8449
  itemId: item.id,
8450
+ ...item.async != null ? { async: item.async } : (ongoingToolCall == null ? void 0 : ongoingToolCall.async) != null ? { async: ongoingToolCall.async } : {},
8390
8451
  ...item.namespace != null && {
8391
8452
  namespace: item.namespace
8392
8453
  },
@@ -8472,6 +8533,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
8472
8533
  }
8473
8534
  });
8474
8535
  } else if (value.item.type === "custom_tool_call") {
8536
+ const ongoingToolCall = ongoingToolCalls[value.output_index];
8475
8537
  ongoingToolCalls[value.output_index] = void 0;
8476
8538
  hasFunctionCall = true;
8477
8539
  const toolName = toolNameMapping.toCustomToolName(
@@ -8488,7 +8550,8 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
8488
8550
  input: JSON.stringify(value.item.input),
8489
8551
  providerMetadata: {
8490
8552
  [providerOptionsName]: {
8491
- itemId: value.item.id
8553
+ itemId: value.item.id,
8554
+ ...value.item.async != null ? { async: value.item.async } : (ongoingToolCall == null ? void 0 : ongoingToolCall.async) != null ? { async: ongoingToolCall.async } : {}
8492
8555
  }
8493
8556
  }
8494
8557
  });
@@ -9316,6 +9379,7 @@ export {
9316
9379
  openaiImageModelOptions,
9317
9380
  openaiLanguageModelChatOptions,
9318
9381
  openaiLanguageModelCompletionOptions,
9382
+ openaiResponsesSupportedUrls,
9319
9383
  openaiSpeechModelOptionsSchema,
9320
9384
  programmaticToolCalling,
9321
9385
  programmaticToolCallingInputSchema,