@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.
@@ -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,
@@ -2082,6 +2083,10 @@ var modelMaxImagesPerCall = {
2082
2083
  "gpt-image-1-mini": 10,
2083
2084
  "gpt-image-1.5": 10,
2084
2085
  "gpt-image-2": 10,
2086
+ "gpt-image-2.5-flare": 10,
2087
+ "gpt-image-2.5-flare-2026-09-08": 10,
2088
+ "gpt-image-2.5-sunburst": 10,
2089
+ "gpt-image-2.5-sunburst-2026-09-08": 10,
2085
2090
  "chatgpt-image-latest": 10
2086
2091
  };
2087
2092
  var defaultResponseFormatPrefixes = ["chatgpt-image-", "gpt-image-"];
@@ -2098,9 +2103,10 @@ var baseImageModelOptionsObject = z9.object({
2098
2103
  /**
2099
2104
  * Quality of the generated image(s).
2100
2105
  *
2101
- * Valid values: `standard`, `hd`, `low`, `medium`, `high`, `auto`.
2106
+ * Valid values: `standard`, `hd`, `low`, `medium`, `high`, `xhigh`, `max`, `auto`.
2107
+ * `xhigh` and `max` are supported by GPT Image 2.5 models.
2102
2108
  */
2103
- quality: z9.enum(["standard", "hd", "low", "medium", "high", "auto"]).optional(),
2109
+ quality: z9.enum(["standard", "hd", "low", "medium", "high", "xhigh", "max", "auto"]).optional(),
2104
2110
  /**
2105
2111
  * Background behavior for the generated image(s).
2106
2112
  *
@@ -3274,6 +3280,7 @@ async function convertToOpenAIResponsesInput({
3274
3280
  toolNameMapping,
3275
3281
  systemMessageMode,
3276
3282
  providerOptionsName,
3283
+ explicitMessageItemType = false,
3277
3284
  fileIdPrefixes,
3278
3285
  passThroughUnsupportedFiles = false,
3279
3286
  store,
@@ -3285,7 +3292,7 @@ async function convertToOpenAIResponsesInput({
3285
3292
  toolSearchToolName,
3286
3293
  customProviderToolNames
3287
3294
  }) {
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;
3295
+ 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
3296
  let input = [];
3290
3297
  const warnings = [];
3291
3298
  const processedApprovalIds = /* @__PURE__ */ new Set();
@@ -3305,6 +3312,7 @@ async function convertToOpenAIResponsesInput({
3305
3312
  providerOptionsName
3306
3313
  );
3307
3314
  input.push({
3315
+ ...explicitMessageItemType && { type: "message" },
3308
3316
  role: "system",
3309
3317
  content: promptCacheBreakpoint == null ? content : [
3310
3318
  {
@@ -3322,6 +3330,7 @@ async function convertToOpenAIResponsesInput({
3322
3330
  providerOptionsName
3323
3331
  );
3324
3332
  input.push({
3333
+ ...explicitMessageItemType && { type: "message" },
3325
3334
  role: "developer",
3326
3335
  content: promptCacheBreakpoint == null ? content : [
3327
3336
  {
@@ -3351,6 +3360,7 @@ async function convertToOpenAIResponsesInput({
3351
3360
  }
3352
3361
  case "user": {
3353
3362
  input.push({
3363
+ ...explicitMessageItemType && { type: "message" },
3354
3364
  role: "user",
3355
3365
  content: content.map((part, index) => {
3356
3366
  var _a3, _b2, _c2;
@@ -3432,6 +3442,7 @@ async function convertToOpenAIResponsesInput({
3432
3442
  break;
3433
3443
  }
3434
3444
  input.push({
3445
+ ...explicitMessageItemType && { type: "message" },
3435
3446
  role: "assistant",
3436
3447
  content: [{ type: "output_text", text: part.text }],
3437
3448
  id,
@@ -3470,6 +3481,7 @@ async function convertToOpenAIResponsesInput({
3470
3481
  }
3471
3482
  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
3483
  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;
3484
+ 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
3485
  if (hasConversation && id != null) {
3474
3486
  break;
3475
3487
  }
@@ -3493,7 +3505,7 @@ async function convertToOpenAIResponsesInput({
3493
3505
  type: "tool_search_call",
3494
3506
  id: id != null ? id : part.toolCallId,
3495
3507
  execution,
3496
- call_id: (_l = parsedInput.call_id) != null ? _l : null,
3508
+ call_id: (_q = parsedInput.call_id) != null ? _q : null,
3497
3509
  status: "completed",
3498
3510
  arguments: parsedInput.arguments
3499
3511
  });
@@ -3507,7 +3519,7 @@ async function convertToOpenAIResponsesInput({
3507
3519
  break;
3508
3520
  }
3509
3521
  }
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);
3522
+ 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
3523
  if (hasPreviousResponseId && store && id != null && isProviderDefinedToolCall) {
3512
3524
  break;
3513
3525
  }
@@ -3573,6 +3585,7 @@ async function convertToOpenAIResponsesInput({
3573
3585
  call_id: part.toolCallId,
3574
3586
  name: resolvedToolName,
3575
3587
  input: typeof part.input === "string" ? part.input : JSON.stringify(part.input),
3588
+ ...isAsync != null && { async: isAsync },
3576
3589
  id
3577
3590
  });
3578
3591
  break;
@@ -3582,6 +3595,7 @@ async function convertToOpenAIResponsesInput({
3582
3595
  call_id: part.toolCallId,
3583
3596
  name: resolvedToolName,
3584
3597
  arguments: serializeToolCallArguments2(part.input),
3598
+ ...isAsync != null && { async: isAsync },
3585
3599
  ...namespace != null && { namespace }
3586
3600
  });
3587
3601
  break;
@@ -3598,7 +3612,7 @@ async function convertToOpenAIResponsesInput({
3598
3612
  part.toolName
3599
3613
  );
3600
3614
  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;
3615
+ 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
3616
  if (store) {
3603
3617
  input.push({ type: "item_reference", id: itemId });
3604
3618
  } else if (part.output.type === "json") {
@@ -3639,7 +3653,7 @@ async function convertToOpenAIResponsesInput({
3639
3653
  break;
3640
3654
  }
3641
3655
  if (store) {
3642
- const itemId = (_v = (_u = (_t = part.providerOptions) == null ? void 0 : _t[providerOptionsName]) == null ? void 0 : _u.itemId) != null ? _v : part.toolCallId;
3656
+ const itemId = (_A = (_z = (_y = part.providerOptions) == null ? void 0 : _y[providerOptionsName]) == null ? void 0 : _z.itemId) != null ? _A : part.toolCallId;
3643
3657
  input.push({ type: "item_reference", id: itemId });
3644
3658
  } else {
3645
3659
  warnings.push({
@@ -3806,7 +3820,7 @@ ${text}`,
3806
3820
  }
3807
3821
  const output = part.output;
3808
3822
  if (output.type === "execution-denied") {
3809
- const approvalId = (_x = (_w = output.providerOptions) == null ? void 0 : _w.openai) == null ? void 0 : _x.approvalId;
3823
+ const approvalId = (_C = (_B = output.providerOptions) == null ? void 0 : _B.openai) == null ? void 0 : _C.approvalId;
3810
3824
  if (approvalId) {
3811
3825
  continue;
3812
3826
  }
@@ -3893,7 +3907,7 @@ ${text}`,
3893
3907
  break;
3894
3908
  case "execution-denied":
3895
3909
  outputValue = convertScalarOutput(
3896
- (_y = output.reason) != null ? _y : "Tool call execution denied."
3910
+ (_D = output.reason) != null ? _D : "Tool call execution denied."
3897
3911
  );
3898
3912
  break;
3899
3913
  case "json":
@@ -4234,6 +4248,7 @@ var openaiResponsesChunkSchema = lazySchema16(
4234
4248
  call_id: z18.string(),
4235
4249
  name: z18.string(),
4236
4250
  arguments: z18.string(),
4251
+ async: z18.boolean().nullish(),
4237
4252
  namespace: z18.string().nullish()
4238
4253
  }),
4239
4254
  z18.object({
@@ -4309,7 +4324,8 @@ var openaiResponsesChunkSchema = lazySchema16(
4309
4324
  id: z18.string(),
4310
4325
  call_id: z18.string(),
4311
4326
  name: z18.string(),
4312
- input: z18.string()
4327
+ input: z18.string(),
4328
+ async: z18.boolean().nullish()
4313
4329
  }),
4314
4330
  z18.object({
4315
4331
  type: z18.literal("shell_call"),
@@ -4377,6 +4393,7 @@ var openaiResponsesChunkSchema = lazySchema16(
4377
4393
  call_id: z18.string(),
4378
4394
  name: z18.string(),
4379
4395
  arguments: z18.string(),
4396
+ async: z18.boolean().nullish(),
4380
4397
  status: z18.literal("completed"),
4381
4398
  namespace: z18.string().nullish()
4382
4399
  }),
@@ -4386,6 +4403,7 @@ var openaiResponsesChunkSchema = lazySchema16(
4386
4403
  call_id: z18.string(),
4387
4404
  name: z18.string(),
4388
4405
  input: z18.string(),
4406
+ async: z18.boolean().nullish(),
4389
4407
  status: z18.literal("completed")
4390
4408
  }),
4391
4409
  z18.object({
@@ -4819,6 +4837,7 @@ var openaiResponsesResponseSchema = lazySchema16(
4819
4837
  name: z18.string(),
4820
4838
  arguments: z18.string(),
4821
4839
  id: z18.string(),
4840
+ async: z18.boolean().nullish(),
4822
4841
  namespace: z18.string().nullish()
4823
4842
  }),
4824
4843
  z18.object({
@@ -4826,7 +4845,8 @@ var openaiResponsesResponseSchema = lazySchema16(
4826
4845
  call_id: z18.string(),
4827
4846
  name: z18.string(),
4828
4847
  input: z18.string(),
4829
- id: z18.string()
4848
+ id: z18.string(),
4849
+ async: z18.boolean().nullish()
4830
4850
  }),
4831
4851
  z18.object({
4832
4852
  type: z18.literal("computer_call"),
@@ -5381,7 +5401,7 @@ var imageGenerationArgsSchema = lazySchema20(
5381
5401
  outputCompression: z22.number().int().min(0).max(100).optional(),
5382
5402
  outputFormat: z22.enum(["png", "jpeg", "webp"]).optional(),
5383
5403
  partialImages: z22.number().int().min(0).max(3).optional(),
5384
- quality: z22.enum(["auto", "low", "medium", "high"]).optional(),
5404
+ quality: z22.enum(["auto", "low", "medium", "high", "xhigh", "max"]).optional(),
5385
5405
  size: z22.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]).optional()
5386
5406
  }).strict()
5387
5407
  )
@@ -5411,6 +5431,7 @@ var customArgsSchema = lazySchema21(
5411
5431
  z23.object({
5412
5432
  name: z23.string(),
5413
5433
  description: z23.string().optional(),
5434
+ async: z23.boolean().optional(),
5414
5435
  format: z23.union([
5415
5436
  z23.object({
5416
5437
  type: z23.literal("grammar"),
@@ -5615,7 +5636,8 @@ async function prepareResponsesTools({
5615
5636
  toolChoice,
5616
5637
  allowedTools,
5617
5638
  toolNameMapping,
5618
- customProviderToolNames
5639
+ customProviderToolNames,
5640
+ supportsAsyncToolCalling = true
5619
5641
  }) {
5620
5642
  var _a2, _b, _c, _d;
5621
5643
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
@@ -5646,7 +5668,13 @@ async function prepareResponsesTools({
5646
5668
  const openaiOptions = (_a2 = tool.providerOptions) == null ? void 0 : _a2.openai;
5647
5669
  const openaiFunctionTool = prepareFunctionTool({
5648
5670
  tool,
5649
- options: openaiOptions
5671
+ options: openaiOptions,
5672
+ async: resolveAsyncToolOption({
5673
+ value: openaiOptions == null ? void 0 : openaiOptions.async,
5674
+ supportsAsyncToolCalling,
5675
+ toolName: tool.name,
5676
+ toolWarnings
5677
+ })
5650
5678
  });
5651
5679
  const namespace = openaiOptions == null ? void 0 : openaiOptions.namespace;
5652
5680
  if (namespace == null) {
@@ -5828,6 +5856,12 @@ async function prepareResponsesTools({
5828
5856
  type: "custom",
5829
5857
  name: args.name,
5830
5858
  description: args.description,
5859
+ ...resolveAsyncToolOption({
5860
+ value: args.async,
5861
+ supportsAsyncToolCalling,
5862
+ toolName: args.name,
5863
+ toolWarnings
5864
+ }) != null ? { async: args.async } : {},
5831
5865
  format: args.format
5832
5866
  });
5833
5867
  resolvedCustomProviderToolNames.add(args.name);
@@ -5999,7 +6033,8 @@ function toAllowedToolResolution(tool) {
5999
6033
  }
6000
6034
  function prepareFunctionTool({
6001
6035
  tool,
6002
- options
6036
+ options,
6037
+ async
6003
6038
  }) {
6004
6039
  const deferLoading = options == null ? void 0 : options.deferLoading;
6005
6040
  return {
@@ -6007,10 +6042,27 @@ function prepareFunctionTool({
6007
6042
  name: tool.name,
6008
6043
  description: tool.description,
6009
6044
  parameters: tool.inputSchema,
6045
+ ...async != null ? { async } : {},
6010
6046
  ...tool.strict != null ? { strict: tool.strict } : {},
6011
6047
  ...deferLoading != null ? { defer_loading: deferLoading } : {}
6012
6048
  };
6013
6049
  }
6050
+ function resolveAsyncToolOption({
6051
+ value,
6052
+ supportsAsyncToolCalling,
6053
+ toolName,
6054
+ toolWarnings
6055
+ }) {
6056
+ if (value !== true || supportsAsyncToolCalling) {
6057
+ return value;
6058
+ }
6059
+ toolWarnings.push({
6060
+ type: "unsupported",
6061
+ feature: `async tool calling for "${toolName}"`,
6062
+ details: "Async tool calling is only supported by GPT-6 and later models."
6063
+ });
6064
+ return void 0;
6065
+ }
6014
6066
  function mapShellEnvironment(environment) {
6015
6067
  if (environment.type === "containerReference") {
6016
6068
  const env2 = environment;
@@ -6178,13 +6230,15 @@ var OpenAIResponsesLanguageModel = class {
6178
6230
  toolChoice,
6179
6231
  allowedTools: (_b = openaiOptions == null ? void 0 : openaiOptions.allowedTools) != null ? _b : void 0,
6180
6232
  toolNameMapping,
6181
- customProviderToolNames
6233
+ customProviderToolNames,
6234
+ supportsAsyncToolCalling: modelCapabilities.supportsAsyncToolCalling
6182
6235
  });
6183
6236
  const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
6184
6237
  prompt,
6185
6238
  toolNameMapping,
6186
6239
  systemMessageMode: (_c = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _c : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
6187
6240
  providerOptionsName,
6241
+ explicitMessageItemType: this.config.explicitMessageItemType,
6188
6242
  fileIdPrefixes: this.config.fileIdPrefixes,
6189
6243
  passThroughUnsupportedFiles: (_d = openaiOptions == null ? void 0 : openaiOptions.passThroughUnsupportedFiles) != null ? _d : false,
6190
6244
  store: (_e = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _e : true,
@@ -6688,6 +6742,7 @@ var OpenAIResponsesLanguageModel = class {
6688
6742
  providerMetadata: {
6689
6743
  [providerOptionsName]: {
6690
6744
  itemId: part.id,
6745
+ ...part.async != null && { async: part.async },
6691
6746
  ...part.namespace != null && { namespace: part.namespace }
6692
6747
  }
6693
6748
  }
@@ -6704,7 +6759,8 @@ var OpenAIResponsesLanguageModel = class {
6704
6759
  input: JSON.stringify(part.input),
6705
6760
  providerMetadata: {
6706
6761
  [providerOptionsName]: {
6707
- itemId: part.id
6762
+ itemId: part.id,
6763
+ ...part.async != null && { async: part.async }
6708
6764
  }
6709
6765
  }
6710
6766
  });
@@ -6992,7 +7048,8 @@ var OpenAIResponsesLanguageModel = class {
6992
7048
  toolName: value.item.name,
6993
7049
  toolCallId: value.item.call_id,
6994
7050
  suppressInputStreaming,
6995
- bufferedInputDeltas: suppressInputStreaming ? [] : void 0
7051
+ bufferedInputDeltas: suppressInputStreaming ? [] : void 0,
7052
+ async: value.item.async
6996
7053
  };
6997
7054
  if (!suppressInputStreaming) {
6998
7055
  controller.enqueue({
@@ -7007,7 +7064,8 @@ var OpenAIResponsesLanguageModel = class {
7007
7064
  );
7008
7065
  ongoingToolCalls[value.output_index] = {
7009
7066
  toolName,
7010
- toolCallId: value.item.call_id
7067
+ toolCallId: value.item.call_id,
7068
+ async: value.item.async
7011
7069
  };
7012
7070
  controller.enqueue({
7013
7071
  type: "tool-input-start",
@@ -7251,6 +7309,7 @@ var OpenAIResponsesLanguageModel = class {
7251
7309
  providerMetadata: {
7252
7310
  [providerOptionsName]: {
7253
7311
  itemId: item.id,
7312
+ ...item.async != null ? { async: item.async } : (ongoingToolCall == null ? void 0 : ongoingToolCall.async) != null ? { async: ongoingToolCall.async } : {},
7254
7313
  ...item.namespace != null && {
7255
7314
  namespace: item.namespace
7256
7315
  }
@@ -7295,6 +7354,7 @@ var OpenAIResponsesLanguageModel = class {
7295
7354
  }
7296
7355
  });
7297
7356
  } else if (value.item.type === "custom_tool_call") {
7357
+ const ongoingToolCall = ongoingToolCalls[value.output_index];
7298
7358
  ongoingToolCalls[value.output_index] = void 0;
7299
7359
  hasFunctionCall = true;
7300
7360
  const toolName = toolNameMapping.toCustomToolName(
@@ -7311,7 +7371,8 @@ var OpenAIResponsesLanguageModel = class {
7311
7371
  input: JSON.stringify(value.item.input),
7312
7372
  providerMetadata: {
7313
7373
  [providerOptionsName]: {
7314
- itemId: value.item.id
7374
+ itemId: value.item.id,
7375
+ ...value.item.async != null ? { async: value.item.async } : (ongoingToolCall == null ? void 0 : ongoingToolCall.async) != null ? { async: ongoingToolCall.async } : {}
7315
7376
  }
7316
7377
  }
7317
7378
  });