@ai-sdk/openai 4.0.59 → 4.0.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -48,14 +48,18 @@ function getOpenAILanguageModelCapabilities(modelId) {
48
48
  const gptVersion = getGptVersion(modelId);
49
49
  const isGptChatModel = (gptVersion == null ? void 0 : gptVersion.minor) == null && ((_b = (_a2 = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _a2.startsWith("chat")) != null ? _b : false);
50
50
  const isGptNanoModel = (_d = (_c = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _c.startsWith("nano")) != null ? _d : false;
51
+ const isGpt6OrLaterModel = gptVersion != null && gptVersion.major >= 6;
51
52
  const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
52
53
  const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
53
54
  const isReasoningModel = oSeriesVersion != null || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
54
- const supportsNonReasoningParameters = gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
55
+ const supportsNonReasoningParameters = !isGpt6OrLaterModel && gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
55
56
  const systemMessageMode = isReasoningModel ? "developer" : "system";
56
57
  return {
57
58
  supportsFlexProcessing,
58
59
  supportsPriorityProcessing,
60
+ supportsConfigurationUpdate: isGpt6OrLaterModel,
61
+ supportsAsyncToolCalling: isGpt6OrLaterModel,
62
+ supportedReasoningEfforts: isGpt6OrLaterModel ? ["low", "medium", "high", "xhigh", "max"] : void 0,
59
63
  isReasoningModel,
60
64
  systemMessageMode,
61
65
  supportsNonReasoningParameters
@@ -1020,7 +1024,17 @@ var OpenAIChatLanguageModel = class _OpenAIChatLanguageModel {
1020
1024
  schema: openaiLanguageModelChatOptions
1021
1025
  })) != null ? _a2 : {};
1022
1026
  const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
1023
- const resolvedReasoningEffort = (_b = openaiOptions.reasoningEffort) != null ? _b : isCustomReasoning(reasoning) ? reasoning : void 0;
1027
+ let resolvedReasoningEffort = (_b = openaiOptions.reasoningEffort) != null ? _b : isCustomReasoning(reasoning) ? reasoning : void 0;
1028
+ if (resolvedReasoningEffort != null && modelCapabilities.supportedReasoningEfforts != null && !modelCapabilities.supportedReasoningEfforts.includes(
1029
+ resolvedReasoningEffort
1030
+ )) {
1031
+ warnings.push({
1032
+ type: "unsupported",
1033
+ feature: "reasoningEffort",
1034
+ details: `${this.modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
1035
+ });
1036
+ resolvedReasoningEffort = void 0;
1037
+ }
1024
1038
  const isReasoningModel = (_c = openaiOptions.forceReasoning) != null ? _c : modelCapabilities.isReasoningModel;
1025
1039
  if (topK != null) {
1026
1040
  warnings.push({ type: "unsupported", feature: "topK" });
@@ -1075,6 +1089,14 @@ var OpenAIChatLanguageModel = class _OpenAIChatLanguageModel {
1075
1089
  // messages:
1076
1090
  messages
1077
1091
  };
1092
+ if (modelCapabilities.supportedReasoningEfforts != null && baseArgs.prompt_cache_retention != null) {
1093
+ baseArgs.prompt_cache_retention = void 0;
1094
+ warnings.push({
1095
+ type: "unsupported",
1096
+ feature: "promptCacheRetention",
1097
+ details: "promptCacheRetention is not supported by GPT-6 and later models; use promptCacheOptions instead"
1098
+ });
1099
+ }
1078
1100
  if (isReasoningModel) {
1079
1101
  if (resolvedReasoningEffort !== "none" || !modelCapabilities.supportsNonReasoningParameters) {
1080
1102
  if (baseArgs.temperature != null) {
@@ -2875,6 +2897,7 @@ var customArgsSchema = lazySchema14(
2875
2897
  () => zodSchema14(
2876
2898
  z15.object({
2877
2899
  description: z15.string().optional(),
2900
+ async: z15.boolean().optional(),
2878
2901
  format: z15.union([
2879
2902
  z15.object({
2880
2903
  type: z15.literal("grammar"),
@@ -3406,6 +3429,7 @@ var openaiTools = {
3406
3429
  * `input` field is a string matching the specified grammar.
3407
3430
  *
3408
3431
  * @param description - An optional description of the tool.
3432
+ * @param async - Whether the model can continue without waiting for the tool result.
3409
3433
  * @param format - The output format constraint (grammar type, syntax, and definition).
3410
3434
  */
3411
3435
  customTool,
@@ -3521,7 +3545,7 @@ var openaiTools = {
3521
3545
  toolSearch
3522
3546
  };
3523
3547
 
3524
- // src/openai-responses-batch.ts
3548
+ // src/openai-batch.ts
3525
3549
  import {
3526
3550
  InvalidArgumentError as InvalidArgumentError2,
3527
3551
  InvalidResponseDataError
@@ -3538,34 +3562,10 @@ import {
3538
3562
  postJsonToApi as postJsonToApi6,
3539
3563
  postToApi,
3540
3564
  safeValidateTypes,
3541
- WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE6,
3542
- WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE6,
3543
3565
  zodSchema as zodSchema26
3544
3566
  } from "@ai-sdk/provider-utils";
3545
3567
  import { z as z28 } from "zod/v4";
3546
3568
 
3547
- // src/openai-config.ts
3548
- function prepareOpenAIConfigForWorkflowDeserialize(config) {
3549
- if (config.provider == null) {
3550
- throw new Error(
3551
- "OpenAI model is missing provider after workflow deserialization."
3552
- );
3553
- }
3554
- return {
3555
- ...config,
3556
- provider: config.provider,
3557
- url: typeof config.url === "function" ? config.url : ({ path }) => {
3558
- if (config.baseURL == null) {
3559
- throw new Error(
3560
- "OpenAI model is missing baseURL after workflow deserialization."
3561
- );
3562
- }
3563
- return `${config.baseURL}${path}`;
3564
- },
3565
- headers: typeof config.headers === "function" ? config.headers : config.headers == null ? void 0 : () => config.headers
3566
- };
3567
- }
3568
-
3569
3569
  // src/responses/convert-openai-responses-usage.ts
3570
3570
  import { createNullLanguageModelUsage as createNullLanguageModelUsage3 } from "@ai-sdk/provider-utils";
3571
3571
  function convertOpenAIResponsesUsage(usage) {
@@ -3911,6 +3911,7 @@ var openaiResponsesChunkSchema = lazySchema24(
3911
3911
  call_id: z25.string(),
3912
3912
  name: z25.string(),
3913
3913
  arguments: z25.string(),
3914
+ async: z25.boolean().nullish(),
3914
3915
  namespace: z25.string().nullish(),
3915
3916
  caller: openaiResponsesToolCallerSchema.nullish()
3916
3917
  }),
@@ -3985,7 +3986,8 @@ var openaiResponsesChunkSchema = lazySchema24(
3985
3986
  id: z25.string(),
3986
3987
  call_id: z25.string(),
3987
3988
  name: z25.string(),
3988
- input: z25.string()
3989
+ input: z25.string(),
3990
+ async: z25.boolean().nullish()
3989
3991
  }),
3990
3992
  z25.object({
3991
3993
  type: z25.literal("shell_call"),
@@ -4058,6 +4060,7 @@ var openaiResponsesChunkSchema = lazySchema24(
4058
4060
  call_id: z25.string(),
4059
4061
  name: z25.string(),
4060
4062
  arguments: z25.string(),
4063
+ async: z25.boolean().nullish(),
4061
4064
  status: z25.enum(["in_progress", "completed", "incomplete"]),
4062
4065
  namespace: z25.string().nullish(),
4063
4066
  caller: openaiResponsesToolCallerSchema.nullish()
@@ -4070,6 +4073,7 @@ var openaiResponsesChunkSchema = lazySchema24(
4070
4073
  call_id: z25.string(),
4071
4074
  name: z25.string(),
4072
4075
  input: z25.string(),
4076
+ async: z25.boolean().nullish(),
4073
4077
  status: z25.literal("completed")
4074
4078
  }),
4075
4079
  z25.object({
@@ -4507,6 +4511,7 @@ var openaiResponsesResponseSchema = lazySchema24(
4507
4511
  name: z25.string(),
4508
4512
  arguments: z25.string(),
4509
4513
  id: z25.string(),
4514
+ async: z25.boolean().nullish(),
4510
4515
  namespace: z25.string().nullish(),
4511
4516
  caller: openaiResponsesToolCallerSchema.nullish()
4512
4517
  }),
@@ -4517,7 +4522,8 @@ var openaiResponsesResponseSchema = lazySchema24(
4517
4522
  call_id: z25.string(),
4518
4523
  name: z25.string(),
4519
4524
  input: z25.string(),
4520
- id: z25.string()
4525
+ id: z25.string(),
4526
+ async: z25.boolean().nullish()
4521
4527
  }),
4522
4528
  openaiResponsesComputerCallSchema,
4523
4529
  z25.object({
@@ -4679,6 +4685,28 @@ import {
4679
4685
  WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE5
4680
4686
  } from "@ai-sdk/provider-utils";
4681
4687
 
4688
+ // src/openai-config.ts
4689
+ function prepareOpenAIConfigForWorkflowDeserialize(config) {
4690
+ if (config.provider == null) {
4691
+ throw new Error(
4692
+ "OpenAI model is missing provider after workflow deserialization."
4693
+ );
4694
+ }
4695
+ return {
4696
+ ...config,
4697
+ provider: config.provider,
4698
+ url: typeof config.url === "function" ? config.url : ({ path }) => {
4699
+ if (config.baseURL == null) {
4700
+ throw new Error(
4701
+ "OpenAI model is missing baseURL after workflow deserialization."
4702
+ );
4703
+ }
4704
+ return `${config.baseURL}${path}`;
4705
+ },
4706
+ headers: typeof config.headers === "function" ? config.headers : config.headers == null ? void 0 : () => config.headers
4707
+ };
4708
+ }
4709
+
4682
4710
  // src/responses/convert-to-openai-responses-input.ts
4683
4711
  import {
4684
4712
  UnsupportedFunctionalityError as UnsupportedFunctionalityError4
@@ -4983,7 +5011,7 @@ async function convertToOpenAIResponsesInput({
4983
5011
  customProviderToolNames,
4984
5012
  outputSchemaToolNames
4985
5013
  }) {
4986
- 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;
5014
+ 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;
4987
5015
  let input = [];
4988
5016
  const warnings = [];
4989
5017
  const processedApprovalIds = /* @__PURE__ */ new Set();
@@ -5203,7 +5231,8 @@ async function convertToOpenAIResponsesInput({
5203
5231
  }
5204
5232
  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;
5205
5233
  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;
5206
- const caller = (_m = (_l = part.providerOptions) == null ? void 0 : _l[providerOptionsName]) == null ? void 0 : _m.caller;
5234
+ 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;
5235
+ const caller = (_r = (_q = part.providerOptions) == null ? void 0 : _q[providerOptionsName]) == null ? void 0 : _r.caller;
5207
5236
  if (hasConversation && id != null) {
5208
5237
  break;
5209
5238
  }
@@ -5227,7 +5256,7 @@ async function convertToOpenAIResponsesInput({
5227
5256
  type: "tool_search_call",
5228
5257
  id: id != null ? id : part.toolCallId,
5229
5258
  execution,
5230
- call_id: (_n = parsedInput.call_id) != null ? _n : null,
5259
+ call_id: (_s = parsedInput.call_id) != null ? _s : null,
5231
5260
  status: "completed",
5232
5261
  arguments: parsedInput.arguments
5233
5262
  });
@@ -5259,7 +5288,7 @@ async function convertToOpenAIResponsesInput({
5259
5288
  break;
5260
5289
  }
5261
5290
  }
5262
- 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);
5291
+ 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);
5263
5292
  if (hasPreviousResponseId && store && id != null && isProviderDefinedToolCall) {
5264
5293
  break;
5265
5294
  }
@@ -5372,6 +5401,7 @@ async function convertToOpenAIResponsesInput({
5372
5401
  call_id: part.toolCallId,
5373
5402
  name: resolvedToolName,
5374
5403
  input: typeof part.input === "string" ? part.input : JSON.stringify(part.input),
5404
+ ...isAsync != null && { async: isAsync },
5375
5405
  id
5376
5406
  });
5377
5407
  break;
@@ -5381,6 +5411,7 @@ async function convertToOpenAIResponsesInput({
5381
5411
  call_id: part.toolCallId,
5382
5412
  name: resolvedToolName,
5383
5413
  arguments: serializeToolCallArguments2(part.input),
5414
+ ...isAsync != null && { async: isAsync },
5384
5415
  ...namespace != null && { namespace },
5385
5416
  ...caller != null && {
5386
5417
  caller: mapToolCaller(caller)
@@ -5400,7 +5431,7 @@ async function convertToOpenAIResponsesInput({
5400
5431
  part.toolName
5401
5432
  );
5402
5433
  if (part.toolName === toolSearchToolName) {
5403
- 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;
5434
+ 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;
5404
5435
  if (store) {
5405
5436
  input.push({ type: "item_reference", id: itemId });
5406
5437
  } else if (part.output.type === "json") {
@@ -5420,7 +5451,7 @@ async function convertToOpenAIResponsesInput({
5420
5451
  break;
5421
5452
  }
5422
5453
  if (resolvedResultToolName === "programmatic_tool_calling") {
5423
- 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;
5454
+ 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;
5424
5455
  if (store) {
5425
5456
  input.push({ type: "item_reference", id: itemId });
5426
5457
  } else if (part.output.type === "json") {
@@ -5460,7 +5491,7 @@ async function convertToOpenAIResponsesInput({
5460
5491
  break;
5461
5492
  }
5462
5493
  if (store) {
5463
- const itemId = (_D = (_C = (_B = part.providerOptions) == null ? void 0 : _B[providerOptionsName]) == null ? void 0 : _C.itemId) != null ? _D : part.toolCallId;
5494
+ const itemId = (_I = (_H = (_G = part.providerOptions) == null ? void 0 : _G[providerOptionsName]) == null ? void 0 : _H.itemId) != null ? _I : part.toolCallId;
5464
5495
  input.push({ type: "item_reference", id: itemId });
5465
5496
  } else {
5466
5497
  warnings.push({
@@ -5545,7 +5576,7 @@ async function convertToOpenAIResponsesInput({
5545
5576
  }
5546
5577
  case "custom": {
5547
5578
  if (part.kind === "openai.compaction") {
5548
- const providerOptions2 = (_E = part.providerOptions) == null ? void 0 : _E[providerOptionsName];
5579
+ const providerOptions2 = (_J = part.providerOptions) == null ? void 0 : _J[providerOptionsName];
5549
5580
  const id = providerOptions2 == null ? void 0 : providerOptions2.itemId;
5550
5581
  if (hasConversation && id != null) {
5551
5582
  break;
@@ -5651,7 +5682,7 @@ ${text}`,
5651
5682
  }
5652
5683
  const output = part.output;
5653
5684
  if (output.type === "execution-denied") {
5654
- const approvalId = (_G = (_F = output.providerOptions) == null ? void 0 : _F.openai) == null ? void 0 : _G.approvalId;
5685
+ const approvalId = (_L = (_K = output.providerOptions) == null ? void 0 : _K.openai) == null ? void 0 : _L.approvalId;
5655
5686
  if (approvalId) {
5656
5687
  continue;
5657
5688
  }
@@ -5731,7 +5762,7 @@ ${text}`,
5731
5762
  file_id: parsedOutput.output.fileId,
5732
5763
  detail: parsedOutput.output.detail
5733
5764
  },
5734
- acknowledged_safety_checks: (_H = parsedOutput.acknowledgedSafetyChecks) == null ? void 0 : _H.map((safetyCheck) => ({
5765
+ acknowledged_safety_checks: (_M = parsedOutput.acknowledgedSafetyChecks) == null ? void 0 : _M.map((safetyCheck) => ({
5735
5766
  id: safetyCheck.id,
5736
5767
  code: safetyCheck.code,
5737
5768
  message: safetyCheck.message
@@ -5760,7 +5791,7 @@ ${text}`,
5760
5791
  break;
5761
5792
  case "execution-denied":
5762
5793
  outputValue = convertScalarOutput(
5763
- (_I = output.reason) != null ? _I : "Tool call execution denied."
5794
+ (_N = output.reason) != null ? _N : "Tool call execution denied."
5764
5795
  );
5765
5796
  break;
5766
5797
  case "json":
@@ -5866,7 +5897,7 @@ ${text}`,
5866
5897
  warnings
5867
5898
  });
5868
5899
  const caller = mapToolCaller(
5869
- (_K = (_J = part.providerOptions) == null ? void 0 : _J[providerOptionsName]) == null ? void 0 : _K.caller
5900
+ (_P = (_O = part.providerOptions) == null ? void 0 : _O[providerOptionsName]) == null ? void 0 : _P.caller
5870
5901
  );
5871
5902
  input.push({
5872
5903
  type: "function_call_output",
@@ -6073,6 +6104,15 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema25(
6073
6104
  * Supported values vary by model.
6074
6105
  */
6075
6106
  reasoningEffort: z27.string().nullish(),
6107
+ /**
6108
+ * Updates the reasoning effort for GPT-6 and later models starting with this response
6109
+ * without changing the request-level reasoning effort. This preserves the
6110
+ * request prefix for prompt caching.
6111
+ *
6112
+ * Only supported by GPT-6 and later models in standard, single-agent mode. Cannot be
6113
+ * combined with automatic compaction or automatic truncation.
6114
+ */
6115
+ reasoningEffortUpdate: z27.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
6076
6116
  /**
6077
6117
  * Controls how much model work GPT-5.6 performs before returning a final answer.
6078
6118
  * `standard` is the default. `pro` increases quality, latency, and token usage.
@@ -6204,7 +6244,8 @@ async function prepareResponsesTools({
6204
6244
  allowedTools,
6205
6245
  toolNameMapping,
6206
6246
  customProviderToolNames,
6207
- outputSchemaToolNames
6247
+ outputSchemaToolNames,
6248
+ supportsAsyncToolCalling = true
6208
6249
  }) {
6209
6250
  var _a2, _b, _c, _d;
6210
6251
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
@@ -6238,7 +6279,13 @@ async function prepareResponsesTools({
6238
6279
  }
6239
6280
  const openaiFunctionTool = prepareFunctionTool({
6240
6281
  tool,
6241
- options: openaiOptions
6282
+ options: openaiOptions,
6283
+ async: resolveAsyncToolOption({
6284
+ value: openaiOptions == null ? void 0 : openaiOptions.async,
6285
+ supportsAsyncToolCalling,
6286
+ toolName: tool.name,
6287
+ toolWarnings
6288
+ })
6242
6289
  });
6243
6290
  const namespace = openaiOptions == null ? void 0 : openaiOptions.namespace;
6244
6291
  if (namespace == null) {
@@ -6427,6 +6474,12 @@ async function prepareResponsesTools({
6427
6474
  type: "custom",
6428
6475
  name: tool.name,
6429
6476
  description: args.description,
6477
+ ...resolveAsyncToolOption({
6478
+ value: args.async,
6479
+ supportsAsyncToolCalling,
6480
+ toolName: tool.name,
6481
+ toolWarnings
6482
+ }) != null ? { async: args.async } : {},
6430
6483
  format: args.format
6431
6484
  });
6432
6485
  resolvedCustomProviderToolNames.add(tool.name);
@@ -6606,7 +6659,8 @@ function toAllowedToolResolution(tool) {
6606
6659
  }
6607
6660
  function prepareFunctionTool({
6608
6661
  tool,
6609
- options
6662
+ options,
6663
+ async
6610
6664
  }) {
6611
6665
  const deferLoading = options == null ? void 0 : options.deferLoading;
6612
6666
  return {
@@ -6614,12 +6668,29 @@ function prepareFunctionTool({
6614
6668
  name: tool.name,
6615
6669
  description: tool.description,
6616
6670
  parameters: tool.inputSchema,
6671
+ ...async != null ? { async } : {},
6617
6672
  ...tool.strict != null ? { strict: tool.strict } : {},
6618
6673
  ...deferLoading != null ? { defer_loading: deferLoading } : {},
6619
6674
  ...(options == null ? void 0 : options.allowedCallers) != null ? { allowed_callers: options.allowedCallers } : {},
6620
6675
  ...(options == null ? void 0 : options.outputSchema) != null ? { output_schema: options.outputSchema } : {}
6621
6676
  };
6622
6677
  }
6678
+ function resolveAsyncToolOption({
6679
+ value,
6680
+ supportsAsyncToolCalling,
6681
+ toolName,
6682
+ toolWarnings
6683
+ }) {
6684
+ if (value !== true || supportsAsyncToolCalling) {
6685
+ return value;
6686
+ }
6687
+ toolWarnings.push({
6688
+ type: "unsupported",
6689
+ feature: `async tool calling for "${toolName}"`,
6690
+ details: "Async tool calling is only supported by GPT-6 and later models."
6691
+ });
6692
+ return void 0;
6693
+ }
6623
6694
  function mapShellEnvironment(environment) {
6624
6695
  if (environment.type === "containerReference") {
6625
6696
  const env2 = environment;
@@ -6757,13 +6828,14 @@ function mapComputerCallInput({
6757
6828
  status
6758
6829
  };
6759
6830
  }
6831
+ var openaiResponsesSupportedUrls = {
6832
+ "image/*": [/^https?:\/\/.*$/],
6833
+ "application/pdf": [/^https?:\/\/.*$/]
6834
+ };
6760
6835
  var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6761
6836
  constructor(modelId, config) {
6762
6837
  this.specificationVersion = "v4";
6763
- this.supportedUrls = {
6764
- "image/*": [/^https?:\/\/.*$/],
6765
- "application/pdf": [/^https?:\/\/.*$/]
6766
- };
6838
+ this.supportedUrls = openaiResponsesSupportedUrls;
6767
6839
  this.modelId = modelId;
6768
6840
  this.config = config;
6769
6841
  }
@@ -6782,25 +6854,29 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6782
6854
  get provider() {
6783
6855
  return this.config.provider;
6784
6856
  }
6785
- async getArgs({
6786
- maxOutputTokens,
6787
- temperature,
6788
- stopSequences,
6789
- topP,
6790
- topK,
6791
- presencePenalty,
6792
- frequencyPenalty,
6793
- seed,
6794
- prompt,
6795
- reasoning,
6796
- providerOptions,
6797
- tools,
6798
- toolChoice,
6799
- responseFormat
6857
+ static async prepareRequest({
6858
+ modelId,
6859
+ config,
6860
+ options: {
6861
+ maxOutputTokens,
6862
+ temperature,
6863
+ stopSequences,
6864
+ topP,
6865
+ topK,
6866
+ presencePenalty,
6867
+ frequencyPenalty,
6868
+ seed,
6869
+ prompt,
6870
+ reasoning,
6871
+ providerOptions,
6872
+ tools,
6873
+ toolChoice,
6874
+ responseFormat
6875
+ }
6800
6876
  }) {
6801
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
6877
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
6802
6878
  const warnings = [];
6803
- const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
6879
+ const modelCapabilities = getOpenAILanguageModelCapabilities(modelId);
6804
6880
  if (topK != null) {
6805
6881
  warnings.push({ type: "unsupported", feature: "topK" });
6806
6882
  }
@@ -6816,7 +6892,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6816
6892
  if (stopSequences != null) {
6817
6893
  warnings.push({ type: "unsupported", feature: "stopSequences" });
6818
6894
  }
6819
- const providerOptionsName = this.config.provider.includes("azure") ? "azure" : "openai";
6895
+ const providerOptionsName = config.provider.includes("azure") ? "azure" : "openai";
6820
6896
  let openaiOptions = await parseProviderOptions7({
6821
6897
  provider: providerOptionsName,
6822
6898
  providerOptions,
@@ -6829,7 +6905,17 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6829
6905
  schema: openaiLanguageModelResponsesOptionsSchema
6830
6906
  });
6831
6907
  }
6832
- const resolvedReasoningEffort = (_a2 = openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null ? _a2 : isCustomReasoning2(reasoning) ? reasoning : void 0;
6908
+ let resolvedReasoningEffort = (_a2 = openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null ? _a2 : isCustomReasoning2(reasoning) ? reasoning : void 0;
6909
+ if (resolvedReasoningEffort != null && modelCapabilities.supportedReasoningEfforts != null && !modelCapabilities.supportedReasoningEfforts.includes(
6910
+ resolvedReasoningEffort
6911
+ )) {
6912
+ warnings.push({
6913
+ type: "unsupported",
6914
+ feature: "reasoningEffort",
6915
+ details: `${modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
6916
+ });
6917
+ resolvedReasoningEffort = void 0;
6918
+ }
6833
6919
  const resolvedReasoningSummary = (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) !== void 0 ? openaiOptions.reasoningSummary : resolvedReasoningEffort != null && resolvedReasoningEffort !== "none" ? "detailed" : void 0;
6834
6920
  const isReasoningModel = (_b = openaiOptions == null ? void 0 : openaiOptions.forceReasoning) != null ? _b : modelCapabilities.isReasoningModel;
6835
6921
  if ((openaiOptions == null ? void 0 : openaiOptions.conversation) && (openaiOptions == null ? void 0 : openaiOptions.previousResponseId)) {
@@ -6868,14 +6954,15 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6868
6954
  allowedTools: (_c = openaiOptions == null ? void 0 : openaiOptions.allowedTools) != null ? _c : void 0,
6869
6955
  toolNameMapping,
6870
6956
  customProviderToolNames,
6871
- outputSchemaToolNames
6957
+ outputSchemaToolNames,
6958
+ supportsAsyncToolCalling: modelCapabilities.supportsAsyncToolCalling
6872
6959
  });
6873
6960
  const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
6874
6961
  prompt,
6875
6962
  toolNameMapping,
6876
6963
  systemMessageMode: (_d = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _d : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
6877
6964
  providerOptionsName,
6878
- fileIdPrefixes: this.config.fileIdPrefixes,
6965
+ fileIdPrefixes: config.fileIdPrefixes,
6879
6966
  passThroughUnsupportedFiles: (_e = openaiOptions == null ? void 0 : openaiOptions.passThroughUnsupportedFiles) != null ? _e : false,
6880
6967
  store: (_f = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _f : true,
6881
6968
  hasConversation: (openaiOptions == null ? void 0 : openaiOptions.conversation) != null,
@@ -6889,6 +6976,20 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6889
6976
  outputSchemaToolNames: outputSchemaToolNames.size > 0 ? outputSchemaToolNames : void 0
6890
6977
  });
6891
6978
  warnings.push(...inputWarnings);
6979
+ const reasoningEffortUpdate = openaiOptions == null ? void 0 : openaiOptions.reasoningEffortUpdate;
6980
+ const configurationUpdateIsSupported = reasoningEffortUpdate == null || modelCapabilities.supportsConfigurationUpdate && (openaiOptions == null ? void 0 : openaiOptions.reasoningMode) !== "pro" && (openaiOptions == null ? void 0 : openaiOptions.contextManagement) == null && (openaiOptions == null ? void 0 : openaiOptions.truncation) !== "auto";
6981
+ if (reasoningEffortUpdate != null && !configurationUpdateIsSupported) {
6982
+ warnings.push({
6983
+ type: "unsupported",
6984
+ feature: "reasoningEffortUpdate",
6985
+ details: !modelCapabilities.supportsConfigurationUpdate ? "reasoningEffortUpdate is only supported by GPT-6 and later models" : "reasoningEffortUpdate requires standard reasoning mode without automatic compaction or automatic truncation"
6986
+ });
6987
+ } else if (reasoningEffortUpdate != null) {
6988
+ input.unshift({
6989
+ type: "configuration_update",
6990
+ reasoning: { effort: reasoningEffortUpdate }
6991
+ });
6992
+ }
6892
6993
  if (openaiOptions == null ? void 0 : openaiOptions.compactionTrigger) {
6893
6994
  input.push({ type: "compaction_trigger" });
6894
6995
  }
@@ -6926,7 +7027,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6926
7027
  addInclude("reasoning.encrypted_content");
6927
7028
  }
6928
7029
  const baseArgs = {
6929
- model: this.modelId,
7030
+ model: modelId,
6930
7031
  input,
6931
7032
  temperature,
6932
7033
  top_p: topP,
@@ -6989,6 +7090,14 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6989
7090
  }
6990
7091
  }
6991
7092
  };
7093
+ if (modelCapabilities.supportsConfigurationUpdate && baseArgs.prompt_cache_retention != null) {
7094
+ baseArgs.prompt_cache_retention = void 0;
7095
+ warnings.push({
7096
+ type: "unsupported",
7097
+ feature: "promptCacheRetention",
7098
+ details: "promptCacheRetention is not supported by GPT-6 and later models; use promptCacheOptions instead"
7099
+ });
7100
+ }
6992
7101
  if (isReasoningModel) {
6993
7102
  if (!(resolvedReasoningEffort === "none" && modelCapabilities.supportsNonReasoningParameters)) {
6994
7103
  if (baseArgs.temperature != null) {
@@ -7007,6 +7116,18 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7007
7116
  details: "topP is not supported for reasoning models"
7008
7117
  });
7009
7118
  }
7119
+ if (modelCapabilities.supportedReasoningEfforts != null && (baseArgs.top_logprobs != null || ((_j = baseArgs.include) == null ? void 0 : _j.includes("message.output_text.logprobs")))) {
7120
+ baseArgs.top_logprobs = void 0;
7121
+ const filteredInclude = (_k = baseArgs.include) == null ? void 0 : _k.filter(
7122
+ (value) => value !== "message.output_text.logprobs"
7123
+ );
7124
+ baseArgs.include = filteredInclude != null && filteredInclude.length > 0 ? filteredInclude : void 0;
7125
+ warnings.push({
7126
+ type: "unsupported",
7127
+ feature: "logprobs",
7128
+ details: "logprobs is not supported for reasoning models"
7129
+ });
7130
+ }
7010
7131
  }
7011
7132
  } else {
7012
7133
  if ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null) {
@@ -7054,9 +7175,9 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7054
7175
  });
7055
7176
  delete baseArgs.service_tier;
7056
7177
  }
7057
- const shellToolEnvType = (_l = (_k = (_j = tools == null ? void 0 : tools.find(
7178
+ const shellToolEnvType = (_n = (_m = (_l = tools == null ? void 0 : tools.find(
7058
7179
  (tool) => tool.type === "provider" && tool.id === "openai.shell"
7059
- )) == null ? void 0 : _j.args) == null ? void 0 : _k.environment) == null ? void 0 : _l.type;
7180
+ )) == null ? void 0 : _l.args) == null ? void 0 : _m.environment) == null ? void 0 : _n.type;
7060
7181
  const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
7061
7182
  return {
7062
7183
  webSearchToolName,
@@ -7072,6 +7193,13 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7072
7193
  isShellProviderExecuted
7073
7194
  };
7074
7195
  }
7196
+ getArgs(options) {
7197
+ return _OpenAIResponsesLanguageModel.prepareRequest({
7198
+ modelId: this.modelId,
7199
+ config: this.config,
7200
+ options
7201
+ });
7202
+ }
7075
7203
  async doGenerate(options) {
7076
7204
  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;
7077
7205
  const {
@@ -7368,6 +7496,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7368
7496
  providerMetadata: {
7369
7497
  [providerOptionsName]: {
7370
7498
  itemId: part.id,
7499
+ ...part.async != null && { async: part.async },
7371
7500
  ...part.namespace != null && { namespace: part.namespace },
7372
7501
  ...part.caller != null && {
7373
7502
  caller: part.caller.type === "program" ? {
@@ -7429,7 +7558,8 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7429
7558
  input: JSON.stringify(part.input),
7430
7559
  providerMetadata: {
7431
7560
  [providerOptionsName]: {
7432
- itemId: part.id
7561
+ itemId: part.id,
7562
+ ...part.async != null && { async: part.async }
7433
7563
  }
7434
7564
  }
7435
7565
  });
@@ -7756,7 +7886,8 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7756
7886
  toolName: value.item.name,
7757
7887
  toolCallId: value.item.call_id,
7758
7888
  suppressInputStreaming,
7759
- bufferedInputDeltas: suppressInputStreaming ? [] : void 0
7889
+ bufferedInputDeltas: suppressInputStreaming ? [] : void 0,
7890
+ async: value.item.async
7760
7891
  };
7761
7892
  if (!suppressInputStreaming) {
7762
7893
  controller.enqueue({
@@ -7771,7 +7902,8 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7771
7902
  );
7772
7903
  ongoingToolCalls[value.output_index] = {
7773
7904
  toolName,
7774
- toolCallId: value.item.call_id
7905
+ toolCallId: value.item.call_id,
7906
+ async: value.item.async
7775
7907
  };
7776
7908
  controller.enqueue({
7777
7909
  type: "tool-input-start",
@@ -8022,6 +8154,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
8022
8154
  providerMetadata: {
8023
8155
  [providerOptionsName]: {
8024
8156
  itemId: item.id,
8157
+ ...item.async != null ? { async: item.async } : (ongoingToolCall == null ? void 0 : ongoingToolCall.async) != null ? { async: ongoingToolCall.async } : {},
8025
8158
  ...item.namespace != null && {
8026
8159
  namespace: item.namespace
8027
8160
  },
@@ -8107,6 +8240,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
8107
8240
  }
8108
8241
  });
8109
8242
  } else if (value.item.type === "custom_tool_call") {
8243
+ const ongoingToolCall = ongoingToolCalls[value.output_index];
8110
8244
  ongoingToolCalls[value.output_index] = void 0;
8111
8245
  hasFunctionCall = true;
8112
8246
  const toolName = toolNameMapping.toCustomToolName(
@@ -8123,7 +8257,8 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
8123
8257
  input: JSON.stringify(value.item.input),
8124
8258
  providerMetadata: {
8125
8259
  [providerOptionsName]: {
8126
- itemId: value.item.id
8260
+ itemId: value.item.id,
8261
+ ...value.item.async != null ? { async: value.item.async } : (ongoingToolCall == null ? void 0 : ongoingToolCall.async) != null ? { async: ongoingToolCall.async } : {}
8127
8262
  }
8128
8263
  }
8129
8264
  });
@@ -8917,7 +9052,7 @@ function escapeJSONDelta(delta) {
8917
9052
  return JSON.stringify(delta).slice(1, -1);
8918
9053
  }
8919
9054
 
8920
- // src/openai-responses-batch.ts
9055
+ // src/openai-batch.ts
8921
9056
  var openaiBatchEndpoint = "/v1/responses";
8922
9057
  var openaiBatchInputFileDefaultExpiresAfterSeconds = 48 * 60 * 60;
8923
9058
  var openaiBatchProviderOptionsSchema = lazySchema26(
@@ -8973,12 +9108,16 @@ var openaiBatchResultLineSchema = lazySchema26(
8973
9108
  })
8974
9109
  )
8975
9110
  );
8976
- var OpenAIResponsesBatch = class {
9111
+ var OpenAIBatch = class {
8977
9112
  constructor(options) {
8978
9113
  this.options = options;
9114
+ this.specificationVersion = "v4";
9115
+ this.supportedUrls = openaiResponsesSupportedUrls;
9116
+ this.provider = options.provider;
8979
9117
  }
8980
- async startBatch(options) {
9118
+ async doStartBatch(options) {
8981
9119
  var _a2, _b, _c, _d, _e, _f;
9120
+ validateSingleModel(options.requests);
8982
9121
  const fileParts = [];
8983
9122
  const warnings = options.webhookUrl == null ? [] : [
8984
9123
  {
@@ -8994,7 +9133,7 @@ var OpenAIResponsesBatch = class {
8994
9133
  );
8995
9134
  const inputFileExpiresAfterSeconds = (_a2 = batchOptions == null ? void 0 : batchOptions.inputFileExpiresAfter) != null ? _a2 : openaiBatchInputFileDefaultExpiresAfterSeconds;
8996
9135
  for (const request of options.requests) {
8997
- const preparedRequest = await this.options.prepareRequest(request);
9136
+ const preparedRequest = await this.prepareRequest(request);
8998
9137
  fileParts.push(
8999
9138
  JSON.stringify({
9000
9139
  custom_id: request.id,
@@ -9100,11 +9239,11 @@ var OpenAIResponsesBatch = class {
9100
9239
  }
9101
9240
  return batchOptions;
9102
9241
  }
9103
- async getBatchStatus(options) {
9242
+ async doGetBatchStatus(options) {
9104
9243
  const batch = await this.retrieveBatch(options);
9105
9244
  return convertOpenAIBatchStatus(batch);
9106
9245
  }
9107
- async getBatchResults(options) {
9246
+ async doGetBatchResults(options) {
9108
9247
  const batch = await this.retrieveBatch(options);
9109
9248
  const batchStatus = convertOpenAIBatchStatus(batch);
9110
9249
  if (batchStatus.status === "pending") {
@@ -9172,15 +9311,16 @@ var OpenAIResponsesBatch = class {
9172
9311
  code: line.error.code
9173
9312
  };
9174
9313
  if (line.error.code === "batch_cancelled") {
9175
- return { id: line.custom_id, status: "cancelled", error };
9314
+ return { type: "text", id: line.custom_id, status: "cancelled", error };
9176
9315
  }
9177
9316
  if (line.error.code === "batch_expired") {
9178
- return { id: line.custom_id, status: "expired", error };
9317
+ return { type: "text", id: line.custom_id, status: "expired", error };
9179
9318
  }
9180
- return { id: line.custom_id, status: "failed", error };
9319
+ return { type: "text", id: line.custom_id, status: "failed", error };
9181
9320
  }
9182
9321
  if (line.response == null) {
9183
9322
  return {
9323
+ type: "text",
9184
9324
  id: line.custom_id,
9185
9325
  status: "failed",
9186
9326
  error: {
@@ -9191,6 +9331,7 @@ var OpenAIResponsesBatch = class {
9191
9331
  }
9192
9332
  if (line.response.status_code < 200 || line.response.status_code >= 300) {
9193
9333
  return {
9334
+ type: "text",
9194
9335
  id: line.custom_id,
9195
9336
  status: "failed",
9196
9337
  error: await convertOpenAIErrorResponse({
@@ -9199,29 +9340,46 @@ var OpenAIResponsesBatch = class {
9199
9340
  })
9200
9341
  };
9201
9342
  }
9202
- const conversion = await convertOpenAIResponsesBatchResponse(
9203
- line.response.body
9204
- );
9343
+ const conversion = await convertOpenAIBatchResult(line.response.body);
9205
9344
  if (!conversion.success) {
9206
9345
  return {
9346
+ type: "text",
9207
9347
  id: line.custom_id,
9208
9348
  status: "failed",
9209
9349
  error: conversion.error
9210
9350
  };
9211
9351
  }
9212
9352
  return {
9353
+ type: "text",
9213
9354
  id: line.custom_id,
9214
9355
  status: "succeeded",
9215
9356
  result: conversion.result
9216
9357
  };
9217
9358
  }
9218
- getUrl(path) {
9219
- return this.options.config.url({
9220
- modelId: this.options.modelId,
9221
- path
9359
+ async prepareRequest(request) {
9360
+ const { args: body, warnings } = await OpenAIResponsesLanguageModel.prepareRequest({
9361
+ modelId: request.modelId,
9362
+ config: this.options.config,
9363
+ options: request.options
9222
9364
  });
9365
+ return { body, warnings };
9366
+ }
9367
+ getUrl(path) {
9368
+ return this.options.config.url({ path, modelId: "" });
9223
9369
  }
9224
9370
  };
9371
+ function validateSingleModel(requests) {
9372
+ var _a2;
9373
+ const modelId = (_a2 = requests[0]) == null ? void 0 : _a2.modelId;
9374
+ for (const request of requests) {
9375
+ if (request.modelId !== modelId) {
9376
+ throw new InvalidArgumentError2({
9377
+ argument: "requests",
9378
+ message: `The OpenAI Batch API requires all requests in a batch to use the same model. Found "${modelId}" and "${request.modelId}".`
9379
+ });
9380
+ }
9381
+ }
9382
+ }
9225
9383
  var openAIBatchConvertibleProviderToolIds = /* @__PURE__ */ new Set([
9226
9384
  "openai.code_interpreter",
9227
9385
  "openai.custom",
@@ -9229,37 +9387,6 @@ var openAIBatchConvertibleProviderToolIds = /* @__PURE__ */ new Set([
9229
9387
  "openai.web_search",
9230
9388
  "openai.web_search_preview"
9231
9389
  ]);
9232
- var OpenAIResponsesBatchLanguageModel = class _OpenAIResponsesBatchLanguageModel extends OpenAIResponsesLanguageModel {
9233
- static [WORKFLOW_SERIALIZE6](model) {
9234
- return OpenAIResponsesLanguageModel[WORKFLOW_SERIALIZE6](model);
9235
- }
9236
- static [WORKFLOW_DESERIALIZE6](options) {
9237
- return new _OpenAIResponsesBatchLanguageModel(
9238
- options.modelId,
9239
- prepareOpenAIConfigForWorkflowDeserialize(options.config)
9240
- );
9241
- }
9242
- constructor(modelId, config) {
9243
- super(modelId, config);
9244
- this.batch = new OpenAIResponsesBatch({
9245
- modelId,
9246
- config,
9247
- prepareRequest: async (request) => {
9248
- const { args: body, warnings } = await this.getArgs(request.options);
9249
- return { body, warnings };
9250
- }
9251
- });
9252
- }
9253
- experimental_doStartBatch(options) {
9254
- return this.batch.startBatch(options);
9255
- }
9256
- experimental_doGetBatchStatus(options) {
9257
- return this.batch.getBatchStatus(options);
9258
- }
9259
- experimental_doGetBatchResults(options) {
9260
- return this.batch.getBatchResults(options);
9261
- }
9262
- };
9263
9390
  function convertOpenAIBatchStatus(batch) {
9264
9391
  var _a2, _b, _c;
9265
9392
  const status = mapOpenAIBatchStatus(batch.status);
@@ -9337,7 +9464,7 @@ async function convertOpenAIErrorResponse({
9337
9464
  statusCode
9338
9465
  };
9339
9466
  }
9340
- async function convertOpenAIResponsesBatchResponse(body) {
9467
+ async function convertOpenAIBatchResult(body) {
9341
9468
  var _a2, _b, _c, _d, _e, _f, _g, _h;
9342
9469
  const validation = await safeValidateTypes({
9343
9470
  value: body,
@@ -9931,8 +10058,8 @@ import {
9931
10058
  parseProviderOptions as parseProviderOptions9,
9932
10059
  postJsonToApi as postJsonToApi7,
9933
10060
  serializeModelOptions as serializeModelOptions6,
9934
- WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE7,
9935
- WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE7
10061
+ WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE6,
10062
+ WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE6
9936
10063
  } from "@ai-sdk/provider-utils";
9937
10064
 
9938
10065
  // src/speech/openai-speech-model-options.ts
@@ -9957,13 +10084,13 @@ var OpenAISpeechModel = class _OpenAISpeechModel {
9957
10084
  this.config = config;
9958
10085
  this.specificationVersion = "v4";
9959
10086
  }
9960
- static [WORKFLOW_SERIALIZE7](model) {
10087
+ static [WORKFLOW_SERIALIZE6](model) {
9961
10088
  return serializeModelOptions6({
9962
10089
  modelId: model.modelId,
9963
10090
  config: model.config
9964
10091
  });
9965
10092
  }
9966
- static [WORKFLOW_DESERIALIZE7](options) {
10093
+ static [WORKFLOW_DESERIALIZE6](options) {
9967
10094
  return new _OpenAISpeechModel(options.modelId, options.config);
9968
10095
  }
9969
10096
  get provider() {
@@ -10076,8 +10203,8 @@ import {
10076
10203
  safeParseJSON as safeParseJSON2,
10077
10204
  serializeModelOptions as serializeModelOptions7,
10078
10205
  toWebSocketUrl,
10079
- WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE8,
10080
- WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE8,
10206
+ WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE7,
10207
+ WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE7,
10081
10208
  waitForWebSocketBufferDrain
10082
10209
  } from "@ai-sdk/provider-utils";
10083
10210
 
@@ -10258,13 +10385,13 @@ var OpenAITranscriptionModel = class _OpenAITranscriptionModel {
10258
10385
  this.config = config;
10259
10386
  this.specificationVersion = "v4";
10260
10387
  }
10261
- static [WORKFLOW_SERIALIZE8](model) {
10388
+ static [WORKFLOW_SERIALIZE7](model) {
10262
10389
  return serializeModelOptions7({
10263
10390
  modelId: model.modelId,
10264
10391
  config: model.config
10265
10392
  });
10266
10393
  }
10267
- static [WORKFLOW_DESERIALIZE8](options) {
10394
+ static [WORKFLOW_DESERIALIZE7](options) {
10268
10395
  return new _OpenAITranscriptionModel(options.modelId, options.config);
10269
10396
  }
10270
10397
  get provider() {
@@ -10670,8 +10797,8 @@ import {
10670
10797
  safeParseJSON as safeParseJSON3,
10671
10798
  serializeModelOptions as serializeModelOptions8,
10672
10799
  toWebSocketUrl as toWebSocketUrl2,
10673
- WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE9,
10674
- WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE9,
10800
+ WORKFLOW_DESERIALIZE as WORKFLOW_DESERIALIZE8,
10801
+ WORKFLOW_SERIALIZE as WORKFLOW_SERIALIZE8,
10675
10802
  waitForWebSocketBufferDrain as waitForWebSocketBufferDrain2
10676
10803
  } from "@ai-sdk/provider-utils";
10677
10804
 
@@ -10692,13 +10819,13 @@ var OpenAISpeechTranslationModel = class _OpenAISpeechTranslationModel {
10692
10819
  this.config = config;
10693
10820
  this.specificationVersion = "v4";
10694
10821
  }
10695
- static [WORKFLOW_SERIALIZE9](model) {
10822
+ static [WORKFLOW_SERIALIZE8](model) {
10696
10823
  return serializeModelOptions8({
10697
10824
  modelId: model.modelId,
10698
10825
  config: model.config
10699
10826
  });
10700
10827
  }
10701
- static [WORKFLOW_DESERIALIZE9](options) {
10828
+ static [WORKFLOW_DESERIALIZE8](options) {
10702
10829
  return new _OpenAISpeechTranslationModel(options.modelId, options.config);
10703
10830
  }
10704
10831
  get provider() {
@@ -11060,7 +11187,7 @@ var OpenAISkills = class {
11060
11187
  };
11061
11188
 
11062
11189
  // src/version.ts
11063
- var VERSION = true ? "4.0.59" : "0.0.0-test";
11190
+ var VERSION = true ? "4.0.61" : "0.0.0-test";
11064
11191
 
11065
11192
  // src/openai-provider.ts
11066
11193
  function createOpenAI(options = {}) {
@@ -11152,7 +11279,7 @@ function createOpenAI(options = {}) {
11152
11279
  return createResponsesModel(modelId);
11153
11280
  };
11154
11281
  const createResponsesModel = (modelId) => {
11155
- return new OpenAIResponsesBatchLanguageModel(modelId, {
11282
+ return new OpenAIResponsesLanguageModel(modelId, {
11156
11283
  provider: `${providerName}.responses`,
11157
11284
  baseURL,
11158
11285
  url: ({ path }) => `${baseURL}${path}`,
@@ -11162,6 +11289,18 @@ function createOpenAI(options = {}) {
11162
11289
  fileIdPrefixes: ["file-"]
11163
11290
  });
11164
11291
  };
11292
+ const createBatch = () => new OpenAIBatch({
11293
+ provider: `${providerName}.batch`,
11294
+ config: {
11295
+ provider: `${providerName}.responses`,
11296
+ baseURL,
11297
+ url: ({ path }) => `${baseURL}${path}`,
11298
+ headers: getHeaders,
11299
+ fetch: options.fetch,
11300
+ // Soft-deprecated. TODO: remove in v8
11301
+ fileIdPrefixes: ["file-"]
11302
+ }
11303
+ });
11165
11304
  const createRealtimeModel = (modelId) => new OpenAIRealtimeModel(modelId, {
11166
11305
  provider: `${providerName}.realtime`,
11167
11306
  baseURL,
@@ -11207,6 +11346,7 @@ function createOpenAI(options = {}) {
11207
11346
  provider.speechModel = createSpeechModel;
11208
11347
  provider.files = createFiles;
11209
11348
  provider.skills = createSkills;
11349
+ provider.experimental_batch = createBatch;
11210
11350
  provider.experimental_realtime = experimentalRealtimeFactory;
11211
11351
  provider.tools = openaiTools;
11212
11352
  return provider;