@ai-sdk/openai 3.0.109 → 3.0.110

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.
@@ -47,6 +47,7 @@ function getOpenAILanguageModelCapabilities(modelId) {
47
47
  supportsFlexProcessing,
48
48
  supportsPriorityProcessing,
49
49
  supportsConfigurationUpdate: isGpt6OrLaterModel,
50
+ supportsAsyncToolCalling: isGpt6OrLaterModel,
50
51
  supportedReasoningEfforts: isGpt6OrLaterModel ? ["low", "medium", "high", "xhigh", "max"] : void 0,
51
52
  isReasoningModel,
52
53
  systemMessageMode,
@@ -2098,9 +2099,10 @@ var baseImageModelOptionsObject = z9.object({
2098
2099
  /**
2099
2100
  * Quality of the generated image(s).
2100
2101
  *
2101
- * Valid values: `standard`, `hd`, `low`, `medium`, `high`, `auto`.
2102
+ * Valid values: `standard`, `hd`, `low`, `medium`, `high`, `xhigh`, `max`, `auto`.
2103
+ * `xhigh` and `max` are supported by GPT Image 2.5 models.
2102
2104
  */
2103
- quality: z9.enum(["standard", "hd", "low", "medium", "high", "auto"]).optional(),
2105
+ quality: z9.enum(["standard", "hd", "low", "medium", "high", "xhigh", "max", "auto"]).optional(),
2104
2106
  /**
2105
2107
  * Background behavior for the generated image(s).
2106
2108
  *
@@ -3285,7 +3287,7 @@ async function convertToOpenAIResponsesInput({
3285
3287
  toolSearchToolName,
3286
3288
  customProviderToolNames
3287
3289
  }) {
3288
- 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;
3290
+ 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;
3289
3291
  let input = [];
3290
3292
  const warnings = [];
3291
3293
  const processedApprovalIds = /* @__PURE__ */ new Set();
@@ -3470,6 +3472,7 @@ async function convertToOpenAIResponsesInput({
3470
3472
  }
3471
3473
  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;
3472
3474
  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;
3475
+ 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;
3473
3476
  if (hasConversation && id != null) {
3474
3477
  break;
3475
3478
  }
@@ -3493,7 +3496,7 @@ async function convertToOpenAIResponsesInput({
3493
3496
  type: "tool_search_call",
3494
3497
  id: id != null ? id : part.toolCallId,
3495
3498
  execution,
3496
- call_id: (_l = parsedInput.call_id) != null ? _l : null,
3499
+ call_id: (_q = parsedInput.call_id) != null ? _q : null,
3497
3500
  status: "completed",
3498
3501
  arguments: parsedInput.arguments
3499
3502
  });
@@ -3507,7 +3510,7 @@ async function convertToOpenAIResponsesInput({
3507
3510
  break;
3508
3511
  }
3509
3512
  }
3510
- const isProviderDefinedToolCall = hasLocalShellTool && resolvedToolName === "local_shell" || hasShellTool && resolvedToolName === "shell" || hasApplyPatchTool && resolvedToolName === "apply_patch" || ((_m = customProviderToolNames == null ? void 0 : customProviderToolNames.has(resolvedToolName)) != null ? _m : false);
3513
+ const isProviderDefinedToolCall = hasLocalShellTool && resolvedToolName === "local_shell" || hasShellTool && resolvedToolName === "shell" || hasApplyPatchTool && resolvedToolName === "apply_patch" || ((_r = customProviderToolNames == null ? void 0 : customProviderToolNames.has(resolvedToolName)) != null ? _r : false);
3511
3514
  if (hasPreviousResponseId && store && id != null && isProviderDefinedToolCall) {
3512
3515
  break;
3513
3516
  }
@@ -3573,6 +3576,7 @@ async function convertToOpenAIResponsesInput({
3573
3576
  call_id: part.toolCallId,
3574
3577
  name: resolvedToolName,
3575
3578
  input: typeof part.input === "string" ? part.input : JSON.stringify(part.input),
3579
+ ...isAsync != null && { async: isAsync },
3576
3580
  id
3577
3581
  });
3578
3582
  break;
@@ -3582,6 +3586,7 @@ async function convertToOpenAIResponsesInput({
3582
3586
  call_id: part.toolCallId,
3583
3587
  name: resolvedToolName,
3584
3588
  arguments: serializeToolCallArguments2(part.input),
3589
+ ...isAsync != null && { async: isAsync },
3585
3590
  ...namespace != null && { namespace }
3586
3591
  });
3587
3592
  break;
@@ -3598,7 +3603,7 @@ async function convertToOpenAIResponsesInput({
3598
3603
  part.toolName
3599
3604
  );
3600
3605
  if (part.toolName === toolSearchToolName) {
3601
- const itemId = (_s = (_r = (_o = (_n = part.providerOptions) == null ? void 0 : _n[providerOptionsName]) == null ? void 0 : _o.itemId) != null ? _r : (_q = (_p = part.providerMetadata) == null ? void 0 : _p[providerOptionsName]) == null ? void 0 : _q.itemId) != null ? _s : part.toolCallId;
3606
+ const itemId = (_x = (_w = (_t = (_s = part.providerOptions) == null ? void 0 : _s[providerOptionsName]) == null ? void 0 : _t.itemId) != null ? _w : (_v = (_u = part.providerMetadata) == null ? void 0 : _u[providerOptionsName]) == null ? void 0 : _v.itemId) != null ? _x : part.toolCallId;
3602
3607
  if (store) {
3603
3608
  input.push({ type: "item_reference", id: itemId });
3604
3609
  } else if (part.output.type === "json") {
@@ -3639,7 +3644,7 @@ async function convertToOpenAIResponsesInput({
3639
3644
  break;
3640
3645
  }
3641
3646
  if (store) {
3642
- const itemId = (_v = (_u = (_t = part.providerOptions) == null ? void 0 : _t[providerOptionsName]) == null ? void 0 : _u.itemId) != null ? _v : part.toolCallId;
3647
+ const itemId = (_A = (_z = (_y = part.providerOptions) == null ? void 0 : _y[providerOptionsName]) == null ? void 0 : _z.itemId) != null ? _A : part.toolCallId;
3643
3648
  input.push({ type: "item_reference", id: itemId });
3644
3649
  } else {
3645
3650
  warnings.push({
@@ -3806,7 +3811,7 @@ ${text}`,
3806
3811
  }
3807
3812
  const output = part.output;
3808
3813
  if (output.type === "execution-denied") {
3809
- const approvalId = (_x = (_w = output.providerOptions) == null ? void 0 : _w.openai) == null ? void 0 : _x.approvalId;
3814
+ const approvalId = (_C = (_B = output.providerOptions) == null ? void 0 : _B.openai) == null ? void 0 : _C.approvalId;
3810
3815
  if (approvalId) {
3811
3816
  continue;
3812
3817
  }
@@ -3893,7 +3898,7 @@ ${text}`,
3893
3898
  break;
3894
3899
  case "execution-denied":
3895
3900
  outputValue = convertScalarOutput(
3896
- (_y = output.reason) != null ? _y : "Tool call execution denied."
3901
+ (_D = output.reason) != null ? _D : "Tool call execution denied."
3897
3902
  );
3898
3903
  break;
3899
3904
  case "json":
@@ -4234,6 +4239,7 @@ var openaiResponsesChunkSchema = lazySchema16(
4234
4239
  call_id: z18.string(),
4235
4240
  name: z18.string(),
4236
4241
  arguments: z18.string(),
4242
+ async: z18.boolean().nullish(),
4237
4243
  namespace: z18.string().nullish()
4238
4244
  }),
4239
4245
  z18.object({
@@ -4309,7 +4315,8 @@ var openaiResponsesChunkSchema = lazySchema16(
4309
4315
  id: z18.string(),
4310
4316
  call_id: z18.string(),
4311
4317
  name: z18.string(),
4312
- input: z18.string()
4318
+ input: z18.string(),
4319
+ async: z18.boolean().nullish()
4313
4320
  }),
4314
4321
  z18.object({
4315
4322
  type: z18.literal("shell_call"),
@@ -4377,6 +4384,7 @@ var openaiResponsesChunkSchema = lazySchema16(
4377
4384
  call_id: z18.string(),
4378
4385
  name: z18.string(),
4379
4386
  arguments: z18.string(),
4387
+ async: z18.boolean().nullish(),
4380
4388
  status: z18.literal("completed"),
4381
4389
  namespace: z18.string().nullish()
4382
4390
  }),
@@ -4386,6 +4394,7 @@ var openaiResponsesChunkSchema = lazySchema16(
4386
4394
  call_id: z18.string(),
4387
4395
  name: z18.string(),
4388
4396
  input: z18.string(),
4397
+ async: z18.boolean().nullish(),
4389
4398
  status: z18.literal("completed")
4390
4399
  }),
4391
4400
  z18.object({
@@ -4819,6 +4828,7 @@ var openaiResponsesResponseSchema = lazySchema16(
4819
4828
  name: z18.string(),
4820
4829
  arguments: z18.string(),
4821
4830
  id: z18.string(),
4831
+ async: z18.boolean().nullish(),
4822
4832
  namespace: z18.string().nullish()
4823
4833
  }),
4824
4834
  z18.object({
@@ -4826,7 +4836,8 @@ var openaiResponsesResponseSchema = lazySchema16(
4826
4836
  call_id: z18.string(),
4827
4837
  name: z18.string(),
4828
4838
  input: z18.string(),
4829
- id: z18.string()
4839
+ id: z18.string(),
4840
+ async: z18.boolean().nullish()
4830
4841
  }),
4831
4842
  z18.object({
4832
4843
  type: z18.literal("computer_call"),
@@ -5381,7 +5392,7 @@ var imageGenerationArgsSchema = lazySchema20(
5381
5392
  outputCompression: z22.number().int().min(0).max(100).optional(),
5382
5393
  outputFormat: z22.enum(["png", "jpeg", "webp"]).optional(),
5383
5394
  partialImages: z22.number().int().min(0).max(3).optional(),
5384
- quality: z22.enum(["auto", "low", "medium", "high"]).optional(),
5395
+ quality: z22.enum(["auto", "low", "medium", "high", "xhigh", "max"]).optional(),
5385
5396
  size: z22.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
5386
5397
  }).strict()
5387
5398
  )
@@ -5411,6 +5422,7 @@ var customArgsSchema = lazySchema21(
5411
5422
  z23.object({
5412
5423
  name: z23.string(),
5413
5424
  description: z23.string().optional(),
5425
+ async: z23.boolean().optional(),
5414
5426
  format: z23.union([
5415
5427
  z23.object({
5416
5428
  type: z23.literal("grammar"),
@@ -5615,7 +5627,8 @@ async function prepareResponsesTools({
5615
5627
  toolChoice,
5616
5628
  allowedTools,
5617
5629
  toolNameMapping,
5618
- customProviderToolNames
5630
+ customProviderToolNames,
5631
+ supportsAsyncToolCalling = true
5619
5632
  }) {
5620
5633
  var _a2, _b, _c, _d;
5621
5634
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
@@ -5646,7 +5659,13 @@ async function prepareResponsesTools({
5646
5659
  const openaiOptions = (_a2 = tool.providerOptions) == null ? void 0 : _a2.openai;
5647
5660
  const openaiFunctionTool = prepareFunctionTool({
5648
5661
  tool,
5649
- options: openaiOptions
5662
+ options: openaiOptions,
5663
+ async: resolveAsyncToolOption({
5664
+ value: openaiOptions == null ? void 0 : openaiOptions.async,
5665
+ supportsAsyncToolCalling,
5666
+ toolName: tool.name,
5667
+ toolWarnings
5668
+ })
5650
5669
  });
5651
5670
  const namespace = openaiOptions == null ? void 0 : openaiOptions.namespace;
5652
5671
  if (namespace == null) {
@@ -5828,6 +5847,12 @@ async function prepareResponsesTools({
5828
5847
  type: "custom",
5829
5848
  name: args.name,
5830
5849
  description: args.description,
5850
+ ...resolveAsyncToolOption({
5851
+ value: args.async,
5852
+ supportsAsyncToolCalling,
5853
+ toolName: args.name,
5854
+ toolWarnings
5855
+ }) != null ? { async: args.async } : {},
5831
5856
  format: args.format
5832
5857
  });
5833
5858
  resolvedCustomProviderToolNames.add(args.name);
@@ -5999,7 +6024,8 @@ function toAllowedToolResolution(tool) {
5999
6024
  }
6000
6025
  function prepareFunctionTool({
6001
6026
  tool,
6002
- options
6027
+ options,
6028
+ async
6003
6029
  }) {
6004
6030
  const deferLoading = options == null ? void 0 : options.deferLoading;
6005
6031
  return {
@@ -6007,10 +6033,27 @@ function prepareFunctionTool({
6007
6033
  name: tool.name,
6008
6034
  description: tool.description,
6009
6035
  parameters: tool.inputSchema,
6036
+ ...async != null ? { async } : {},
6010
6037
  ...tool.strict != null ? { strict: tool.strict } : {},
6011
6038
  ...deferLoading != null ? { defer_loading: deferLoading } : {}
6012
6039
  };
6013
6040
  }
6041
+ function resolveAsyncToolOption({
6042
+ value,
6043
+ supportsAsyncToolCalling,
6044
+ toolName,
6045
+ toolWarnings
6046
+ }) {
6047
+ if (value !== true || supportsAsyncToolCalling) {
6048
+ return value;
6049
+ }
6050
+ toolWarnings.push({
6051
+ type: "unsupported",
6052
+ feature: `async tool calling for "${toolName}"`,
6053
+ details: "Async tool calling is only supported by GPT-6 and later models."
6054
+ });
6055
+ return void 0;
6056
+ }
6014
6057
  function mapShellEnvironment(environment) {
6015
6058
  if (environment.type === "containerReference") {
6016
6059
  const env2 = environment;
@@ -6178,7 +6221,8 @@ var OpenAIResponsesLanguageModel = class {
6178
6221
  toolChoice,
6179
6222
  allowedTools: (_b = openaiOptions == null ? void 0 : openaiOptions.allowedTools) != null ? _b : void 0,
6180
6223
  toolNameMapping,
6181
- customProviderToolNames
6224
+ customProviderToolNames,
6225
+ supportsAsyncToolCalling: modelCapabilities.supportsAsyncToolCalling
6182
6226
  });
6183
6227
  const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
6184
6228
  prompt,
@@ -6688,6 +6732,7 @@ var OpenAIResponsesLanguageModel = class {
6688
6732
  providerMetadata: {
6689
6733
  [providerOptionsName]: {
6690
6734
  itemId: part.id,
6735
+ ...part.async != null && { async: part.async },
6691
6736
  ...part.namespace != null && { namespace: part.namespace }
6692
6737
  }
6693
6738
  }
@@ -6704,7 +6749,8 @@ var OpenAIResponsesLanguageModel = class {
6704
6749
  input: JSON.stringify(part.input),
6705
6750
  providerMetadata: {
6706
6751
  [providerOptionsName]: {
6707
- itemId: part.id
6752
+ itemId: part.id,
6753
+ ...part.async != null && { async: part.async }
6708
6754
  }
6709
6755
  }
6710
6756
  });
@@ -6992,7 +7038,8 @@ var OpenAIResponsesLanguageModel = class {
6992
7038
  toolName: value.item.name,
6993
7039
  toolCallId: value.item.call_id,
6994
7040
  suppressInputStreaming,
6995
- bufferedInputDeltas: suppressInputStreaming ? [] : void 0
7041
+ bufferedInputDeltas: suppressInputStreaming ? [] : void 0,
7042
+ async: value.item.async
6996
7043
  };
6997
7044
  if (!suppressInputStreaming) {
6998
7045
  controller.enqueue({
@@ -7007,7 +7054,8 @@ var OpenAIResponsesLanguageModel = class {
7007
7054
  );
7008
7055
  ongoingToolCalls[value.output_index] = {
7009
7056
  toolName,
7010
- toolCallId: value.item.call_id
7057
+ toolCallId: value.item.call_id,
7058
+ async: value.item.async
7011
7059
  };
7012
7060
  controller.enqueue({
7013
7061
  type: "tool-input-start",
@@ -7251,6 +7299,7 @@ var OpenAIResponsesLanguageModel = class {
7251
7299
  providerMetadata: {
7252
7300
  [providerOptionsName]: {
7253
7301
  itemId: item.id,
7302
+ ...item.async != null ? { async: item.async } : (ongoingToolCall == null ? void 0 : ongoingToolCall.async) != null ? { async: ongoingToolCall.async } : {},
7254
7303
  ...item.namespace != null && {
7255
7304
  namespace: item.namespace
7256
7305
  }
@@ -7295,6 +7344,7 @@ var OpenAIResponsesLanguageModel = class {
7295
7344
  }
7296
7345
  });
7297
7346
  } else if (value.item.type === "custom_tool_call") {
7347
+ const ongoingToolCall = ongoingToolCalls[value.output_index];
7298
7348
  ongoingToolCalls[value.output_index] = void 0;
7299
7349
  hasFunctionCall = true;
7300
7350
  const toolName = toolNameMapping.toCustomToolName(
@@ -7311,7 +7361,8 @@ var OpenAIResponsesLanguageModel = class {
7311
7361
  input: JSON.stringify(value.item.input),
7312
7362
  providerMetadata: {
7313
7363
  [providerOptionsName]: {
7314
- itemId: value.item.id
7364
+ itemId: value.item.id,
7365
+ ...value.item.async != null ? { async: value.item.async } : (ongoingToolCall == null ? void 0 : ongoingToolCall.async) != null ? { async: ongoingToolCall.async } : {}
7315
7366
  }
7316
7367
  }
7317
7368
  });