@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.
@@ -39,14 +39,18 @@ function getOpenAILanguageModelCapabilities(modelId) {
39
39
  const gptVersion = getGptVersion(modelId);
40
40
  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);
41
41
  const isGptNanoModel = (_d = (_c = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _c.startsWith("nano")) != null ? _d : false;
42
+ const isGpt6OrLaterModel = gptVersion != null && gptVersion.major >= 6;
42
43
  const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
43
44
  const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
44
45
  const isReasoningModel = oSeriesVersion != null || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
45
- const supportsNonReasoningParameters = gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
46
+ const supportsNonReasoningParameters = !isGpt6OrLaterModel && gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
46
47
  const systemMessageMode = isReasoningModel ? "developer" : "system";
47
48
  return {
48
49
  supportsFlexProcessing,
49
50
  supportsPriorityProcessing,
51
+ supportsConfigurationUpdate: isGpt6OrLaterModel,
52
+ supportsAsyncToolCalling: isGpt6OrLaterModel,
53
+ supportedReasoningEfforts: isGpt6OrLaterModel ? ["low", "medium", "high", "xhigh", "max"] : void 0,
50
54
  isReasoningModel,
51
55
  systemMessageMode,
52
56
  supportsNonReasoningParameters
@@ -1011,7 +1015,17 @@ var OpenAIChatLanguageModel = class _OpenAIChatLanguageModel {
1011
1015
  schema: openaiLanguageModelChatOptions
1012
1016
  })) != null ? _a2 : {};
1013
1017
  const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
1014
- const resolvedReasoningEffort = (_b = openaiOptions.reasoningEffort) != null ? _b : isCustomReasoning(reasoning) ? reasoning : void 0;
1018
+ let resolvedReasoningEffort = (_b = openaiOptions.reasoningEffort) != null ? _b : isCustomReasoning(reasoning) ? reasoning : void 0;
1019
+ if (resolvedReasoningEffort != null && modelCapabilities.supportedReasoningEfforts != null && !modelCapabilities.supportedReasoningEfforts.includes(
1020
+ resolvedReasoningEffort
1021
+ )) {
1022
+ warnings.push({
1023
+ type: "unsupported",
1024
+ feature: "reasoningEffort",
1025
+ details: `${this.modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
1026
+ });
1027
+ resolvedReasoningEffort = void 0;
1028
+ }
1015
1029
  const isReasoningModel = (_c = openaiOptions.forceReasoning) != null ? _c : modelCapabilities.isReasoningModel;
1016
1030
  if (topK != null) {
1017
1031
  warnings.push({ type: "unsupported", feature: "topK" });
@@ -1066,6 +1080,14 @@ var OpenAIChatLanguageModel = class _OpenAIChatLanguageModel {
1066
1080
  // messages:
1067
1081
  messages
1068
1082
  };
1083
+ if (modelCapabilities.supportedReasoningEfforts != null && baseArgs.prompt_cache_retention != null) {
1084
+ baseArgs.prompt_cache_retention = void 0;
1085
+ warnings.push({
1086
+ type: "unsupported",
1087
+ feature: "promptCacheRetention",
1088
+ details: "promptCacheRetention is not supported by GPT-6 and later models; use promptCacheOptions instead"
1089
+ });
1090
+ }
1069
1091
  if (isReasoningModel) {
1070
1092
  if (resolvedReasoningEffort !== "none" || !modelCapabilities.supportsNonReasoningParameters) {
1071
1093
  if (baseArgs.temperature != null) {
@@ -3852,7 +3874,7 @@ async function convertToOpenAIResponsesInput({
3852
3874
  customProviderToolNames,
3853
3875
  outputSchemaToolNames
3854
3876
  }) {
3855
- 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;
3877
+ 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;
3856
3878
  let input = [];
3857
3879
  const warnings = [];
3858
3880
  const processedApprovalIds = /* @__PURE__ */ new Set();
@@ -4072,7 +4094,8 @@ async function convertToOpenAIResponsesInput({
4072
4094
  }
4073
4095
  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;
4074
4096
  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;
4075
- const caller = (_m = (_l = part.providerOptions) == null ? void 0 : _l[providerOptionsName]) == null ? void 0 : _m.caller;
4097
+ 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;
4098
+ const caller = (_r = (_q = part.providerOptions) == null ? void 0 : _q[providerOptionsName]) == null ? void 0 : _r.caller;
4076
4099
  if (hasConversation && id != null) {
4077
4100
  break;
4078
4101
  }
@@ -4096,7 +4119,7 @@ async function convertToOpenAIResponsesInput({
4096
4119
  type: "tool_search_call",
4097
4120
  id: id != null ? id : part.toolCallId,
4098
4121
  execution,
4099
- call_id: (_n = parsedInput.call_id) != null ? _n : null,
4122
+ call_id: (_s = parsedInput.call_id) != null ? _s : null,
4100
4123
  status: "completed",
4101
4124
  arguments: parsedInput.arguments
4102
4125
  });
@@ -4128,7 +4151,7 @@ async function convertToOpenAIResponsesInput({
4128
4151
  break;
4129
4152
  }
4130
4153
  }
4131
- 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);
4154
+ 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);
4132
4155
  if (hasPreviousResponseId && store && id != null && isProviderDefinedToolCall) {
4133
4156
  break;
4134
4157
  }
@@ -4241,6 +4264,7 @@ async function convertToOpenAIResponsesInput({
4241
4264
  call_id: part.toolCallId,
4242
4265
  name: resolvedToolName,
4243
4266
  input: typeof part.input === "string" ? part.input : JSON.stringify(part.input),
4267
+ ...isAsync != null && { async: isAsync },
4244
4268
  id
4245
4269
  });
4246
4270
  break;
@@ -4250,6 +4274,7 @@ async function convertToOpenAIResponsesInput({
4250
4274
  call_id: part.toolCallId,
4251
4275
  name: resolvedToolName,
4252
4276
  arguments: serializeToolCallArguments2(part.input),
4277
+ ...isAsync != null && { async: isAsync },
4253
4278
  ...namespace != null && { namespace },
4254
4279
  ...caller != null && {
4255
4280
  caller: mapToolCaller(caller)
@@ -4269,7 +4294,7 @@ async function convertToOpenAIResponsesInput({
4269
4294
  part.toolName
4270
4295
  );
4271
4296
  if (part.toolName === toolSearchToolName) {
4272
- 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;
4297
+ 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;
4273
4298
  if (store) {
4274
4299
  input.push({ type: "item_reference", id: itemId });
4275
4300
  } else if (part.output.type === "json") {
@@ -4289,7 +4314,7 @@ async function convertToOpenAIResponsesInput({
4289
4314
  break;
4290
4315
  }
4291
4316
  if (resolvedResultToolName === "programmatic_tool_calling") {
4292
- 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;
4317
+ 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;
4293
4318
  if (store) {
4294
4319
  input.push({ type: "item_reference", id: itemId });
4295
4320
  } else if (part.output.type === "json") {
@@ -4329,7 +4354,7 @@ async function convertToOpenAIResponsesInput({
4329
4354
  break;
4330
4355
  }
4331
4356
  if (store) {
4332
- const itemId = (_D = (_C = (_B = part.providerOptions) == null ? void 0 : _B[providerOptionsName]) == null ? void 0 : _C.itemId) != null ? _D : part.toolCallId;
4357
+ const itemId = (_I = (_H = (_G = part.providerOptions) == null ? void 0 : _G[providerOptionsName]) == null ? void 0 : _H.itemId) != null ? _I : part.toolCallId;
4333
4358
  input.push({ type: "item_reference", id: itemId });
4334
4359
  } else {
4335
4360
  warnings.push({
@@ -4414,7 +4439,7 @@ async function convertToOpenAIResponsesInput({
4414
4439
  }
4415
4440
  case "custom": {
4416
4441
  if (part.kind === "openai.compaction") {
4417
- const providerOptions2 = (_E = part.providerOptions) == null ? void 0 : _E[providerOptionsName];
4442
+ const providerOptions2 = (_J = part.providerOptions) == null ? void 0 : _J[providerOptionsName];
4418
4443
  const id = providerOptions2 == null ? void 0 : providerOptions2.itemId;
4419
4444
  if (hasConversation && id != null) {
4420
4445
  break;
@@ -4520,7 +4545,7 @@ ${text}`,
4520
4545
  }
4521
4546
  const output = part.output;
4522
4547
  if (output.type === "execution-denied") {
4523
- const approvalId = (_G = (_F = output.providerOptions) == null ? void 0 : _F.openai) == null ? void 0 : _G.approvalId;
4548
+ const approvalId = (_L = (_K = output.providerOptions) == null ? void 0 : _K.openai) == null ? void 0 : _L.approvalId;
4524
4549
  if (approvalId) {
4525
4550
  continue;
4526
4551
  }
@@ -4600,7 +4625,7 @@ ${text}`,
4600
4625
  file_id: parsedOutput.output.fileId,
4601
4626
  detail: parsedOutput.output.detail
4602
4627
  },
4603
- acknowledged_safety_checks: (_H = parsedOutput.acknowledgedSafetyChecks) == null ? void 0 : _H.map((safetyCheck) => ({
4628
+ acknowledged_safety_checks: (_M = parsedOutput.acknowledgedSafetyChecks) == null ? void 0 : _M.map((safetyCheck) => ({
4604
4629
  id: safetyCheck.id,
4605
4630
  code: safetyCheck.code,
4606
4631
  message: safetyCheck.message
@@ -4629,7 +4654,7 @@ ${text}`,
4629
4654
  break;
4630
4655
  case "execution-denied":
4631
4656
  outputValue = convertScalarOutput(
4632
- (_I = output.reason) != null ? _I : "Tool call execution denied."
4657
+ (_N = output.reason) != null ? _N : "Tool call execution denied."
4633
4658
  );
4634
4659
  break;
4635
4660
  case "json":
@@ -4735,7 +4760,7 @@ ${text}`,
4735
4760
  warnings
4736
4761
  });
4737
4762
  const caller = mapToolCaller(
4738
- (_K = (_J = part.providerOptions) == null ? void 0 : _J[providerOptionsName]) == null ? void 0 : _K.caller
4763
+ (_P = (_O = part.providerOptions) == null ? void 0 : _O[providerOptionsName]) == null ? void 0 : _P.caller
4739
4764
  );
4740
4765
  input.push({
4741
4766
  type: "function_call_output",
@@ -5087,6 +5112,7 @@ var openaiResponsesChunkSchema = lazySchema18(
5087
5112
  call_id: z20.string(),
5088
5113
  name: z20.string(),
5089
5114
  arguments: z20.string(),
5115
+ async: z20.boolean().nullish(),
5090
5116
  namespace: z20.string().nullish(),
5091
5117
  caller: openaiResponsesToolCallerSchema.nullish()
5092
5118
  }),
@@ -5161,7 +5187,8 @@ var openaiResponsesChunkSchema = lazySchema18(
5161
5187
  id: z20.string(),
5162
5188
  call_id: z20.string(),
5163
5189
  name: z20.string(),
5164
- input: z20.string()
5190
+ input: z20.string(),
5191
+ async: z20.boolean().nullish()
5165
5192
  }),
5166
5193
  z20.object({
5167
5194
  type: z20.literal("shell_call"),
@@ -5234,6 +5261,7 @@ var openaiResponsesChunkSchema = lazySchema18(
5234
5261
  call_id: z20.string(),
5235
5262
  name: z20.string(),
5236
5263
  arguments: z20.string(),
5264
+ async: z20.boolean().nullish(),
5237
5265
  status: z20.enum(["in_progress", "completed", "incomplete"]),
5238
5266
  namespace: z20.string().nullish(),
5239
5267
  caller: openaiResponsesToolCallerSchema.nullish()
@@ -5246,6 +5274,7 @@ var openaiResponsesChunkSchema = lazySchema18(
5246
5274
  call_id: z20.string(),
5247
5275
  name: z20.string(),
5248
5276
  input: z20.string(),
5277
+ async: z20.boolean().nullish(),
5249
5278
  status: z20.literal("completed")
5250
5279
  }),
5251
5280
  z20.object({
@@ -5683,6 +5712,7 @@ var openaiResponsesResponseSchema = lazySchema18(
5683
5712
  name: z20.string(),
5684
5713
  arguments: z20.string(),
5685
5714
  id: z20.string(),
5715
+ async: z20.boolean().nullish(),
5686
5716
  namespace: z20.string().nullish(),
5687
5717
  caller: openaiResponsesToolCallerSchema.nullish()
5688
5718
  }),
@@ -5693,7 +5723,8 @@ var openaiResponsesResponseSchema = lazySchema18(
5693
5723
  call_id: z20.string(),
5694
5724
  name: z20.string(),
5695
5725
  input: z20.string(),
5696
- id: z20.string()
5726
+ id: z20.string(),
5727
+ async: z20.boolean().nullish()
5697
5728
  }),
5698
5729
  openaiResponsesComputerCallSchema,
5699
5730
  z20.object({
@@ -6009,6 +6040,15 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema19(
6009
6040
  * Supported values vary by model.
6010
6041
  */
6011
6042
  reasoningEffort: z21.string().nullish(),
6043
+ /**
6044
+ * Updates the reasoning effort for GPT-6 and later models starting with this response
6045
+ * without changing the request-level reasoning effort. This preserves the
6046
+ * request prefix for prompt caching.
6047
+ *
6048
+ * Only supported by GPT-6 and later models in standard, single-agent mode. Cannot be
6049
+ * combined with automatic compaction or automatic truncation.
6050
+ */
6051
+ reasoningEffortUpdate: z21.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
6012
6052
  /**
6013
6053
  * Controls how much model work GPT-5.6 performs before returning a final answer.
6014
6054
  * `standard` is the default. `pro` increases quality, latency, and token usage.
@@ -6290,6 +6330,7 @@ var customArgsSchema = lazySchema23(
6290
6330
  () => zodSchema23(
6291
6331
  z25.object({
6292
6332
  description: z25.string().optional(),
6333
+ async: z25.boolean().optional(),
6293
6334
  format: z25.union([
6294
6335
  z25.object({
6295
6336
  type: z25.literal("grammar"),
@@ -6495,7 +6536,8 @@ async function prepareResponsesTools({
6495
6536
  allowedTools,
6496
6537
  toolNameMapping,
6497
6538
  customProviderToolNames,
6498
- outputSchemaToolNames
6539
+ outputSchemaToolNames,
6540
+ supportsAsyncToolCalling = true
6499
6541
  }) {
6500
6542
  var _a2, _b, _c, _d;
6501
6543
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
@@ -6529,7 +6571,13 @@ async function prepareResponsesTools({
6529
6571
  }
6530
6572
  const openaiFunctionTool = prepareFunctionTool({
6531
6573
  tool,
6532
- options: openaiOptions
6574
+ options: openaiOptions,
6575
+ async: resolveAsyncToolOption({
6576
+ value: openaiOptions == null ? void 0 : openaiOptions.async,
6577
+ supportsAsyncToolCalling,
6578
+ toolName: tool.name,
6579
+ toolWarnings
6580
+ })
6533
6581
  });
6534
6582
  const namespace = openaiOptions == null ? void 0 : openaiOptions.namespace;
6535
6583
  if (namespace == null) {
@@ -6718,6 +6766,12 @@ async function prepareResponsesTools({
6718
6766
  type: "custom",
6719
6767
  name: tool.name,
6720
6768
  description: args.description,
6769
+ ...resolveAsyncToolOption({
6770
+ value: args.async,
6771
+ supportsAsyncToolCalling,
6772
+ toolName: tool.name,
6773
+ toolWarnings
6774
+ }) != null ? { async: args.async } : {},
6721
6775
  format: args.format
6722
6776
  });
6723
6777
  resolvedCustomProviderToolNames.add(tool.name);
@@ -6897,7 +6951,8 @@ function toAllowedToolResolution(tool) {
6897
6951
  }
6898
6952
  function prepareFunctionTool({
6899
6953
  tool,
6900
- options
6954
+ options,
6955
+ async
6901
6956
  }) {
6902
6957
  const deferLoading = options == null ? void 0 : options.deferLoading;
6903
6958
  return {
@@ -6905,12 +6960,29 @@ function prepareFunctionTool({
6905
6960
  name: tool.name,
6906
6961
  description: tool.description,
6907
6962
  parameters: tool.inputSchema,
6963
+ ...async != null ? { async } : {},
6908
6964
  ...tool.strict != null ? { strict: tool.strict } : {},
6909
6965
  ...deferLoading != null ? { defer_loading: deferLoading } : {},
6910
6966
  ...(options == null ? void 0 : options.allowedCallers) != null ? { allowed_callers: options.allowedCallers } : {},
6911
6967
  ...(options == null ? void 0 : options.outputSchema) != null ? { output_schema: options.outputSchema } : {}
6912
6968
  };
6913
6969
  }
6970
+ function resolveAsyncToolOption({
6971
+ value,
6972
+ supportsAsyncToolCalling,
6973
+ toolName,
6974
+ toolWarnings
6975
+ }) {
6976
+ if (value !== true || supportsAsyncToolCalling) {
6977
+ return value;
6978
+ }
6979
+ toolWarnings.push({
6980
+ type: "unsupported",
6981
+ feature: `async tool calling for "${toolName}"`,
6982
+ details: "Async tool calling is only supported by GPT-6 and later models."
6983
+ });
6984
+ return void 0;
6985
+ }
6914
6986
  function mapShellEnvironment(environment) {
6915
6987
  if (environment.type === "containerReference") {
6916
6988
  const env2 = environment;
@@ -7048,13 +7120,14 @@ function mapComputerCallInput({
7048
7120
  status
7049
7121
  };
7050
7122
  }
7123
+ var openaiResponsesSupportedUrls = {
7124
+ "image/*": [/^https?:\/\/.*$/],
7125
+ "application/pdf": [/^https?:\/\/.*$/]
7126
+ };
7051
7127
  var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7052
7128
  constructor(modelId, config) {
7053
7129
  this.specificationVersion = "v4";
7054
- this.supportedUrls = {
7055
- "image/*": [/^https?:\/\/.*$/],
7056
- "application/pdf": [/^https?:\/\/.*$/]
7057
- };
7130
+ this.supportedUrls = openaiResponsesSupportedUrls;
7058
7131
  this.modelId = modelId;
7059
7132
  this.config = config;
7060
7133
  }
@@ -7073,25 +7146,29 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7073
7146
  get provider() {
7074
7147
  return this.config.provider;
7075
7148
  }
7076
- async getArgs({
7077
- maxOutputTokens,
7078
- temperature,
7079
- stopSequences,
7080
- topP,
7081
- topK,
7082
- presencePenalty,
7083
- frequencyPenalty,
7084
- seed,
7085
- prompt,
7086
- reasoning,
7087
- providerOptions,
7088
- tools,
7089
- toolChoice,
7090
- responseFormat
7149
+ static async prepareRequest({
7150
+ modelId,
7151
+ config,
7152
+ options: {
7153
+ maxOutputTokens,
7154
+ temperature,
7155
+ stopSequences,
7156
+ topP,
7157
+ topK,
7158
+ presencePenalty,
7159
+ frequencyPenalty,
7160
+ seed,
7161
+ prompt,
7162
+ reasoning,
7163
+ providerOptions,
7164
+ tools,
7165
+ toolChoice,
7166
+ responseFormat
7167
+ }
7091
7168
  }) {
7092
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
7169
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
7093
7170
  const warnings = [];
7094
- const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
7171
+ const modelCapabilities = getOpenAILanguageModelCapabilities(modelId);
7095
7172
  if (topK != null) {
7096
7173
  warnings.push({ type: "unsupported", feature: "topK" });
7097
7174
  }
@@ -7107,7 +7184,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7107
7184
  if (stopSequences != null) {
7108
7185
  warnings.push({ type: "unsupported", feature: "stopSequences" });
7109
7186
  }
7110
- const providerOptionsName = this.config.provider.includes("azure") ? "azure" : "openai";
7187
+ const providerOptionsName = config.provider.includes("azure") ? "azure" : "openai";
7111
7188
  let openaiOptions = await parseProviderOptions8({
7112
7189
  provider: providerOptionsName,
7113
7190
  providerOptions,
@@ -7120,7 +7197,17 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7120
7197
  schema: openaiLanguageModelResponsesOptionsSchema
7121
7198
  });
7122
7199
  }
7123
- const resolvedReasoningEffort = (_a2 = openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null ? _a2 : isCustomReasoning2(reasoning) ? reasoning : void 0;
7200
+ let resolvedReasoningEffort = (_a2 = openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null ? _a2 : isCustomReasoning2(reasoning) ? reasoning : void 0;
7201
+ if (resolvedReasoningEffort != null && modelCapabilities.supportedReasoningEfforts != null && !modelCapabilities.supportedReasoningEfforts.includes(
7202
+ resolvedReasoningEffort
7203
+ )) {
7204
+ warnings.push({
7205
+ type: "unsupported",
7206
+ feature: "reasoningEffort",
7207
+ details: `${modelId} only supports the following reasoning efforts: ${modelCapabilities.supportedReasoningEfforts.join(", ")}`
7208
+ });
7209
+ resolvedReasoningEffort = void 0;
7210
+ }
7124
7211
  const resolvedReasoningSummary = (openaiOptions == null ? void 0 : openaiOptions.reasoningSummary) !== void 0 ? openaiOptions.reasoningSummary : resolvedReasoningEffort != null && resolvedReasoningEffort !== "none" ? "detailed" : void 0;
7125
7212
  const isReasoningModel = (_b = openaiOptions == null ? void 0 : openaiOptions.forceReasoning) != null ? _b : modelCapabilities.isReasoningModel;
7126
7213
  if ((openaiOptions == null ? void 0 : openaiOptions.conversation) && (openaiOptions == null ? void 0 : openaiOptions.previousResponseId)) {
@@ -7159,14 +7246,15 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7159
7246
  allowedTools: (_c = openaiOptions == null ? void 0 : openaiOptions.allowedTools) != null ? _c : void 0,
7160
7247
  toolNameMapping,
7161
7248
  customProviderToolNames,
7162
- outputSchemaToolNames
7249
+ outputSchemaToolNames,
7250
+ supportsAsyncToolCalling: modelCapabilities.supportsAsyncToolCalling
7163
7251
  });
7164
7252
  const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
7165
7253
  prompt,
7166
7254
  toolNameMapping,
7167
7255
  systemMessageMode: (_d = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _d : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
7168
7256
  providerOptionsName,
7169
- fileIdPrefixes: this.config.fileIdPrefixes,
7257
+ fileIdPrefixes: config.fileIdPrefixes,
7170
7258
  passThroughUnsupportedFiles: (_e = openaiOptions == null ? void 0 : openaiOptions.passThroughUnsupportedFiles) != null ? _e : false,
7171
7259
  store: (_f = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _f : true,
7172
7260
  hasConversation: (openaiOptions == null ? void 0 : openaiOptions.conversation) != null,
@@ -7180,6 +7268,20 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7180
7268
  outputSchemaToolNames: outputSchemaToolNames.size > 0 ? outputSchemaToolNames : void 0
7181
7269
  });
7182
7270
  warnings.push(...inputWarnings);
7271
+ const reasoningEffortUpdate = openaiOptions == null ? void 0 : openaiOptions.reasoningEffortUpdate;
7272
+ 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";
7273
+ if (reasoningEffortUpdate != null && !configurationUpdateIsSupported) {
7274
+ warnings.push({
7275
+ type: "unsupported",
7276
+ feature: "reasoningEffortUpdate",
7277
+ details: !modelCapabilities.supportsConfigurationUpdate ? "reasoningEffortUpdate is only supported by GPT-6 and later models" : "reasoningEffortUpdate requires standard reasoning mode without automatic compaction or automatic truncation"
7278
+ });
7279
+ } else if (reasoningEffortUpdate != null) {
7280
+ input.unshift({
7281
+ type: "configuration_update",
7282
+ reasoning: { effort: reasoningEffortUpdate }
7283
+ });
7284
+ }
7183
7285
  if (openaiOptions == null ? void 0 : openaiOptions.compactionTrigger) {
7184
7286
  input.push({ type: "compaction_trigger" });
7185
7287
  }
@@ -7217,7 +7319,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7217
7319
  addInclude("reasoning.encrypted_content");
7218
7320
  }
7219
7321
  const baseArgs = {
7220
- model: this.modelId,
7322
+ model: modelId,
7221
7323
  input,
7222
7324
  temperature,
7223
7325
  top_p: topP,
@@ -7280,6 +7382,14 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7280
7382
  }
7281
7383
  }
7282
7384
  };
7385
+ if (modelCapabilities.supportsConfigurationUpdate && baseArgs.prompt_cache_retention != null) {
7386
+ baseArgs.prompt_cache_retention = void 0;
7387
+ warnings.push({
7388
+ type: "unsupported",
7389
+ feature: "promptCacheRetention",
7390
+ details: "promptCacheRetention is not supported by GPT-6 and later models; use promptCacheOptions instead"
7391
+ });
7392
+ }
7283
7393
  if (isReasoningModel) {
7284
7394
  if (!(resolvedReasoningEffort === "none" && modelCapabilities.supportsNonReasoningParameters)) {
7285
7395
  if (baseArgs.temperature != null) {
@@ -7298,6 +7408,18 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7298
7408
  details: "topP is not supported for reasoning models"
7299
7409
  });
7300
7410
  }
7411
+ if (modelCapabilities.supportedReasoningEfforts != null && (baseArgs.top_logprobs != null || ((_j = baseArgs.include) == null ? void 0 : _j.includes("message.output_text.logprobs")))) {
7412
+ baseArgs.top_logprobs = void 0;
7413
+ const filteredInclude = (_k = baseArgs.include) == null ? void 0 : _k.filter(
7414
+ (value) => value !== "message.output_text.logprobs"
7415
+ );
7416
+ baseArgs.include = filteredInclude != null && filteredInclude.length > 0 ? filteredInclude : void 0;
7417
+ warnings.push({
7418
+ type: "unsupported",
7419
+ feature: "logprobs",
7420
+ details: "logprobs is not supported for reasoning models"
7421
+ });
7422
+ }
7301
7423
  }
7302
7424
  } else {
7303
7425
  if ((openaiOptions == null ? void 0 : openaiOptions.reasoningEffort) != null) {
@@ -7345,9 +7467,9 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7345
7467
  });
7346
7468
  delete baseArgs.service_tier;
7347
7469
  }
7348
- const shellToolEnvType = (_l = (_k = (_j = tools == null ? void 0 : tools.find(
7470
+ const shellToolEnvType = (_n = (_m = (_l = tools == null ? void 0 : tools.find(
7349
7471
  (tool) => tool.type === "provider" && tool.id === "openai.shell"
7350
- )) == null ? void 0 : _j.args) == null ? void 0 : _k.environment) == null ? void 0 : _l.type;
7472
+ )) == null ? void 0 : _l.args) == null ? void 0 : _m.environment) == null ? void 0 : _n.type;
7351
7473
  const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
7352
7474
  return {
7353
7475
  webSearchToolName,
@@ -7363,6 +7485,13 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7363
7485
  isShellProviderExecuted
7364
7486
  };
7365
7487
  }
7488
+ getArgs(options) {
7489
+ return _OpenAIResponsesLanguageModel.prepareRequest({
7490
+ modelId: this.modelId,
7491
+ config: this.config,
7492
+ options
7493
+ });
7494
+ }
7366
7495
  async doGenerate(options) {
7367
7496
  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;
7368
7497
  const {
@@ -7659,6 +7788,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7659
7788
  providerMetadata: {
7660
7789
  [providerOptionsName]: {
7661
7790
  itemId: part.id,
7791
+ ...part.async != null && { async: part.async },
7662
7792
  ...part.namespace != null && { namespace: part.namespace },
7663
7793
  ...part.caller != null && {
7664
7794
  caller: part.caller.type === "program" ? {
@@ -7720,7 +7850,8 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7720
7850
  input: JSON.stringify(part.input),
7721
7851
  providerMetadata: {
7722
7852
  [providerOptionsName]: {
7723
- itemId: part.id
7853
+ itemId: part.id,
7854
+ ...part.async != null && { async: part.async }
7724
7855
  }
7725
7856
  }
7726
7857
  });
@@ -8047,7 +8178,8 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
8047
8178
  toolName: value.item.name,
8048
8179
  toolCallId: value.item.call_id,
8049
8180
  suppressInputStreaming,
8050
- bufferedInputDeltas: suppressInputStreaming ? [] : void 0
8181
+ bufferedInputDeltas: suppressInputStreaming ? [] : void 0,
8182
+ async: value.item.async
8051
8183
  };
8052
8184
  if (!suppressInputStreaming) {
8053
8185
  controller.enqueue({
@@ -8062,7 +8194,8 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
8062
8194
  );
8063
8195
  ongoingToolCalls[value.output_index] = {
8064
8196
  toolName,
8065
- toolCallId: value.item.call_id
8197
+ toolCallId: value.item.call_id,
8198
+ async: value.item.async
8066
8199
  };
8067
8200
  controller.enqueue({
8068
8201
  type: "tool-input-start",
@@ -8313,6 +8446,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
8313
8446
  providerMetadata: {
8314
8447
  [providerOptionsName]: {
8315
8448
  itemId: item.id,
8449
+ ...item.async != null ? { async: item.async } : (ongoingToolCall == null ? void 0 : ongoingToolCall.async) != null ? { async: ongoingToolCall.async } : {},
8316
8450
  ...item.namespace != null && {
8317
8451
  namespace: item.namespace
8318
8452
  },
@@ -8398,6 +8532,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
8398
8532
  }
8399
8533
  });
8400
8534
  } else if (value.item.type === "custom_tool_call") {
8535
+ const ongoingToolCall = ongoingToolCalls[value.output_index];
8401
8536
  ongoingToolCalls[value.output_index] = void 0;
8402
8537
  hasFunctionCall = true;
8403
8538
  const toolName = toolNameMapping.toCustomToolName(
@@ -8414,7 +8549,8 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
8414
8549
  input: JSON.stringify(value.item.input),
8415
8550
  providerMetadata: {
8416
8551
  [providerOptionsName]: {
8417
- itemId: value.item.id
8552
+ itemId: value.item.id,
8553
+ ...value.item.async != null ? { async: value.item.async } : (ongoingToolCall == null ? void 0 : ongoingToolCall.async) != null ? { async: ongoingToolCall.async } : {}
8418
8554
  }
8419
8555
  }
8420
8556
  });
@@ -9242,6 +9378,7 @@ export {
9242
9378
  openaiImageModelOptions,
9243
9379
  openaiLanguageModelChatOptions,
9244
9380
  openaiLanguageModelCompletionOptions,
9381
+ openaiResponsesSupportedUrls,
9245
9382
  openaiSpeechModelOptionsSchema,
9246
9383
  programmaticToolCalling,
9247
9384
  programmaticToolCallingInputSchema,