@ai-sdk/openai 3.0.109 → 3.0.111

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.mjs CHANGED
@@ -55,6 +55,7 @@ function getOpenAILanguageModelCapabilities(modelId) {
55
55
  supportsFlexProcessing,
56
56
  supportsPriorityProcessing,
57
57
  supportsConfigurationUpdate: isGpt6OrLaterModel,
58
+ supportsAsyncToolCalling: isGpt6OrLaterModel,
58
59
  supportedReasoningEfforts: isGpt6OrLaterModel ? ["low", "medium", "high", "xhigh", "max"] : void 0,
59
60
  isReasoningModel,
60
61
  systemMessageMode,
@@ -2090,6 +2091,10 @@ var modelMaxImagesPerCall = {
2090
2091
  "gpt-image-1-mini": 10,
2091
2092
  "gpt-image-1.5": 10,
2092
2093
  "gpt-image-2": 10,
2094
+ "gpt-image-2.5-flare": 10,
2095
+ "gpt-image-2.5-flare-2026-09-08": 10,
2096
+ "gpt-image-2.5-sunburst": 10,
2097
+ "gpt-image-2.5-sunburst-2026-09-08": 10,
2093
2098
  "chatgpt-image-latest": 10
2094
2099
  };
2095
2100
  var defaultResponseFormatPrefixes = ["chatgpt-image-", "gpt-image-"];
@@ -2106,9 +2111,10 @@ var baseImageModelOptionsObject = z9.object({
2106
2111
  /**
2107
2112
  * Quality of the generated image(s).
2108
2113
  *
2109
- * Valid values: `standard`, `hd`, `low`, `medium`, `high`, `auto`.
2114
+ * Valid values: `standard`, `hd`, `low`, `medium`, `high`, `xhigh`, `max`, `auto`.
2115
+ * `xhigh` and `max` are supported by GPT Image 2.5 models.
2110
2116
  */
2111
- quality: z9.enum(["standard", "hd", "low", "medium", "high", "auto"]).optional(),
2117
+ quality: z9.enum(["standard", "hd", "low", "medium", "high", "xhigh", "max", "auto"]).optional(),
2112
2118
  /**
2113
2119
  * Background behavior for the generated image(s).
2114
2120
  *
@@ -2481,6 +2487,7 @@ var customArgsSchema = lazySchema11(
2481
2487
  z12.object({
2482
2488
  name: z12.string(),
2483
2489
  description: z12.string().optional(),
2490
+ async: z12.boolean().optional(),
2484
2491
  format: z12.union([
2485
2492
  z12.object({
2486
2493
  type: z12.literal("grammar"),
@@ -2575,7 +2582,7 @@ var imageGenerationArgsSchema = lazySchema13(
2575
2582
  outputCompression: z14.number().int().min(0).max(100).optional(),
2576
2583
  outputFormat: z14.enum(["png", "jpeg", "webp"]).optional(),
2577
2584
  partialImages: z14.number().int().min(0).max(3).optional(),
2578
- quality: z14.enum(["auto", "low", "medium", "high"]).optional(),
2585
+ quality: z14.enum(["auto", "low", "medium", "high", "xhigh", "max"]).optional(),
2579
2586
  size: z14.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
2580
2587
  }).strict()
2581
2588
  )
@@ -2959,6 +2966,7 @@ var openaiTools = {
2959
2966
  *
2960
2967
  * @param name - The name of the custom tool.
2961
2968
  * @param description - An optional description of the tool.
2969
+ * @param async - Whether the model can continue without waiting for the tool result.
2962
2970
  * @param format - The output format constraint (grammar type, syntax, and definition).
2963
2971
  */
2964
2972
  customTool,
@@ -2994,7 +3002,7 @@ var openaiTools = {
2994
3002
  * @param outputCompression - Compression level for the output image (0-100).
2995
3003
  * @param outputFormat - The output format of the generated image. One of 'png', 'jpeg', or 'webp'.
2996
3004
  * @param partialImages - Number of partial images to generate in streaming mode (0-3).
2997
- * @param quality - The quality of the generated image. One of 'auto', 'low', 'medium', or 'high'.
3005
+ * @param quality - The quality of the generated image. One of 'auto', 'low', 'medium', 'high', 'xhigh', or 'max'. 'xhigh' and 'max' require a GPT Image 2.5 model.
2998
3006
  * @param size - The size of the generated image. One of 'auto', '1024x1024', '1024x1536', or '1536x1024'.
2999
3007
  */
3000
3008
  imageGeneration,
@@ -3383,6 +3391,7 @@ async function convertToOpenAIResponsesInput({
3383
3391
  toolNameMapping,
3384
3392
  systemMessageMode,
3385
3393
  providerOptionsName,
3394
+ explicitMessageItemType = false,
3386
3395
  fileIdPrefixes,
3387
3396
  passThroughUnsupportedFiles = false,
3388
3397
  store,
@@ -3394,7 +3403,7 @@ async function convertToOpenAIResponsesInput({
3394
3403
  toolSearchToolName,
3395
3404
  customProviderToolNames
3396
3405
  }) {
3397
- 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;
3406
+ 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;
3398
3407
  let input = [];
3399
3408
  const warnings = [];
3400
3409
  const processedApprovalIds = /* @__PURE__ */ new Set();
@@ -3414,6 +3423,7 @@ async function convertToOpenAIResponsesInput({
3414
3423
  providerOptionsName
3415
3424
  );
3416
3425
  input.push({
3426
+ ...explicitMessageItemType && { type: "message" },
3417
3427
  role: "system",
3418
3428
  content: promptCacheBreakpoint == null ? content : [
3419
3429
  {
@@ -3431,6 +3441,7 @@ async function convertToOpenAIResponsesInput({
3431
3441
  providerOptionsName
3432
3442
  );
3433
3443
  input.push({
3444
+ ...explicitMessageItemType && { type: "message" },
3434
3445
  role: "developer",
3435
3446
  content: promptCacheBreakpoint == null ? content : [
3436
3447
  {
@@ -3460,6 +3471,7 @@ async function convertToOpenAIResponsesInput({
3460
3471
  }
3461
3472
  case "user": {
3462
3473
  input.push({
3474
+ ...explicitMessageItemType && { type: "message" },
3463
3475
  role: "user",
3464
3476
  content: content.map((part, index) => {
3465
3477
  var _a3, _b2, _c2;
@@ -3541,6 +3553,7 @@ async function convertToOpenAIResponsesInput({
3541
3553
  break;
3542
3554
  }
3543
3555
  input.push({
3556
+ ...explicitMessageItemType && { type: "message" },
3544
3557
  role: "assistant",
3545
3558
  content: [{ type: "output_text", text: part.text }],
3546
3559
  id,
@@ -3579,6 +3592,7 @@ async function convertToOpenAIResponsesInput({
3579
3592
  }
3580
3593
  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;
3581
3594
  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;
3595
+ 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;
3582
3596
  if (hasConversation && id != null) {
3583
3597
  break;
3584
3598
  }
@@ -3602,7 +3616,7 @@ async function convertToOpenAIResponsesInput({
3602
3616
  type: "tool_search_call",
3603
3617
  id: id != null ? id : part.toolCallId,
3604
3618
  execution,
3605
- call_id: (_l = parsedInput.call_id) != null ? _l : null,
3619
+ call_id: (_q = parsedInput.call_id) != null ? _q : null,
3606
3620
  status: "completed",
3607
3621
  arguments: parsedInput.arguments
3608
3622
  });
@@ -3616,7 +3630,7 @@ async function convertToOpenAIResponsesInput({
3616
3630
  break;
3617
3631
  }
3618
3632
  }
3619
- const isProviderDefinedToolCall = hasLocalShellTool && resolvedToolName === "local_shell" || hasShellTool && resolvedToolName === "shell" || hasApplyPatchTool && resolvedToolName === "apply_patch" || ((_m = customProviderToolNames == null ? void 0 : customProviderToolNames.has(resolvedToolName)) != null ? _m : false);
3633
+ const isProviderDefinedToolCall = hasLocalShellTool && resolvedToolName === "local_shell" || hasShellTool && resolvedToolName === "shell" || hasApplyPatchTool && resolvedToolName === "apply_patch" || ((_r = customProviderToolNames == null ? void 0 : customProviderToolNames.has(resolvedToolName)) != null ? _r : false);
3620
3634
  if (hasPreviousResponseId && store && id != null && isProviderDefinedToolCall) {
3621
3635
  break;
3622
3636
  }
@@ -3682,6 +3696,7 @@ async function convertToOpenAIResponsesInput({
3682
3696
  call_id: part.toolCallId,
3683
3697
  name: resolvedToolName,
3684
3698
  input: typeof part.input === "string" ? part.input : JSON.stringify(part.input),
3699
+ ...isAsync != null && { async: isAsync },
3685
3700
  id
3686
3701
  });
3687
3702
  break;
@@ -3691,6 +3706,7 @@ async function convertToOpenAIResponsesInput({
3691
3706
  call_id: part.toolCallId,
3692
3707
  name: resolvedToolName,
3693
3708
  arguments: serializeToolCallArguments2(part.input),
3709
+ ...isAsync != null && { async: isAsync },
3694
3710
  ...namespace != null && { namespace }
3695
3711
  });
3696
3712
  break;
@@ -3707,7 +3723,7 @@ async function convertToOpenAIResponsesInput({
3707
3723
  part.toolName
3708
3724
  );
3709
3725
  if (part.toolName === toolSearchToolName) {
3710
- 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;
3726
+ 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;
3711
3727
  if (store) {
3712
3728
  input.push({ type: "item_reference", id: itemId });
3713
3729
  } else if (part.output.type === "json") {
@@ -3748,7 +3764,7 @@ async function convertToOpenAIResponsesInput({
3748
3764
  break;
3749
3765
  }
3750
3766
  if (store) {
3751
- const itemId = (_v = (_u = (_t = part.providerOptions) == null ? void 0 : _t[providerOptionsName]) == null ? void 0 : _u.itemId) != null ? _v : part.toolCallId;
3767
+ const itemId = (_A = (_z = (_y = part.providerOptions) == null ? void 0 : _y[providerOptionsName]) == null ? void 0 : _z.itemId) != null ? _A : part.toolCallId;
3752
3768
  input.push({ type: "item_reference", id: itemId });
3753
3769
  } else {
3754
3770
  warnings.push({
@@ -3915,7 +3931,7 @@ ${text}`,
3915
3931
  }
3916
3932
  const output = part.output;
3917
3933
  if (output.type === "execution-denied") {
3918
- const approvalId = (_x = (_w = output.providerOptions) == null ? void 0 : _w.openai) == null ? void 0 : _x.approvalId;
3934
+ const approvalId = (_C = (_B = output.providerOptions) == null ? void 0 : _B.openai) == null ? void 0 : _C.approvalId;
3919
3935
  if (approvalId) {
3920
3936
  continue;
3921
3937
  }
@@ -4002,7 +4018,7 @@ ${text}`,
4002
4018
  break;
4003
4019
  case "execution-denied":
4004
4020
  outputValue = convertScalarOutput(
4005
- (_y = output.reason) != null ? _y : "Tool call execution denied."
4021
+ (_D = output.reason) != null ? _D : "Tool call execution denied."
4006
4022
  );
4007
4023
  break;
4008
4024
  case "json":
@@ -4343,6 +4359,7 @@ var openaiResponsesChunkSchema = lazySchema20(
4343
4359
  call_id: z22.string(),
4344
4360
  name: z22.string(),
4345
4361
  arguments: z22.string(),
4362
+ async: z22.boolean().nullish(),
4346
4363
  namespace: z22.string().nullish()
4347
4364
  }),
4348
4365
  z22.object({
@@ -4418,7 +4435,8 @@ var openaiResponsesChunkSchema = lazySchema20(
4418
4435
  id: z22.string(),
4419
4436
  call_id: z22.string(),
4420
4437
  name: z22.string(),
4421
- input: z22.string()
4438
+ input: z22.string(),
4439
+ async: z22.boolean().nullish()
4422
4440
  }),
4423
4441
  z22.object({
4424
4442
  type: z22.literal("shell_call"),
@@ -4486,6 +4504,7 @@ var openaiResponsesChunkSchema = lazySchema20(
4486
4504
  call_id: z22.string(),
4487
4505
  name: z22.string(),
4488
4506
  arguments: z22.string(),
4507
+ async: z22.boolean().nullish(),
4489
4508
  status: z22.literal("completed"),
4490
4509
  namespace: z22.string().nullish()
4491
4510
  }),
@@ -4495,6 +4514,7 @@ var openaiResponsesChunkSchema = lazySchema20(
4495
4514
  call_id: z22.string(),
4496
4515
  name: z22.string(),
4497
4516
  input: z22.string(),
4517
+ async: z22.boolean().nullish(),
4498
4518
  status: z22.literal("completed")
4499
4519
  }),
4500
4520
  z22.object({
@@ -4928,6 +4948,7 @@ var openaiResponsesResponseSchema = lazySchema20(
4928
4948
  name: z22.string(),
4929
4949
  arguments: z22.string(),
4930
4950
  id: z22.string(),
4951
+ async: z22.boolean().nullish(),
4931
4952
  namespace: z22.string().nullish()
4932
4953
  }),
4933
4954
  z22.object({
@@ -4935,7 +4956,8 @@ var openaiResponsesResponseSchema = lazySchema20(
4935
4956
  call_id: z22.string(),
4936
4957
  name: z22.string(),
4937
4958
  input: z22.string(),
4938
- id: z22.string()
4959
+ id: z22.string(),
4960
+ async: z22.boolean().nullish()
4939
4961
  }),
4940
4962
  z22.object({
4941
4963
  type: z22.literal("computer_call"),
@@ -5372,7 +5394,8 @@ async function prepareResponsesTools({
5372
5394
  toolChoice,
5373
5395
  allowedTools,
5374
5396
  toolNameMapping,
5375
- customProviderToolNames
5397
+ customProviderToolNames,
5398
+ supportsAsyncToolCalling = true
5376
5399
  }) {
5377
5400
  var _a2, _b, _c, _d;
5378
5401
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
@@ -5403,7 +5426,13 @@ async function prepareResponsesTools({
5403
5426
  const openaiOptions = (_a2 = tool.providerOptions) == null ? void 0 : _a2.openai;
5404
5427
  const openaiFunctionTool = prepareFunctionTool({
5405
5428
  tool,
5406
- options: openaiOptions
5429
+ options: openaiOptions,
5430
+ async: resolveAsyncToolOption({
5431
+ value: openaiOptions == null ? void 0 : openaiOptions.async,
5432
+ supportsAsyncToolCalling,
5433
+ toolName: tool.name,
5434
+ toolWarnings
5435
+ })
5407
5436
  });
5408
5437
  const namespace = openaiOptions == null ? void 0 : openaiOptions.namespace;
5409
5438
  if (namespace == null) {
@@ -5585,6 +5614,12 @@ async function prepareResponsesTools({
5585
5614
  type: "custom",
5586
5615
  name: args.name,
5587
5616
  description: args.description,
5617
+ ...resolveAsyncToolOption({
5618
+ value: args.async,
5619
+ supportsAsyncToolCalling,
5620
+ toolName: args.name,
5621
+ toolWarnings
5622
+ }) != null ? { async: args.async } : {},
5588
5623
  format: args.format
5589
5624
  });
5590
5625
  resolvedCustomProviderToolNames.add(args.name);
@@ -5756,7 +5791,8 @@ function toAllowedToolResolution(tool) {
5756
5791
  }
5757
5792
  function prepareFunctionTool({
5758
5793
  tool,
5759
- options
5794
+ options,
5795
+ async
5760
5796
  }) {
5761
5797
  const deferLoading = options == null ? void 0 : options.deferLoading;
5762
5798
  return {
@@ -5764,10 +5800,27 @@ function prepareFunctionTool({
5764
5800
  name: tool.name,
5765
5801
  description: tool.description,
5766
5802
  parameters: tool.inputSchema,
5803
+ ...async != null ? { async } : {},
5767
5804
  ...tool.strict != null ? { strict: tool.strict } : {},
5768
5805
  ...deferLoading != null ? { defer_loading: deferLoading } : {}
5769
5806
  };
5770
5807
  }
5808
+ function resolveAsyncToolOption({
5809
+ value,
5810
+ supportsAsyncToolCalling,
5811
+ toolName,
5812
+ toolWarnings
5813
+ }) {
5814
+ if (value !== true || supportsAsyncToolCalling) {
5815
+ return value;
5816
+ }
5817
+ toolWarnings.push({
5818
+ type: "unsupported",
5819
+ feature: `async tool calling for "${toolName}"`,
5820
+ details: "Async tool calling is only supported by GPT-6 and later models."
5821
+ });
5822
+ return void 0;
5823
+ }
5771
5824
  function mapShellEnvironment(environment) {
5772
5825
  if (environment.type === "containerReference") {
5773
5826
  const env2 = environment;
@@ -5935,13 +5988,15 @@ var OpenAIResponsesLanguageModel = class {
5935
5988
  toolChoice,
5936
5989
  allowedTools: (_b = openaiOptions == null ? void 0 : openaiOptions.allowedTools) != null ? _b : void 0,
5937
5990
  toolNameMapping,
5938
- customProviderToolNames
5991
+ customProviderToolNames,
5992
+ supportsAsyncToolCalling: modelCapabilities.supportsAsyncToolCalling
5939
5993
  });
5940
5994
  const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
5941
5995
  prompt,
5942
5996
  toolNameMapping,
5943
5997
  systemMessageMode: (_c = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _c : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
5944
5998
  providerOptionsName,
5999
+ explicitMessageItemType: this.config.explicitMessageItemType,
5945
6000
  fileIdPrefixes: this.config.fileIdPrefixes,
5946
6001
  passThroughUnsupportedFiles: (_d = openaiOptions == null ? void 0 : openaiOptions.passThroughUnsupportedFiles) != null ? _d : false,
5947
6002
  store: (_e = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _e : true,
@@ -6445,6 +6500,7 @@ var OpenAIResponsesLanguageModel = class {
6445
6500
  providerMetadata: {
6446
6501
  [providerOptionsName]: {
6447
6502
  itemId: part.id,
6503
+ ...part.async != null && { async: part.async },
6448
6504
  ...part.namespace != null && { namespace: part.namespace }
6449
6505
  }
6450
6506
  }
@@ -6461,7 +6517,8 @@ var OpenAIResponsesLanguageModel = class {
6461
6517
  input: JSON.stringify(part.input),
6462
6518
  providerMetadata: {
6463
6519
  [providerOptionsName]: {
6464
- itemId: part.id
6520
+ itemId: part.id,
6521
+ ...part.async != null && { async: part.async }
6465
6522
  }
6466
6523
  }
6467
6524
  });
@@ -6749,7 +6806,8 @@ var OpenAIResponsesLanguageModel = class {
6749
6806
  toolName: value.item.name,
6750
6807
  toolCallId: value.item.call_id,
6751
6808
  suppressInputStreaming,
6752
- bufferedInputDeltas: suppressInputStreaming ? [] : void 0
6809
+ bufferedInputDeltas: suppressInputStreaming ? [] : void 0,
6810
+ async: value.item.async
6753
6811
  };
6754
6812
  if (!suppressInputStreaming) {
6755
6813
  controller.enqueue({
@@ -6764,7 +6822,8 @@ var OpenAIResponsesLanguageModel = class {
6764
6822
  );
6765
6823
  ongoingToolCalls[value.output_index] = {
6766
6824
  toolName,
6767
- toolCallId: value.item.call_id
6825
+ toolCallId: value.item.call_id,
6826
+ async: value.item.async
6768
6827
  };
6769
6828
  controller.enqueue({
6770
6829
  type: "tool-input-start",
@@ -7008,6 +7067,7 @@ var OpenAIResponsesLanguageModel = class {
7008
7067
  providerMetadata: {
7009
7068
  [providerOptionsName]: {
7010
7069
  itemId: item.id,
7070
+ ...item.async != null ? { async: item.async } : (ongoingToolCall == null ? void 0 : ongoingToolCall.async) != null ? { async: ongoingToolCall.async } : {},
7011
7071
  ...item.namespace != null && {
7012
7072
  namespace: item.namespace
7013
7073
  }
@@ -7052,6 +7112,7 @@ var OpenAIResponsesLanguageModel = class {
7052
7112
  }
7053
7113
  });
7054
7114
  } else if (value.item.type === "custom_tool_call") {
7115
+ const ongoingToolCall = ongoingToolCalls[value.output_index];
7055
7116
  ongoingToolCalls[value.output_index] = void 0;
7056
7117
  hasFunctionCall = true;
7057
7118
  const toolName = toolNameMapping.toCustomToolName(
@@ -7068,7 +7129,8 @@ var OpenAIResponsesLanguageModel = class {
7068
7129
  input: JSON.stringify(value.item.input),
7069
7130
  providerMetadata: {
7070
7131
  [providerOptionsName]: {
7071
- itemId: value.item.id
7132
+ itemId: value.item.id,
7133
+ ...value.item.async != null ? { async: value.item.async } : (ongoingToolCall == null ? void 0 : ongoingToolCall.async) != null ? { async: ongoingToolCall.async } : {}
7072
7134
  }
7073
7135
  }
7074
7136
  });
@@ -8164,7 +8226,7 @@ var OpenAITranscriptionModel = class {
8164
8226
  };
8165
8227
 
8166
8228
  // src/version.ts
8167
- var VERSION = true ? "3.0.109" : "0.0.0-test";
8229
+ var VERSION = true ? "3.0.111" : "0.0.0-test";
8168
8230
 
8169
8231
  // src/openai-provider.ts
8170
8232
  function createOpenAI(options = {}) {