@ai-sdk/openai 3.0.98 → 3.0.100

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
@@ -27,7 +27,7 @@ __export(index_exports, {
27
27
  module.exports = __toCommonJS(index_exports);
28
28
 
29
29
  // src/openai-provider.ts
30
- var import_provider_utils36 = require("@ai-sdk/provider-utils");
30
+ var import_provider_utils37 = require("@ai-sdk/provider-utils");
31
31
 
32
32
  // src/chat/openai-chat-language-model.ts
33
33
  var import_provider4 = require("@ai-sdk/provider");
@@ -2932,8 +2932,8 @@ var openaiTools = {
2932
2932
  };
2933
2933
 
2934
2934
  // src/responses/openai-responses-language-model.ts
2935
- var import_provider9 = require("@ai-sdk/provider");
2936
- var import_provider_utils30 = require("@ai-sdk/provider-utils");
2935
+ var import_provider10 = require("@ai-sdk/provider");
2936
+ var import_provider_utils31 = require("@ai-sdk/provider-utils");
2937
2937
 
2938
2938
  // src/responses/convert-openai-responses-usage.ts
2939
2939
  function convertOpenAIResponsesUsage(usage) {
@@ -2976,12 +2976,229 @@ function convertOpenAIResponsesUsage(usage) {
2976
2976
  }
2977
2977
 
2978
2978
  // src/responses/convert-to-openai-responses-input.ts
2979
+ var import_provider8 = require("@ai-sdk/provider");
2980
+ var import_provider_utils27 = require("@ai-sdk/provider-utils");
2981
+ var import_v421 = require("zod/v4");
2982
+
2983
+ // src/responses/expand-parallel-tool-call.ts
2979
2984
  var import_provider7 = require("@ai-sdk/provider");
2980
2985
  var import_provider_utils26 = require("@ai-sdk/provider-utils");
2981
- var import_v421 = require("zod/v4");
2986
+ var parallelToolName = "parallel";
2987
+ var recipientNamePrefix = "functions.";
2988
+ function getParallelToolCallMetadata({
2989
+ providerOptions,
2990
+ providerOptionsName
2991
+ }) {
2992
+ var _a;
2993
+ const metadata = (_a = providerOptions == null ? void 0 : providerOptions[providerOptionsName]) == null ? void 0 : _a.parallelToolCall;
2994
+ if (!(0, import_provider7.isJSONObject)(metadata) || typeof metadata.itemId !== "string" || typeof metadata.toolCallId !== "string" || typeof metadata.toolName !== "string" || typeof metadata.input !== "string" || typeof metadata.index !== "number" || !Number.isInteger(metadata.index) || typeof metadata.count !== "number" || !Number.isInteger(metadata.count) || metadata.index < 0 || metadata.count <= metadata.index) {
2995
+ return void 0;
2996
+ }
2997
+ return metadata;
2998
+ }
2999
+ function isUndeclaredParallelToolCall({
3000
+ toolName,
3001
+ tools
3002
+ }) {
3003
+ return toolName === parallelToolName && !tools.some((tool) => tool.name === parallelToolName);
3004
+ }
3005
+ async function expandParallelToolCall({
3006
+ toolCall,
3007
+ tools,
3008
+ providerOptionsName,
3009
+ itemId
3010
+ }) {
3011
+ if (!isUndeclaredParallelToolCall({ toolName: toolCall.toolName, tools })) {
3012
+ return void 0;
3013
+ }
3014
+ const parsedInput = await (0, import_provider_utils26.safeParseJSON)({ text: toolCall.input });
3015
+ if (!parsedInput.success || !(0, import_provider7.isJSONObject)(parsedInput.value)) {
3016
+ return void 0;
3017
+ }
3018
+ const toolUses = parsedInput.value.tool_uses;
3019
+ if (!Array.isArray(toolUses) || toolUses.length === 0) {
3020
+ return void 0;
3021
+ }
3022
+ const availableToolNames = new Set(tools.map((tool) => tool.name));
3023
+ const expandedToolCalls = [];
3024
+ for (const [index, toolUse] of toolUses.entries()) {
3025
+ if (!(0, import_provider7.isJSONObject)(toolUse)) {
3026
+ return void 0;
3027
+ }
3028
+ const recipientName = toolUse.recipient_name;
3029
+ const parameters = toolUse.parameters;
3030
+ if (typeof recipientName !== "string" || !recipientName.startsWith(recipientNamePrefix) || !(0, import_provider7.isJSONObject)(parameters)) {
3031
+ return void 0;
3032
+ }
3033
+ const toolName = recipientName.slice(recipientNamePrefix.length);
3034
+ if (toolName.length === 0 || !availableToolNames.has(toolName)) {
3035
+ return void 0;
3036
+ }
3037
+ expandedToolCalls.push({
3038
+ type: "tool-call",
3039
+ toolCallId: `${toolCall.toolCallId}_${index}`,
3040
+ toolName,
3041
+ input: JSON.stringify(parameters),
3042
+ providerMetadata: {
3043
+ [providerOptionsName]: {
3044
+ parallelToolCall: {
3045
+ itemId,
3046
+ toolCallId: toolCall.toolCallId,
3047
+ toolName: toolCall.toolName,
3048
+ input: toolCall.input,
3049
+ index,
3050
+ count: toolUses.length
3051
+ }
3052
+ }
3053
+ }
3054
+ });
3055
+ }
3056
+ return expandedToolCalls;
3057
+ }
3058
+
3059
+ // src/responses/convert-to-openai-responses-input.ts
2982
3060
  function serializeToolCallArguments2(input) {
2983
3061
  return JSON.stringify(input === void 0 ? {} : input);
2984
3062
  }
3063
+ async function convertFunctionToolResultOutput({
3064
+ output,
3065
+ providerOptionsName,
3066
+ warnings
3067
+ }) {
3068
+ var _a;
3069
+ switch (output.type) {
3070
+ case "text":
3071
+ case "error-text":
3072
+ return output.value;
3073
+ case "execution-denied":
3074
+ return (_a = output.reason) != null ? _a : "Tool call execution denied.";
3075
+ case "json":
3076
+ case "error-json":
3077
+ return JSON.stringify(output.value);
3078
+ case "content":
3079
+ return output.value.map((item) => {
3080
+ var _a2, _b, _c, _d, _e;
3081
+ const promptCacheBreakpoint = getPromptCacheBreakpoint2(
3082
+ item.providerOptions,
3083
+ providerOptionsName
3084
+ );
3085
+ switch (item.type) {
3086
+ case "text": {
3087
+ return {
3088
+ type: "input_text",
3089
+ text: item.text,
3090
+ ...promptCacheBreakpoint != null && {
3091
+ prompt_cache_breakpoint: promptCacheBreakpoint
3092
+ }
3093
+ };
3094
+ }
3095
+ case "image-data": {
3096
+ return {
3097
+ type: "input_image",
3098
+ image_url: `data:${item.mediaType};base64,${item.data}`,
3099
+ detail: (_b = (_a2 = item.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b.imageDetail,
3100
+ ...promptCacheBreakpoint != null && {
3101
+ prompt_cache_breakpoint: promptCacheBreakpoint
3102
+ }
3103
+ };
3104
+ }
3105
+ case "image-url": {
3106
+ return {
3107
+ type: "input_image",
3108
+ image_url: item.url,
3109
+ detail: (_d = (_c = item.providerOptions) == null ? void 0 : _c[providerOptionsName]) == null ? void 0 : _d.imageDetail,
3110
+ ...promptCacheBreakpoint != null && {
3111
+ prompt_cache_breakpoint: promptCacheBreakpoint
3112
+ }
3113
+ };
3114
+ }
3115
+ case "file-data": {
3116
+ return {
3117
+ type: "input_file",
3118
+ filename: (_e = item.filename) != null ? _e : "data",
3119
+ file_data: `data:${item.mediaType};base64,${item.data}`,
3120
+ ...promptCacheBreakpoint != null && {
3121
+ prompt_cache_breakpoint: promptCacheBreakpoint
3122
+ }
3123
+ };
3124
+ }
3125
+ case "file-url": {
3126
+ return {
3127
+ type: "input_file",
3128
+ file_url: item.url,
3129
+ ...promptCacheBreakpoint != null && {
3130
+ prompt_cache_breakpoint: promptCacheBreakpoint
3131
+ }
3132
+ };
3133
+ }
3134
+ default: {
3135
+ warnings.push({
3136
+ type: "other",
3137
+ message: `unsupported tool content part type: ${item.type}`
3138
+ });
3139
+ return void 0;
3140
+ }
3141
+ }
3142
+ }).filter(import_provider_utils27.isNonNullable);
3143
+ }
3144
+ }
3145
+ function hasSameParallelToolCall(first, second) {
3146
+ return first.itemId === second.itemId && first.toolCallId === second.toolCallId && first.toolName === second.toolName && first.input === second.input && first.count === second.count;
3147
+ }
3148
+ function collectCompleteParallelToolResultGroups({
3149
+ prompt,
3150
+ providerOptionsName
3151
+ }) {
3152
+ const pendingGroups = /* @__PURE__ */ new Map();
3153
+ for (const message of prompt) {
3154
+ if (message.role !== "tool") {
3155
+ continue;
3156
+ }
3157
+ for (const part of message.content) {
3158
+ if (part.type !== "tool-result") {
3159
+ continue;
3160
+ }
3161
+ const metadata = getParallelToolCallMetadata({
3162
+ providerOptions: part.providerOptions,
3163
+ providerOptionsName
3164
+ });
3165
+ if (metadata == null) {
3166
+ continue;
3167
+ }
3168
+ const existing = pendingGroups.get(metadata.toolCallId);
3169
+ if (existing == null) {
3170
+ pendingGroups.set(metadata.toolCallId, {
3171
+ metadata,
3172
+ results: /* @__PURE__ */ new Map([[metadata.index, part]]),
3173
+ invalid: false
3174
+ });
3175
+ continue;
3176
+ }
3177
+ if (!hasSameParallelToolCall(existing.metadata, metadata) || existing.results.has(metadata.index)) {
3178
+ existing.invalid = true;
3179
+ continue;
3180
+ }
3181
+ existing.results.set(metadata.index, part);
3182
+ }
3183
+ }
3184
+ const completeGroups = /* @__PURE__ */ new Map();
3185
+ for (const [toolCallId, group] of pendingGroups) {
3186
+ if (group.invalid || group.results.size !== group.metadata.count) {
3187
+ continue;
3188
+ }
3189
+ const results = Array.from(
3190
+ { length: group.metadata.count },
3191
+ (_, index) => group.results.get(index)
3192
+ );
3193
+ if (results.every(import_provider_utils27.isNonNullable)) {
3194
+ completeGroups.set(toolCallId, {
3195
+ metadata: group.metadata,
3196
+ results
3197
+ });
3198
+ }
3199
+ }
3200
+ return completeGroups;
3201
+ }
2985
3202
  function getPromptCacheBreakpoint2(providerOptions, providerOptionsName) {
2986
3203
  var _a;
2987
3204
  return (_a = providerOptions == null ? void 0 : providerOptions[providerOptionsName]) == null ? void 0 : _a.promptCacheBreakpoint;
@@ -3005,10 +3222,16 @@ async function convertToOpenAIResponsesInput({
3005
3222
  hasApplyPatchTool = false,
3006
3223
  customProviderToolNames
3007
3224
  }) {
3008
- var _a, _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;
3225
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
3009
3226
  let input = [];
3010
3227
  const warnings = [];
3011
3228
  const processedApprovalIds = /* @__PURE__ */ new Set();
3229
+ const parallelToolResultGroups = hasConversation || hasPreviousResponseId ? collectCompleteParallelToolResultGroups({
3230
+ prompt,
3231
+ providerOptionsName
3232
+ }) : /* @__PURE__ */ new Map();
3233
+ const emittedParallelToolCalls = /* @__PURE__ */ new Set();
3234
+ const emittedParallelToolResults = /* @__PURE__ */ new Set();
3012
3235
  for (const { role, content, providerOptions } of prompt) {
3013
3236
  switch (role) {
3014
3237
  case "system": {
@@ -3092,7 +3315,7 @@ async function convertToOpenAIResponsesInput({
3092
3315
  return {
3093
3316
  type: "input_image",
3094
3317
  ...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
3095
- image_url: `data:${mediaType};base64,${(0, import_provider_utils26.convertToBase64)(part.data)}`
3318
+ image_url: `data:${mediaType};base64,${(0, import_provider_utils27.convertToBase64)(part.data)}`
3096
3319
  },
3097
3320
  detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail,
3098
3321
  ...promptCacheBreakpoint != null && {
@@ -3110,7 +3333,7 @@ async function convertToOpenAIResponsesInput({
3110
3333
  };
3111
3334
  }
3112
3335
  if (mediaType !== "application/pdf" && !passThroughUnsupportedFiles) {
3113
- throw new import_provider7.UnsupportedFunctionalityError({
3336
+ throw new import_provider8.UnsupportedFunctionalityError({
3114
3337
  functionality: `file part media type ${mediaType}`
3115
3338
  });
3116
3339
  }
@@ -3118,7 +3341,7 @@ async function convertToOpenAIResponsesInput({
3118
3341
  type: "input_file",
3119
3342
  ...typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
3120
3343
  filename: (_c2 = part.filename) != null ? _c2 : mediaType === "application/pdf" ? `part-${index}.pdf` : `part-${index}`,
3121
- file_data: `data:${mediaType};base64,${(0, import_provider_utils26.convertToBase64)(part.data)}`
3344
+ file_data: `data:${mediaType};base64,${(0, import_provider_utils27.convertToBase64)(part.data)}`
3122
3345
  },
3123
3346
  ...promptCacheBreakpoint != null && {
3124
3347
  prompt_cache_breakpoint: promptCacheBreakpoint
@@ -3154,6 +3377,34 @@ async function convertToOpenAIResponsesInput({
3154
3377
  break;
3155
3378
  }
3156
3379
  case "tool-call": {
3380
+ const parallelToolCallMetadata = getParallelToolCallMetadata({
3381
+ providerOptions: part.providerOptions,
3382
+ providerOptionsName
3383
+ });
3384
+ const parallelToolResultGroup = parallelToolCallMetadata == null ? void 0 : parallelToolResultGroups.get(
3385
+ parallelToolCallMetadata.toolCallId
3386
+ );
3387
+ if (parallelToolCallMetadata != null && parallelToolResultGroup != null && hasSameParallelToolCall(
3388
+ parallelToolResultGroup.metadata,
3389
+ parallelToolCallMetadata
3390
+ )) {
3391
+ if (!emittedParallelToolCalls.has(
3392
+ parallelToolResultGroup.metadata.toolCallId
3393
+ )) {
3394
+ emittedParallelToolCalls.add(
3395
+ parallelToolResultGroup.metadata.toolCallId
3396
+ );
3397
+ if (!hasConversation) {
3398
+ input.push({
3399
+ type: "function_call",
3400
+ call_id: parallelToolResultGroup.metadata.toolCallId,
3401
+ name: parallelToolResultGroup.metadata.toolName,
3402
+ arguments: parallelToolResultGroup.metadata.input
3403
+ });
3404
+ }
3405
+ }
3406
+ break;
3407
+ }
3157
3408
  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;
3158
3409
  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;
3159
3410
  if (hasConversation && id != null) {
@@ -3167,10 +3418,10 @@ async function convertToOpenAIResponsesInput({
3167
3418
  input.push({ type: "item_reference", id });
3168
3419
  break;
3169
3420
  }
3170
- const parsedInput = typeof part.input === "string" ? await (0, import_provider_utils26.parseJSON)({
3421
+ const parsedInput = typeof part.input === "string" ? await (0, import_provider_utils27.parseJSON)({
3171
3422
  text: part.input,
3172
3423
  schema: toolSearchInputSchema
3173
- }) : await (0, import_provider_utils26.validateTypes)({
3424
+ }) : await (0, import_provider_utils27.validateTypes)({
3174
3425
  value: part.input,
3175
3426
  schema: toolSearchInputSchema
3176
3427
  });
@@ -3202,7 +3453,7 @@ async function convertToOpenAIResponsesInput({
3202
3453
  break;
3203
3454
  }
3204
3455
  if (hasLocalShellTool && resolvedToolName === "local_shell") {
3205
- const parsedInput = await (0, import_provider_utils26.validateTypes)({
3456
+ const parsedInput = await (0, import_provider_utils27.validateTypes)({
3206
3457
  value: part.input,
3207
3458
  schema: localShellInputSchema
3208
3459
  });
@@ -3222,7 +3473,7 @@ async function convertToOpenAIResponsesInput({
3222
3473
  break;
3223
3474
  }
3224
3475
  if (hasShellTool && resolvedToolName === "shell") {
3225
- const parsedInput = await (0, import_provider_utils26.validateTypes)({
3476
+ const parsedInput = await (0, import_provider_utils27.validateTypes)({
3226
3477
  value: part.input,
3227
3478
  schema: shellInputSchema
3228
3479
  });
@@ -3240,7 +3491,7 @@ async function convertToOpenAIResponsesInput({
3240
3491
  break;
3241
3492
  }
3242
3493
  if (hasApplyPatchTool && resolvedToolName === "apply_patch") {
3243
- const parsedInput = await (0, import_provider_utils26.validateTypes)({
3494
+ const parsedInput = await (0, import_provider_utils27.validateTypes)({
3244
3495
  value: part.input,
3245
3496
  schema: applyPatchInputSchema
3246
3497
  });
@@ -3288,7 +3539,7 @@ async function convertToOpenAIResponsesInput({
3288
3539
  if (store) {
3289
3540
  input.push({ type: "item_reference", id: itemId });
3290
3541
  } else if (part.output.type === "json") {
3291
- const parsedOutput = await (0, import_provider_utils26.validateTypes)({
3542
+ const parsedOutput = await (0, import_provider_utils27.validateTypes)({
3292
3543
  value: part.output.value,
3293
3544
  schema: toolSearchOutputSchema
3294
3545
  });
@@ -3305,7 +3556,7 @@ async function convertToOpenAIResponsesInput({
3305
3556
  }
3306
3557
  if (hasShellTool && resolvedResultToolName === "shell") {
3307
3558
  if (part.output.type === "json") {
3308
- const parsedOutput = await (0, import_provider_utils26.validateTypes)({
3559
+ const parsedOutput = await (0, import_provider_utils27.validateTypes)({
3309
3560
  value: part.output.value,
3310
3561
  schema: shellOutputSchema
3311
3562
  });
@@ -3336,7 +3587,7 @@ async function convertToOpenAIResponsesInput({
3336
3587
  break;
3337
3588
  }
3338
3589
  case "reasoning": {
3339
- const providerOptions2 = await (0, import_provider_utils26.parseProviderOptions)({
3590
+ const providerOptions2 = await (0, import_provider_utils27.parseProviderOptions)({
3340
3591
  provider: providerOptionsName,
3341
3592
  providerOptions: part.providerOptions,
3342
3593
  schema: openaiResponsesReasoningProviderOptionsSchema
@@ -3433,6 +3684,44 @@ async function convertToOpenAIResponsesInput({
3433
3684
  });
3434
3685
  continue;
3435
3686
  }
3687
+ const parallelToolCallMetadata = getParallelToolCallMetadata({
3688
+ providerOptions: part.providerOptions,
3689
+ providerOptionsName
3690
+ });
3691
+ const parallelToolResultGroup = parallelToolCallMetadata == null ? void 0 : parallelToolResultGroups.get(
3692
+ parallelToolCallMetadata.toolCallId
3693
+ );
3694
+ if (parallelToolCallMetadata != null && parallelToolResultGroup != null && hasSameParallelToolCall(
3695
+ parallelToolResultGroup.metadata,
3696
+ parallelToolCallMetadata
3697
+ )) {
3698
+ if (!emittedParallelToolResults.has(
3699
+ parallelToolResultGroup.metadata.toolCallId
3700
+ )) {
3701
+ emittedParallelToolResults.add(
3702
+ parallelToolResultGroup.metadata.toolCallId
3703
+ );
3704
+ const toolOutputs = await Promise.all(
3705
+ parallelToolResultGroup.results.map(
3706
+ async (result) => convertFunctionToolResultOutput({
3707
+ output: result.output,
3708
+ providerOptionsName,
3709
+ warnings
3710
+ })
3711
+ )
3712
+ );
3713
+ input.push({
3714
+ type: "function_call_output",
3715
+ call_id: parallelToolResultGroup.metadata.toolCallId,
3716
+ // The internal wrapper returns one output containing the child
3717
+ // results in the same order as the original tool_uses array.
3718
+ output: toolOutputs.map(
3719
+ (output2) => typeof output2 === "string" ? output2 : JSON.stringify(output2)
3720
+ ).join("\n")
3721
+ });
3722
+ }
3723
+ continue;
3724
+ }
3436
3725
  const output = part.output;
3437
3726
  if (output.type === "execution-denied") {
3438
3727
  const approvalId = (_x = (_w = output.providerOptions) == null ? void 0 : _w.openai) == null ? void 0 : _x.approvalId;
@@ -3444,7 +3733,7 @@ async function convertToOpenAIResponsesInput({
3444
3733
  part.toolName
3445
3734
  );
3446
3735
  if (resolvedToolName === "tool_search" && output.type === "json") {
3447
- const parsedOutput = await (0, import_provider_utils26.validateTypes)({
3736
+ const parsedOutput = await (0, import_provider_utils27.validateTypes)({
3448
3737
  value: output.value,
3449
3738
  schema: toolSearchOutputSchema
3450
3739
  });
@@ -3458,7 +3747,7 @@ async function convertToOpenAIResponsesInput({
3458
3747
  continue;
3459
3748
  }
3460
3749
  if (hasLocalShellTool && resolvedToolName === "local_shell" && output.type === "json") {
3461
- const parsedOutput = await (0, import_provider_utils26.validateTypes)({
3750
+ const parsedOutput = await (0, import_provider_utils27.validateTypes)({
3462
3751
  value: output.value,
3463
3752
  schema: localShellOutputSchema
3464
3753
  });
@@ -3470,7 +3759,7 @@ async function convertToOpenAIResponsesInput({
3470
3759
  continue;
3471
3760
  }
3472
3761
  if (hasShellTool && resolvedToolName === "shell" && output.type === "json") {
3473
- const parsedOutput = await (0, import_provider_utils26.validateTypes)({
3762
+ const parsedOutput = await (0, import_provider_utils27.validateTypes)({
3474
3763
  value: output.value,
3475
3764
  schema: shellOutputSchema
3476
3765
  });
@@ -3489,7 +3778,7 @@ async function convertToOpenAIResponsesInput({
3489
3778
  continue;
3490
3779
  }
3491
3780
  if (hasApplyPatchTool && part.toolName === "apply_patch" && output.type === "json") {
3492
- const parsedOutput = await (0, import_provider_utils26.validateTypes)({
3781
+ const parsedOutput = await (0, import_provider_utils27.validateTypes)({
3493
3782
  value: output.value,
3494
3783
  schema: applyPatchOutputSchema
3495
3784
  });
@@ -3573,7 +3862,7 @@ async function convertToOpenAIResponsesInput({
3573
3862
  });
3574
3863
  return void 0;
3575
3864
  }
3576
- }).filter(import_provider_utils26.isNonNullable);
3865
+ }).filter(import_provider_utils27.isNonNullable);
3577
3866
  break;
3578
3867
  default:
3579
3868
  outputValue = "";
@@ -3585,86 +3874,11 @@ async function convertToOpenAIResponsesInput({
3585
3874
  });
3586
3875
  continue;
3587
3876
  }
3588
- let contentValue;
3589
- switch (output.type) {
3590
- case "text":
3591
- case "error-text":
3592
- contentValue = output.value;
3593
- break;
3594
- case "execution-denied":
3595
- contentValue = (_z = output.reason) != null ? _z : "Tool call execution denied.";
3596
- break;
3597
- case "json":
3598
- case "error-json":
3599
- contentValue = JSON.stringify(output.value);
3600
- break;
3601
- case "content":
3602
- contentValue = output.value.map((item) => {
3603
- var _a2, _b2, _c2, _d2, _e2;
3604
- const promptCacheBreakpoint = getPromptCacheBreakpoint2(
3605
- item.providerOptions,
3606
- providerOptionsName
3607
- );
3608
- switch (item.type) {
3609
- case "text": {
3610
- return {
3611
- type: "input_text",
3612
- text: item.text,
3613
- ...promptCacheBreakpoint != null && {
3614
- prompt_cache_breakpoint: promptCacheBreakpoint
3615
- }
3616
- };
3617
- }
3618
- case "image-data": {
3619
- return {
3620
- type: "input_image",
3621
- image_url: `data:${item.mediaType};base64,${item.data}`,
3622
- detail: (_b2 = (_a2 = item.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail,
3623
- ...promptCacheBreakpoint != null && {
3624
- prompt_cache_breakpoint: promptCacheBreakpoint
3625
- }
3626
- };
3627
- }
3628
- case "image-url": {
3629
- return {
3630
- type: "input_image",
3631
- image_url: item.url,
3632
- detail: (_d2 = (_c2 = item.providerOptions) == null ? void 0 : _c2[providerOptionsName]) == null ? void 0 : _d2.imageDetail,
3633
- ...promptCacheBreakpoint != null && {
3634
- prompt_cache_breakpoint: promptCacheBreakpoint
3635
- }
3636
- };
3637
- }
3638
- case "file-data": {
3639
- return {
3640
- type: "input_file",
3641
- filename: (_e2 = item.filename) != null ? _e2 : "data",
3642
- file_data: `data:${item.mediaType};base64,${item.data}`,
3643
- ...promptCacheBreakpoint != null && {
3644
- prompt_cache_breakpoint: promptCacheBreakpoint
3645
- }
3646
- };
3647
- }
3648
- case "file-url": {
3649
- return {
3650
- type: "input_file",
3651
- file_url: item.url,
3652
- ...promptCacheBreakpoint != null && {
3653
- prompt_cache_breakpoint: promptCacheBreakpoint
3654
- }
3655
- };
3656
- }
3657
- default: {
3658
- warnings.push({
3659
- type: "other",
3660
- message: `unsupported tool content part type: ${item.type}`
3661
- });
3662
- return void 0;
3663
- }
3664
- }
3665
- }).filter(import_provider_utils26.isNonNullable);
3666
- break;
3667
- }
3877
+ const contentValue = await convertFunctionToolResultOutput({
3878
+ output,
3879
+ providerOptionsName,
3880
+ warnings
3881
+ });
3668
3882
  input.push({
3669
3883
  type: "function_call_output",
3670
3884
  call_id: part.toolCallId,
@@ -3716,7 +3930,7 @@ function mapOpenAIResponseFinishReason({
3716
3930
  }
3717
3931
 
3718
3932
  // src/responses/openai-responses-api.ts
3719
- var import_provider_utils27 = require("@ai-sdk/provider-utils");
3933
+ var import_provider_utils28 = require("@ai-sdk/provider-utils");
3720
3934
  var import_v422 = require("zod/v4");
3721
3935
  var jsonValueSchema2 = import_v422.z.lazy(
3722
3936
  () => import_v422.z.union([
@@ -3745,8 +3959,8 @@ var openaiResponsesErrorChunkSchema = import_v422.z.object({
3745
3959
  message: import_v422.z.string(),
3746
3960
  param: import_v422.z.string().nullish()
3747
3961
  });
3748
- var openaiResponsesChunkSchema = (0, import_provider_utils27.lazySchema)(
3749
- () => (0, import_provider_utils27.zodSchema)(
3962
+ var openaiResponsesChunkSchema = (0, import_provider_utils28.lazySchema)(
3963
+ () => (0, import_provider_utils28.zodSchema)(
3750
3964
  import_v422.z.union([
3751
3965
  import_v422.z.object({
3752
3966
  type: import_v422.z.literal("response.output_text.delta"),
@@ -4294,8 +4508,8 @@ var openaiResponsesChunkSchema = (0, import_provider_utils27.lazySchema)(
4294
4508
  ])
4295
4509
  )
4296
4510
  );
4297
- var openaiResponsesResponseSchema = (0, import_provider_utils27.lazySchema)(
4298
- () => (0, import_provider_utils27.zodSchema)(
4511
+ var openaiResponsesResponseSchema = (0, import_provider_utils28.lazySchema)(
4512
+ () => (0, import_provider_utils28.zodSchema)(
4299
4513
  import_v422.z.object({
4300
4514
  id: import_v422.z.string().optional(),
4301
4515
  created_at: import_v422.z.number().optional(),
@@ -4609,7 +4823,7 @@ var openaiResponsesResponseSchema = (0, import_provider_utils27.lazySchema)(
4609
4823
  );
4610
4824
 
4611
4825
  // src/responses/openai-responses-options.ts
4612
- var import_provider_utils28 = require("@ai-sdk/provider-utils");
4826
+ var import_provider_utils29 = require("@ai-sdk/provider-utils");
4613
4827
  var import_v423 = require("zod/v4");
4614
4828
  var TOP_LOGPROBS_MAX = 20;
4615
4829
  var openaiResponsesReasoningModelIds = [
@@ -4681,8 +4895,8 @@ var openaiResponsesModelIds = [
4681
4895
  "gpt-5-chat-latest",
4682
4896
  ...openaiResponsesReasoningModelIds
4683
4897
  ];
4684
- var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils28.lazySchema)(
4685
- () => (0, import_provider_utils28.zodSchema)(
4898
+ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils29.lazySchema)(
4899
+ () => (0, import_provider_utils29.zodSchema)(
4686
4900
  import_v423.z.object({
4687
4901
  /**
4688
4902
  * The ID of the OpenAI Conversation to continue.
@@ -4879,8 +5093,8 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils28.lazy
4879
5093
  );
4880
5094
 
4881
5095
  // src/responses/openai-responses-prepare-tools.ts
4882
- var import_provider8 = require("@ai-sdk/provider");
4883
- var import_provider_utils29 = require("@ai-sdk/provider-utils");
5096
+ var import_provider9 = require("@ai-sdk/provider");
5097
+ var import_provider_utils30 = require("@ai-sdk/provider-utils");
4884
5098
  async function prepareResponsesTools({
4885
5099
  tools,
4886
5100
  toolChoice,
@@ -4934,7 +5148,7 @@ async function prepareResponsesTools({
4934
5148
  namespaceTools.set(namespace.name, namespaceTool);
4935
5149
  openaiTools2.push(namespaceTool);
4936
5150
  } else if (namespaceTool.description !== namespace.description) {
4937
- throw new import_provider8.UnsupportedFunctionalityError({
5151
+ throw new import_provider9.UnsupportedFunctionalityError({
4938
5152
  functionality: `conflicting descriptions for OpenAI tool namespace "${namespace.name}"`
4939
5153
  });
4940
5154
  }
@@ -4960,7 +5174,7 @@ async function prepareResponsesTools({
4960
5174
  const openaiToolCountBefore = openaiTools2.length;
4961
5175
  switch (tool.id) {
4962
5176
  case "openai.file_search": {
4963
- const args = await (0, import_provider_utils29.validateTypes)({
5177
+ const args = await (0, import_provider_utils30.validateTypes)({
4964
5178
  value: tool.args,
4965
5179
  schema: fileSearchArgsSchema
4966
5180
  });
@@ -4983,7 +5197,7 @@ async function prepareResponsesTools({
4983
5197
  break;
4984
5198
  }
4985
5199
  case "openai.shell": {
4986
- const args = await (0, import_provider_utils29.validateTypes)({
5200
+ const args = await (0, import_provider_utils30.validateTypes)({
4987
5201
  value: tool.args,
4988
5202
  schema: shellArgsSchema
4989
5203
  });
@@ -5002,7 +5216,7 @@ async function prepareResponsesTools({
5002
5216
  break;
5003
5217
  }
5004
5218
  case "openai.web_search_preview": {
5005
- const args = await (0, import_provider_utils29.validateTypes)({
5219
+ const args = await (0, import_provider_utils30.validateTypes)({
5006
5220
  value: tool.args,
5007
5221
  schema: webSearchPreviewArgsSchema
5008
5222
  });
@@ -5014,7 +5228,7 @@ async function prepareResponsesTools({
5014
5228
  break;
5015
5229
  }
5016
5230
  case "openai.web_search": {
5017
- const args = await (0, import_provider_utils29.validateTypes)({
5231
+ const args = await (0, import_provider_utils30.validateTypes)({
5018
5232
  value: tool.args,
5019
5233
  schema: webSearchArgsSchema
5020
5234
  });
@@ -5031,7 +5245,7 @@ async function prepareResponsesTools({
5031
5245
  break;
5032
5246
  }
5033
5247
  case "openai.code_interpreter": {
5034
- const args = await (0, import_provider_utils29.validateTypes)({
5248
+ const args = await (0, import_provider_utils30.validateTypes)({
5035
5249
  value: tool.args,
5036
5250
  schema: codeInterpreterArgsSchema
5037
5251
  });
@@ -5042,7 +5256,7 @@ async function prepareResponsesTools({
5042
5256
  break;
5043
5257
  }
5044
5258
  case "openai.image_generation": {
5045
- const args = await (0, import_provider_utils29.validateTypes)({
5259
+ const args = await (0, import_provider_utils30.validateTypes)({
5046
5260
  value: tool.args,
5047
5261
  schema: imageGenerationArgsSchema
5048
5262
  });
@@ -5065,7 +5279,7 @@ async function prepareResponsesTools({
5065
5279
  break;
5066
5280
  }
5067
5281
  case "openai.mcp": {
5068
- const args = await (0, import_provider_utils29.validateTypes)({
5282
+ const args = await (0, import_provider_utils30.validateTypes)({
5069
5283
  value: tool.args,
5070
5284
  schema: mcpArgsSchema
5071
5285
  });
@@ -5091,7 +5305,7 @@ async function prepareResponsesTools({
5091
5305
  break;
5092
5306
  }
5093
5307
  case "openai.custom": {
5094
- const args = await (0, import_provider_utils29.validateTypes)({
5308
+ const args = await (0, import_provider_utils30.validateTypes)({
5095
5309
  value: tool.args,
5096
5310
  schema: customArgsSchema
5097
5311
  });
@@ -5105,7 +5319,7 @@ async function prepareResponsesTools({
5105
5319
  break;
5106
5320
  }
5107
5321
  case "openai.tool_search": {
5108
- const args = await (0, import_provider_utils29.validateTypes)({
5322
+ const args = await (0, import_provider_utils30.validateTypes)({
5109
5323
  value: tool.args,
5110
5324
  schema: toolSearchArgsSchema
5111
5325
  });
@@ -5182,7 +5396,7 @@ async function prepareResponsesTools({
5182
5396
  allowedToolEntries.push(resolution.entry);
5183
5397
  }
5184
5398
  if (allowedToolEntries.length === 0) {
5185
- throw new import_provider8.UnsupportedFunctionalityError({
5399
+ throw new import_provider9.UnsupportedFunctionalityError({
5186
5400
  functionality: `allowedTools with only tools that cannot be allow-listed (${droppedToolNames.join(
5187
5401
  ", "
5188
5402
  )})`
@@ -5217,7 +5431,7 @@ async function prepareResponsesTools({
5217
5431
  }
5218
5432
  default: {
5219
5433
  const _exhaustiveCheck = type;
5220
- throw new import_provider8.UnsupportedFunctionalityError({
5434
+ throw new import_provider9.UnsupportedFunctionalityError({
5221
5435
  functionality: `tool choice type: ${_exhaustiveCheck}`
5222
5436
  });
5223
5437
  }
@@ -5392,13 +5606,13 @@ var OpenAIResponsesLanguageModel = class {
5392
5606
  warnings.push({ type: "unsupported", feature: "stopSequences" });
5393
5607
  }
5394
5608
  const providerOptionsName = this.config.provider.includes("azure") ? "azure" : "openai";
5395
- let openaiOptions = await (0, import_provider_utils30.parseProviderOptions)({
5609
+ let openaiOptions = await (0, import_provider_utils31.parseProviderOptions)({
5396
5610
  provider: providerOptionsName,
5397
5611
  providerOptions,
5398
5612
  schema: openaiLanguageModelResponsesOptionsSchema
5399
5613
  });
5400
5614
  if (openaiOptions == null && providerOptionsName !== "openai") {
5401
- openaiOptions = await (0, import_provider_utils30.parseProviderOptions)({
5615
+ openaiOptions = await (0, import_provider_utils31.parseProviderOptions)({
5402
5616
  provider: "openai",
5403
5617
  providerOptions,
5404
5618
  schema: openaiLanguageModelResponsesOptionsSchema
@@ -5412,7 +5626,7 @@ var OpenAIResponsesLanguageModel = class {
5412
5626
  details: "conversation and previousResponseId cannot be used together"
5413
5627
  });
5414
5628
  }
5415
- const toolNameMapping = (0, import_provider_utils30.createToolNameMapping)({
5629
+ const toolNameMapping = (0, import_provider_utils31.createToolNameMapping)({
5416
5630
  tools,
5417
5631
  providerToolNames: {
5418
5632
  "openai.code_interpreter": "code_interpreter",
@@ -5626,7 +5840,7 @@ var OpenAIResponsesLanguageModel = class {
5626
5840
  };
5627
5841
  }
5628
5842
  async doGenerate(options) {
5629
- var _a, _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;
5843
+ var _a, _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;
5630
5844
  const {
5631
5845
  args: body,
5632
5846
  warnings,
@@ -5644,19 +5858,19 @@ var OpenAIResponsesLanguageModel = class {
5644
5858
  responseHeaders,
5645
5859
  value: response,
5646
5860
  rawValue: rawResponse
5647
- } = await (0, import_provider_utils30.postJsonToApi)({
5861
+ } = await (0, import_provider_utils31.postJsonToApi)({
5648
5862
  url,
5649
- headers: (0, import_provider_utils30.combineHeaders)(this.config.headers(), options.headers),
5863
+ headers: (0, import_provider_utils31.combineHeaders)(this.config.headers(), options.headers),
5650
5864
  body,
5651
5865
  failedResponseHandler: openaiFailedResponseHandler,
5652
- successfulResponseHandler: (0, import_provider_utils30.createJsonResponseHandler)(
5866
+ successfulResponseHandler: (0, import_provider_utils31.createJsonResponseHandler)(
5653
5867
  openaiResponsesResponseSchema
5654
5868
  ),
5655
5869
  abortSignal: options.abortSignal,
5656
5870
  fetch: this.config.fetch
5657
5871
  });
5658
5872
  if (response.error) {
5659
- throw new import_provider9.APICallError({
5873
+ throw new import_provider10.APICallError({
5660
5874
  message: response.error.message,
5661
5875
  url,
5662
5876
  requestBodyValues: body,
@@ -5668,6 +5882,9 @@ var OpenAIResponsesLanguageModel = class {
5668
5882
  }
5669
5883
  const content = [];
5670
5884
  const logprobs = [];
5885
+ const functionTools = (_b = (_a = options.tools) == null ? void 0 : _a.filter(
5886
+ (tool) => tool.type === "function"
5887
+ )) != null ? _b : [];
5671
5888
  let hasFunctionCall = false;
5672
5889
  const hostedToolSearchCallIds = [];
5673
5890
  for (const part of response.output) {
@@ -5683,7 +5900,7 @@ var OpenAIResponsesLanguageModel = class {
5683
5900
  providerMetadata: {
5684
5901
  [providerOptionsName]: {
5685
5902
  itemId: part.id,
5686
- reasoningEncryptedContent: (_a = part.encrypted_content) != null ? _a : null
5903
+ reasoningEncryptedContent: (_c = part.encrypted_content) != null ? _c : null
5687
5904
  }
5688
5905
  }
5689
5906
  });
@@ -5709,7 +5926,7 @@ var OpenAIResponsesLanguageModel = class {
5709
5926
  break;
5710
5927
  }
5711
5928
  case "tool_search_call": {
5712
- const toolCallId = (_b = part.call_id) != null ? _b : part.id;
5929
+ const toolCallId = (_d = part.call_id) != null ? _d : part.id;
5713
5930
  const isHosted = part.execution === "server";
5714
5931
  if (isHosted) {
5715
5932
  hostedToolSearchCallIds.push(toolCallId);
@@ -5732,7 +5949,7 @@ var OpenAIResponsesLanguageModel = class {
5732
5949
  break;
5733
5950
  }
5734
5951
  case "tool_search_output": {
5735
- const toolCallId = (_d = (_c = part.call_id) != null ? _c : hostedToolSearchCallIds.shift()) != null ? _d : part.id;
5952
+ const toolCallId = (_f = (_e = part.call_id) != null ? _e : hostedToolSearchCallIds.shift()) != null ? _f : part.id;
5736
5953
  content.push({
5737
5954
  type: "tool-result",
5738
5955
  toolCallId,
@@ -5803,7 +6020,7 @@ var OpenAIResponsesLanguageModel = class {
5803
6020
  }
5804
6021
  case "message": {
5805
6022
  for (const contentPart of part.content) {
5806
- if (((_f = (_e = options.providerOptions) == null ? void 0 : _e[providerOptionsName]) == null ? void 0 : _f.logprobs) && contentPart.logprobs) {
6023
+ if (((_h = (_g = options.providerOptions) == null ? void 0 : _g[providerOptionsName]) == null ? void 0 : _h.logprobs) && contentPart.logprobs) {
5807
6024
  logprobs.push(contentPart.logprobs);
5808
6025
  }
5809
6026
  const providerMetadata2 = {
@@ -5825,7 +6042,7 @@ var OpenAIResponsesLanguageModel = class {
5825
6042
  content.push({
5826
6043
  type: "source",
5827
6044
  sourceType: "url",
5828
- id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : (0, import_provider_utils30.generateId)(),
6045
+ id: (_k = (_j = (_i = this.config).generateId) == null ? void 0 : _j.call(_i)) != null ? _k : (0, import_provider_utils31.generateId)(),
5829
6046
  url: annotation.url,
5830
6047
  title: annotation.title
5831
6048
  });
@@ -5833,7 +6050,7 @@ var OpenAIResponsesLanguageModel = class {
5833
6050
  content.push({
5834
6051
  type: "source",
5835
6052
  sourceType: "document",
5836
- id: (_l = (_k = (_j = this.config).generateId) == null ? void 0 : _k.call(_j)) != null ? _l : (0, import_provider_utils30.generateId)(),
6053
+ id: (_n = (_m = (_l = this.config).generateId) == null ? void 0 : _m.call(_l)) != null ? _n : (0, import_provider_utils31.generateId)(),
5837
6054
  mediaType: "text/plain",
5838
6055
  title: annotation.filename,
5839
6056
  filename: annotation.filename,
@@ -5849,7 +6066,7 @@ var OpenAIResponsesLanguageModel = class {
5849
6066
  content.push({
5850
6067
  type: "source",
5851
6068
  sourceType: "document",
5852
- id: (_o = (_n = (_m = this.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : (0, import_provider_utils30.generateId)(),
6069
+ id: (_q = (_p = (_o = this.config).generateId) == null ? void 0 : _p.call(_o)) != null ? _q : (0, import_provider_utils31.generateId)(),
5853
6070
  mediaType: "text/plain",
5854
6071
  title: annotation.filename,
5855
6072
  filename: annotation.filename,
@@ -5865,7 +6082,7 @@ var OpenAIResponsesLanguageModel = class {
5865
6082
  content.push({
5866
6083
  type: "source",
5867
6084
  sourceType: "document",
5868
- id: (_r = (_q = (_p = this.config).generateId) == null ? void 0 : _q.call(_p)) != null ? _r : (0, import_provider_utils30.generateId)(),
6085
+ id: (_t = (_s = (_r = this.config).generateId) == null ? void 0 : _s.call(_r)) != null ? _t : (0, import_provider_utils31.generateId)(),
5869
6086
  mediaType: "application/octet-stream",
5870
6087
  title: annotation.file_id,
5871
6088
  filename: annotation.file_id,
@@ -5884,6 +6101,20 @@ var OpenAIResponsesLanguageModel = class {
5884
6101
  }
5885
6102
  case "function_call": {
5886
6103
  hasFunctionCall = true;
6104
+ const expandedToolCalls = await expandParallelToolCall({
6105
+ toolCall: {
6106
+ toolCallId: part.call_id,
6107
+ toolName: part.name,
6108
+ input: part.arguments
6109
+ },
6110
+ tools: functionTools,
6111
+ providerOptionsName,
6112
+ itemId: part.id
6113
+ });
6114
+ if (expandedToolCalls != null) {
6115
+ content.push(...expandedToolCalls);
6116
+ break;
6117
+ }
5887
6118
  content.push({
5888
6119
  type: "tool-call",
5889
6120
  toolCallId: part.call_id,
@@ -5935,7 +6166,7 @@ var OpenAIResponsesLanguageModel = class {
5935
6166
  break;
5936
6167
  }
5937
6168
  case "mcp_call": {
5938
- const toolCallId = part.approval_request_id != null ? (_s = approvalRequestIdToDummyToolCallIdFromPrompt[part.approval_request_id]) != null ? _s : part.id : part.id;
6169
+ const toolCallId = part.approval_request_id != null ? (_u = approvalRequestIdToDummyToolCallIdFromPrompt[part.approval_request_id]) != null ? _u : part.id : part.id;
5939
6170
  const toolName = `mcp.${part.name}`;
5940
6171
  content.push({
5941
6172
  type: "tool-call",
@@ -5969,8 +6200,8 @@ var OpenAIResponsesLanguageModel = class {
5969
6200
  break;
5970
6201
  }
5971
6202
  case "mcp_approval_request": {
5972
- const approvalRequestId = (_t = part.approval_request_id) != null ? _t : part.id;
5973
- const dummyToolCallId = (_w = (_v = (_u = this.config).generateId) == null ? void 0 : _v.call(_u)) != null ? _w : (0, import_provider_utils30.generateId)();
6203
+ const approvalRequestId = (_v = part.approval_request_id) != null ? _v : part.id;
6204
+ const dummyToolCallId = (_y = (_x = (_w = this.config).generateId) == null ? void 0 : _x.call(_w)) != null ? _y : (0, import_provider_utils31.generateId)();
5974
6205
  const toolName = `mcp.${part.name}`;
5975
6206
  content.push({
5976
6207
  type: "tool-call",
@@ -6020,13 +6251,13 @@ var OpenAIResponsesLanguageModel = class {
6020
6251
  toolName: toolNameMapping.toCustomToolName("file_search"),
6021
6252
  result: {
6022
6253
  queries: part.queries,
6023
- results: (_y = (_x = part.results) == null ? void 0 : _x.map((result) => ({
6254
+ results: (_A = (_z = part.results) == null ? void 0 : _z.map((result) => ({
6024
6255
  attributes: result.attributes,
6025
6256
  fileId: result.file_id,
6026
6257
  filename: result.filename,
6027
6258
  score: result.score,
6028
6259
  text: result.text
6029
- }))) != null ? _y : null
6260
+ }))) != null ? _A : null
6030
6261
  }
6031
6262
  });
6032
6263
  break;
@@ -6076,7 +6307,7 @@ var OpenAIResponsesLanguageModel = class {
6076
6307
  responseId: response.id,
6077
6308
  ...logprobs.length > 0 ? { logprobs } : {},
6078
6309
  ...typeof response.service_tier === "string" ? { serviceTier: response.service_tier } : {},
6079
- ...((_z = response.reasoning) == null ? void 0 : _z.context) != null ? { reasoningContext: response.reasoning.context } : {}
6310
+ ...((_B = response.reasoning) == null ? void 0 : _B.context) != null ? { reasoningContext: response.reasoning.context } : {}
6080
6311
  }
6081
6312
  };
6082
6313
  const usage = response.usage;
@@ -6084,10 +6315,10 @@ var OpenAIResponsesLanguageModel = class {
6084
6315
  content,
6085
6316
  finishReason: {
6086
6317
  unified: mapOpenAIResponseFinishReason({
6087
- finishReason: (_A = response.incomplete_details) == null ? void 0 : _A.reason,
6318
+ finishReason: (_C = response.incomplete_details) == null ? void 0 : _C.reason,
6088
6319
  hasFunctionCall
6089
6320
  }),
6090
- raw: (_C = (_B = response.incomplete_details) == null ? void 0 : _B.reason) != null ? _C : void 0
6321
+ raw: (_E = (_D = response.incomplete_details) == null ? void 0 : _D.reason) != null ? _E : void 0
6091
6322
  },
6092
6323
  usage: convertOpenAIResponsesUsage(usage),
6093
6324
  request: { body },
@@ -6103,6 +6334,7 @@ var OpenAIResponsesLanguageModel = class {
6103
6334
  };
6104
6335
  }
6105
6336
  async doStream(options) {
6337
+ var _a, _b;
6106
6338
  const {
6107
6339
  args: body,
6108
6340
  warnings,
@@ -6116,15 +6348,15 @@ var OpenAIResponsesLanguageModel = class {
6116
6348
  path: "/responses",
6117
6349
  modelId: this.modelId
6118
6350
  });
6119
- const { responseHeaders, value: response } = await (0, import_provider_utils30.postJsonToApi)({
6351
+ const { responseHeaders, value: response } = await (0, import_provider_utils31.postJsonToApi)({
6120
6352
  url,
6121
- headers: (0, import_provider_utils30.combineHeaders)(this.config.headers(), options.headers),
6353
+ headers: (0, import_provider_utils31.combineHeaders)(this.config.headers(), options.headers),
6122
6354
  body: {
6123
6355
  ...body,
6124
6356
  stream: true
6125
6357
  },
6126
6358
  failedResponseHandler: openaiFailedResponseHandler,
6127
- successfulResponseHandler: (0, import_provider_utils30.createEventSourceResponseHandler)(
6359
+ successfulResponseHandler: (0, import_provider_utils31.createEventSourceResponseHandler)(
6128
6360
  openaiResponsesChunkSchema
6129
6361
  ),
6130
6362
  abortSignal: options.abortSignal,
@@ -6140,6 +6372,9 @@ var OpenAIResponsesLanguageModel = class {
6140
6372
  });
6141
6373
  const self = this;
6142
6374
  const approvalRequestIdToDummyToolCallIdFromPrompt = extractApprovalRequestIdToToolCallIdMapping(options.prompt);
6375
+ const functionTools = (_b = (_a = options.tools) == null ? void 0 : _a.filter(
6376
+ (tool) => tool.type === "function"
6377
+ )) != null ? _b : [];
6143
6378
  const approvalRequestIdToDummyToolCallIdFromStream = /* @__PURE__ */ new Map();
6144
6379
  let finishReason = {
6145
6380
  unified: "other",
@@ -6164,7 +6399,7 @@ var OpenAIResponsesLanguageModel = class {
6164
6399
  controller.enqueue({ type: "stream-start", warnings });
6165
6400
  },
6166
6401
  transform(chunk, controller) {
6167
- var _a, _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;
6402
+ var _a2, _b2, _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;
6168
6403
  if (options.includeRawChunks) {
6169
6404
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
6170
6405
  }
@@ -6183,15 +6418,23 @@ var OpenAIResponsesLanguageModel = class {
6183
6418
  const value = chunk.value;
6184
6419
  if (isResponseOutputItemAddedChunk(value)) {
6185
6420
  if (value.item.type === "function_call") {
6421
+ const suppressInputStreaming = isUndeclaredParallelToolCall({
6422
+ toolName: value.item.name,
6423
+ tools: functionTools
6424
+ });
6186
6425
  ongoingToolCalls[value.output_index] = {
6187
6426
  toolName: value.item.name,
6188
- toolCallId: value.item.call_id
6427
+ toolCallId: value.item.call_id,
6428
+ suppressInputStreaming,
6429
+ bufferedInputDeltas: suppressInputStreaming ? [] : void 0
6189
6430
  };
6190
- controller.enqueue({
6191
- type: "tool-input-start",
6192
- id: value.item.call_id,
6193
- toolName: value.item.name
6194
- });
6431
+ if (!suppressInputStreaming) {
6432
+ controller.enqueue({
6433
+ type: "tool-input-start",
6434
+ id: value.item.call_id,
6435
+ toolName: value.item.name
6436
+ });
6437
+ }
6195
6438
  } else if (value.item.type === "custom_tool_call") {
6196
6439
  const toolName = toolNameMapping.toCustomToolName(
6197
6440
  value.item.name
@@ -6286,7 +6529,7 @@ var OpenAIResponsesLanguageModel = class {
6286
6529
  ongoingToolCalls[value.output_index] = {
6287
6530
  toolName,
6288
6531
  toolCallId,
6289
- toolSearchExecution: (_a = value.item.execution) != null ? _a : "server"
6532
+ toolSearchExecution: (_a2 = value.item.execution) != null ? _a2 : "server"
6290
6533
  };
6291
6534
  if (isHosted) {
6292
6535
  controller.enqueue({
@@ -6343,7 +6586,7 @@ var OpenAIResponsesLanguageModel = class {
6343
6586
  } else if (value.item.type === "shell_call_output") {
6344
6587
  } else if (value.item.type === "message") {
6345
6588
  ongoingAnnotations.splice(0, ongoingAnnotations.length);
6346
- activeMessagePhase = (_b = value.item.phase) != null ? _b : void 0;
6589
+ activeMessagePhase = (_b2 = value.item.phase) != null ? _b2 : void 0;
6347
6590
  controller.enqueue({
6348
6591
  type: "text-start",
6349
6592
  id: value.item.id,
@@ -6390,31 +6633,99 @@ var OpenAIResponsesLanguageModel = class {
6390
6633
  }
6391
6634
  });
6392
6635
  } else if (value.item.type === "function_call") {
6636
+ const item = value.item;
6637
+ const ongoingToolCall = ongoingToolCalls[value.output_index];
6393
6638
  ongoingToolCalls[value.output_index] = void 0;
6394
6639
  hasFunctionCall = true;
6395
- controller.enqueue({
6396
- type: "tool-input-end",
6397
- id: value.item.call_id,
6398
- ...value.item.namespace != null && {
6399
- providerMetadata: {
6400
- [providerOptionsName]: {
6401
- namespace: value.item.namespace
6640
+ const suppressInputStreaming = (_e = ongoingToolCall == null ? void 0 : ongoingToolCall.suppressInputStreaming) != null ? _e : isUndeclaredParallelToolCall({
6641
+ toolName: item.name,
6642
+ tools: functionTools
6643
+ });
6644
+ const enqueueUnexpandedToolCall = () => {
6645
+ var _a3;
6646
+ if (suppressInputStreaming) {
6647
+ controller.enqueue({
6648
+ type: "tool-input-start",
6649
+ id: item.call_id,
6650
+ toolName: item.name
6651
+ });
6652
+ const bufferedInputDeltas = (_a3 = ongoingToolCall == null ? void 0 : ongoingToolCall.bufferedInputDeltas) != null ? _a3 : [];
6653
+ if (bufferedInputDeltas.length > 0) {
6654
+ for (const delta of bufferedInputDeltas) {
6655
+ controller.enqueue({
6656
+ type: "tool-input-delta",
6657
+ id: item.call_id,
6658
+ delta
6659
+ });
6402
6660
  }
6661
+ } else if (item.arguments.length > 0) {
6662
+ controller.enqueue({
6663
+ type: "tool-input-delta",
6664
+ id: item.call_id,
6665
+ delta: item.arguments
6666
+ });
6403
6667
  }
6404
6668
  }
6405
- });
6406
- controller.enqueue({
6407
- type: "tool-call",
6408
- toolCallId: value.item.call_id,
6409
- toolName: value.item.name,
6410
- input: value.item.arguments,
6411
- providerMetadata: {
6412
- [providerOptionsName]: {
6413
- itemId: value.item.id,
6414
- ...value.item.namespace != null && {
6415
- namespace: value.item.namespace
6669
+ controller.enqueue({
6670
+ type: "tool-input-end",
6671
+ id: item.call_id,
6672
+ ...item.namespace != null && {
6673
+ providerMetadata: {
6674
+ [providerOptionsName]: {
6675
+ namespace: item.namespace
6676
+ }
6677
+ }
6678
+ }
6679
+ });
6680
+ controller.enqueue({
6681
+ type: "tool-call",
6682
+ toolCallId: item.call_id,
6683
+ toolName: item.name,
6684
+ input: item.arguments,
6685
+ providerMetadata: {
6686
+ [providerOptionsName]: {
6687
+ itemId: item.id,
6688
+ ...item.namespace != null && {
6689
+ namespace: item.namespace
6690
+ }
6416
6691
  }
6417
6692
  }
6693
+ });
6694
+ };
6695
+ if (!suppressInputStreaming) {
6696
+ enqueueUnexpandedToolCall();
6697
+ return;
6698
+ }
6699
+ return expandParallelToolCall({
6700
+ toolCall: {
6701
+ toolCallId: item.call_id,
6702
+ toolName: item.name,
6703
+ input: item.arguments
6704
+ },
6705
+ tools: functionTools,
6706
+ providerOptionsName,
6707
+ itemId: item.id
6708
+ }).then((expandedToolCalls) => {
6709
+ if (expandedToolCalls == null) {
6710
+ enqueueUnexpandedToolCall();
6711
+ return;
6712
+ }
6713
+ for (const toolCall of expandedToolCalls) {
6714
+ controller.enqueue({
6715
+ type: "tool-input-start",
6716
+ id: toolCall.toolCallId,
6717
+ toolName: toolCall.toolName
6718
+ });
6719
+ controller.enqueue({
6720
+ type: "tool-input-delta",
6721
+ id: toolCall.toolCallId,
6722
+ delta: toolCall.input
6723
+ });
6724
+ controller.enqueue({
6725
+ type: "tool-input-end",
6726
+ id: toolCall.toolCallId
6727
+ });
6728
+ controller.enqueue(toolCall);
6418
6729
  }
6419
6730
  });
6420
6731
  } else if (value.item.type === "custom_tool_call") {
@@ -6478,13 +6789,13 @@ var OpenAIResponsesLanguageModel = class {
6478
6789
  toolName: toolNameMapping.toCustomToolName("file_search"),
6479
6790
  result: {
6480
6791
  queries: value.item.queries,
6481
- results: (_f = (_e = value.item.results) == null ? void 0 : _e.map((result2) => ({
6792
+ results: (_g = (_f = value.item.results) == null ? void 0 : _f.map((result2) => ({
6482
6793
  attributes: result2.attributes,
6483
6794
  fileId: result2.file_id,
6484
6795
  filename: result2.filename,
6485
6796
  score: result2.score,
6486
6797
  text: result2.text
6487
- }))) != null ? _f : null
6798
+ }))) != null ? _g : null
6488
6799
  }
6489
6800
  });
6490
6801
  } else if (value.item.type === "code_interpreter_call") {
@@ -6510,7 +6821,7 @@ var OpenAIResponsesLanguageModel = class {
6510
6821
  const toolCall = ongoingToolCalls[value.output_index];
6511
6822
  const isHosted = value.item.execution === "server";
6512
6823
  if (toolCall != null) {
6513
- const toolCallId = isHosted ? toolCall.toolCallId : (_g = value.item.call_id) != null ? _g : value.item.id;
6824
+ const toolCallId = isHosted ? toolCall.toolCallId : (_h = value.item.call_id) != null ? _h : value.item.id;
6514
6825
  if (isHosted) {
6515
6826
  hostedToolSearchCallIds.push(toolCallId);
6516
6827
  } else {
@@ -6542,7 +6853,7 @@ var OpenAIResponsesLanguageModel = class {
6542
6853
  }
6543
6854
  ongoingToolCalls[value.output_index] = void 0;
6544
6855
  } else if (value.item.type === "tool_search_output") {
6545
- const toolCallId = (_i = (_h = value.item.call_id) != null ? _h : hostedToolSearchCallIds.shift()) != null ? _i : value.item.id;
6856
+ const toolCallId = (_j = (_i = value.item.call_id) != null ? _i : hostedToolSearchCallIds.shift()) != null ? _j : value.item.id;
6546
6857
  controller.enqueue({
6547
6858
  type: "tool-result",
6548
6859
  toolCallId,
@@ -6558,10 +6869,10 @@ var OpenAIResponsesLanguageModel = class {
6558
6869
  });
6559
6870
  } else if (value.item.type === "mcp_call") {
6560
6871
  ongoingToolCalls[value.output_index] = void 0;
6561
- const approvalRequestId = (_j = value.item.approval_request_id) != null ? _j : void 0;
6562
- const aliasedToolCallId = approvalRequestId != null ? (_l = (_k = approvalRequestIdToDummyToolCallIdFromStream.get(
6872
+ const approvalRequestId = (_k = value.item.approval_request_id) != null ? _k : void 0;
6873
+ const aliasedToolCallId = approvalRequestId != null ? (_m = (_l = approvalRequestIdToDummyToolCallIdFromStream.get(
6563
6874
  approvalRequestId
6564
- )) != null ? _k : approvalRequestIdToDummyToolCallIdFromPrompt[approvalRequestId]) != null ? _l : value.item.id : value.item.id;
6875
+ )) != null ? _l : approvalRequestIdToDummyToolCallIdFromPrompt[approvalRequestId]) != null ? _m : value.item.id : value.item.id;
6565
6876
  const toolName = `mcp.${value.item.name}`;
6566
6877
  controller.enqueue({
6567
6878
  type: "tool-call",
@@ -6631,8 +6942,8 @@ var OpenAIResponsesLanguageModel = class {
6631
6942
  ongoingToolCalls[value.output_index] = void 0;
6632
6943
  } else if (value.item.type === "mcp_approval_request") {
6633
6944
  ongoingToolCalls[value.output_index] = void 0;
6634
- const dummyToolCallId = (_o = (_n = (_m = self.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : (0, import_provider_utils30.generateId)();
6635
- const approvalRequestId = (_p = value.item.approval_request_id) != null ? _p : value.item.id;
6945
+ const dummyToolCallId = (_p = (_o = (_n = self.config).generateId) == null ? void 0 : _o.call(_n)) != null ? _p : (0, import_provider_utils31.generateId)();
6946
+ const approvalRequestId = (_q = value.item.approval_request_id) != null ? _q : value.item.id;
6636
6947
  approvalRequestIdToDummyToolCallIdFromStream.set(
6637
6948
  approvalRequestId,
6638
6949
  dummyToolCallId
@@ -6721,7 +7032,7 @@ var OpenAIResponsesLanguageModel = class {
6721
7032
  providerMetadata: {
6722
7033
  [providerOptionsName]: {
6723
7034
  itemId: value.item.id,
6724
- reasoningEncryptedContent: (_q = value.item.encrypted_content) != null ? _q : null
7035
+ reasoningEncryptedContent: (_r = value.item.encrypted_content) != null ? _r : null
6725
7036
  }
6726
7037
  }
6727
7038
  });
@@ -6731,11 +7042,15 @@ var OpenAIResponsesLanguageModel = class {
6731
7042
  } else if (isResponseFunctionCallArgumentsDeltaChunk(value)) {
6732
7043
  const toolCall = ongoingToolCalls[value.output_index];
6733
7044
  if (toolCall != null) {
6734
- controller.enqueue({
6735
- type: "tool-input-delta",
6736
- id: toolCall.toolCallId,
6737
- delta: value.delta
6738
- });
7045
+ if (toolCall.suppressInputStreaming) {
7046
+ (_s = toolCall.bufferedInputDeltas) == null ? void 0 : _s.push(value.delta);
7047
+ } else {
7048
+ controller.enqueue({
7049
+ type: "tool-input-delta",
7050
+ id: toolCall.toolCallId,
7051
+ delta: value.delta
7052
+ });
7053
+ }
6739
7054
  }
6740
7055
  } else if (isResponseCustomToolCallInputDeltaChunk(value)) {
6741
7056
  const toolCall = ongoingToolCalls[value.output_index];
@@ -6834,7 +7149,7 @@ var OpenAIResponsesLanguageModel = class {
6834
7149
  id: value.item_id,
6835
7150
  delta: value.delta
6836
7151
  });
6837
- if (((_s = (_r = options.providerOptions) == null ? void 0 : _r[providerOptionsName]) == null ? void 0 : _s.logprobs) && value.logprobs) {
7152
+ if (((_u = (_t = options.providerOptions) == null ? void 0 : _t[providerOptionsName]) == null ? void 0 : _u.logprobs) && value.logprobs) {
6838
7153
  logprobs.push(value.logprobs);
6839
7154
  }
6840
7155
  } else if (value.type === "response.reasoning_summary_part.added") {
@@ -6863,7 +7178,7 @@ var OpenAIResponsesLanguageModel = class {
6863
7178
  providerMetadata: {
6864
7179
  [providerOptionsName]: {
6865
7180
  itemId: value.item_id,
6866
- reasoningEncryptedContent: (_u = (_t = activeReasoning[value.item_id]) == null ? void 0 : _t.encryptedContent) != null ? _u : null
7181
+ reasoningEncryptedContent: (_w = (_v = activeReasoning[value.item_id]) == null ? void 0 : _v.encryptedContent) != null ? _w : null
6867
7182
  }
6868
7183
  }
6869
7184
  });
@@ -6897,20 +7212,20 @@ var OpenAIResponsesLanguageModel = class {
6897
7212
  } else if (isResponseFinishedChunk(value)) {
6898
7213
  finishReason = {
6899
7214
  unified: mapOpenAIResponseFinishReason({
6900
- finishReason: (_v = value.response.incomplete_details) == null ? void 0 : _v.reason,
7215
+ finishReason: (_x = value.response.incomplete_details) == null ? void 0 : _x.reason,
6901
7216
  hasFunctionCall
6902
7217
  }),
6903
- raw: (_x = (_w = value.response.incomplete_details) == null ? void 0 : _w.reason) != null ? _x : void 0
7218
+ raw: (_z = (_y = value.response.incomplete_details) == null ? void 0 : _y.reason) != null ? _z : void 0
6904
7219
  };
6905
7220
  usage = value.response.usage;
6906
7221
  if (typeof value.response.service_tier === "string") {
6907
7222
  serviceTier = value.response.service_tier;
6908
7223
  }
6909
- if (((_y = value.response.reasoning) == null ? void 0 : _y.context) != null) {
7224
+ if (((_A = value.response.reasoning) == null ? void 0 : _A.context) != null) {
6910
7225
  reasoningContext = value.response.reasoning.context;
6911
7226
  }
6912
7227
  } else if (isResponseFailedChunk(value)) {
6913
- const incompleteReason = (_z = value.response.incomplete_details) == null ? void 0 : _z.reason;
7228
+ const incompleteReason = (_B = value.response.incomplete_details) == null ? void 0 : _B.reason;
6914
7229
  finishReason = {
6915
7230
  unified: incompleteReason ? mapOpenAIResponseFinishReason({
6916
7231
  finishReason: incompleteReason,
@@ -6918,8 +7233,8 @@ var OpenAIResponsesLanguageModel = class {
6918
7233
  }) : "error",
6919
7234
  raw: incompleteReason != null ? incompleteReason : "error"
6920
7235
  };
6921
- usage = (_A = value.response.usage) != null ? _A : void 0;
6922
- if (((_B = value.response.reasoning) == null ? void 0 : _B.context) != null) {
7236
+ usage = (_C = value.response.usage) != null ? _C : void 0;
7237
+ if (((_D = value.response.reasoning) == null ? void 0 : _D.context) != null) {
6923
7238
  reasoningContext = value.response.reasoning.context;
6924
7239
  }
6925
7240
  if (!encounteredStreamError && value.response.error != null) {
@@ -6943,7 +7258,7 @@ var OpenAIResponsesLanguageModel = class {
6943
7258
  controller.enqueue({
6944
7259
  type: "source",
6945
7260
  sourceType: "url",
6946
- id: (_E = (_D = (_C = self.config).generateId) == null ? void 0 : _D.call(_C)) != null ? _E : (0, import_provider_utils30.generateId)(),
7261
+ id: (_G = (_F = (_E = self.config).generateId) == null ? void 0 : _F.call(_E)) != null ? _G : (0, import_provider_utils31.generateId)(),
6947
7262
  url: value.annotation.url,
6948
7263
  title: value.annotation.title
6949
7264
  });
@@ -6951,7 +7266,7 @@ var OpenAIResponsesLanguageModel = class {
6951
7266
  controller.enqueue({
6952
7267
  type: "source",
6953
7268
  sourceType: "document",
6954
- id: (_H = (_G = (_F = self.config).generateId) == null ? void 0 : _G.call(_F)) != null ? _H : (0, import_provider_utils30.generateId)(),
7269
+ id: (_J = (_I = (_H = self.config).generateId) == null ? void 0 : _I.call(_H)) != null ? _J : (0, import_provider_utils31.generateId)(),
6955
7270
  mediaType: "text/plain",
6956
7271
  title: value.annotation.filename,
6957
7272
  filename: value.annotation.filename,
@@ -6967,7 +7282,7 @@ var OpenAIResponsesLanguageModel = class {
6967
7282
  controller.enqueue({
6968
7283
  type: "source",
6969
7284
  sourceType: "document",
6970
- id: (_K = (_J = (_I = self.config).generateId) == null ? void 0 : _J.call(_I)) != null ? _K : (0, import_provider_utils30.generateId)(),
7285
+ id: (_M = (_L = (_K = self.config).generateId) == null ? void 0 : _L.call(_K)) != null ? _M : (0, import_provider_utils31.generateId)(),
6971
7286
  mediaType: "text/plain",
6972
7287
  title: value.annotation.filename,
6973
7288
  filename: value.annotation.filename,
@@ -6983,7 +7298,7 @@ var OpenAIResponsesLanguageModel = class {
6983
7298
  controller.enqueue({
6984
7299
  type: "source",
6985
7300
  sourceType: "document",
6986
- id: (_N = (_M = (_L = self.config).generateId) == null ? void 0 : _M.call(_L)) != null ? _N : (0, import_provider_utils30.generateId)(),
7301
+ id: (_P = (_O = (_N = self.config).generateId) == null ? void 0 : _O.call(_N)) != null ? _P : (0, import_provider_utils31.generateId)(),
6987
7302
  mediaType: "application/octet-stream",
6988
7303
  title: value.annotation.file_id,
6989
7304
  filename: value.annotation.file_id,
@@ -7003,6 +7318,24 @@ var OpenAIResponsesLanguageModel = class {
7003
7318
  }
7004
7319
  },
7005
7320
  flush(controller) {
7321
+ var _a2;
7322
+ for (const toolCall of Object.values(ongoingToolCalls)) {
7323
+ if (!(toolCall == null ? void 0 : toolCall.suppressInputStreaming)) {
7324
+ continue;
7325
+ }
7326
+ controller.enqueue({
7327
+ type: "tool-input-start",
7328
+ id: toolCall.toolCallId,
7329
+ toolName: toolCall.toolName
7330
+ });
7331
+ for (const delta of (_a2 = toolCall.bufferedInputDeltas) != null ? _a2 : []) {
7332
+ controller.enqueue({
7333
+ type: "tool-input-delta",
7334
+ id: toolCall.toolCallId,
7335
+ delta
7336
+ });
7337
+ }
7338
+ }
7006
7339
  const providerMetadata = {
7007
7340
  [providerOptionsName]: {
7008
7341
  responseId,
@@ -7040,7 +7373,7 @@ function createOpenAIResponsesChatCompletionsMismatchError({
7040
7373
  requestBodyValues,
7041
7374
  responseHeaders
7042
7375
  }) {
7043
- return new import_provider9.APICallError({
7376
+ return new import_provider10.APICallError({
7044
7377
  message: "Received a Chat Completions stream while using the OpenAI Responses API. The default OpenAI provider model uses the Responses API. If your custom baseURL targets a Chat Completions-compatible endpoint, use openai.chat('model-id') or createOpenAI(...).chat('model-id') instead. You can also use @ai-sdk/openai-compatible for OpenAI-compatible providers.",
7045
7378
  url,
7046
7379
  requestBodyValues,
@@ -7132,13 +7465,13 @@ function escapeJSONDelta(delta) {
7132
7465
  }
7133
7466
 
7134
7467
  // src/speech/openai-speech-model.ts
7135
- var import_provider_utils32 = require("@ai-sdk/provider-utils");
7468
+ var import_provider_utils33 = require("@ai-sdk/provider-utils");
7136
7469
 
7137
7470
  // src/speech/openai-speech-options.ts
7138
- var import_provider_utils31 = require("@ai-sdk/provider-utils");
7471
+ var import_provider_utils32 = require("@ai-sdk/provider-utils");
7139
7472
  var import_v424 = require("zod/v4");
7140
- var openaiSpeechModelOptionsSchema = (0, import_provider_utils31.lazySchema)(
7141
- () => (0, import_provider_utils31.zodSchema)(
7473
+ var openaiSpeechModelOptionsSchema = (0, import_provider_utils32.lazySchema)(
7474
+ () => (0, import_provider_utils32.zodSchema)(
7142
7475
  import_v424.z.object({
7143
7476
  instructions: import_v424.z.string().nullish(),
7144
7477
  speed: import_v424.z.number().min(0.25).max(4).default(1).nullish()
@@ -7166,7 +7499,7 @@ var OpenAISpeechModel = class {
7166
7499
  providerOptions
7167
7500
  }) {
7168
7501
  const warnings = [];
7169
- const openAIOptions = await (0, import_provider_utils32.parseProviderOptions)({
7502
+ const openAIOptions = await (0, import_provider_utils33.parseProviderOptions)({
7170
7503
  provider: "openai",
7171
7504
  providerOptions,
7172
7505
  schema: openaiSpeechModelOptionsSchema
@@ -7219,15 +7552,15 @@ var OpenAISpeechModel = class {
7219
7552
  value: audio,
7220
7553
  responseHeaders,
7221
7554
  rawValue: rawResponse
7222
- } = await (0, import_provider_utils32.postJsonToApi)({
7555
+ } = await (0, import_provider_utils33.postJsonToApi)({
7223
7556
  url: this.config.url({
7224
7557
  path: "/audio/speech",
7225
7558
  modelId: this.modelId
7226
7559
  }),
7227
- headers: (0, import_provider_utils32.combineHeaders)(this.config.headers(), options.headers),
7560
+ headers: (0, import_provider_utils33.combineHeaders)(this.config.headers(), options.headers),
7228
7561
  body: requestBody,
7229
7562
  failedResponseHandler: openaiFailedResponseHandler,
7230
- successfulResponseHandler: (0, import_provider_utils32.createBinaryResponseHandler)(),
7563
+ successfulResponseHandler: (0, import_provider_utils33.createBinaryResponseHandler)(),
7231
7564
  abortSignal: options.abortSignal,
7232
7565
  fetch: this.config.fetch
7233
7566
  });
@@ -7248,13 +7581,13 @@ var OpenAISpeechModel = class {
7248
7581
  };
7249
7582
 
7250
7583
  // src/transcription/openai-transcription-model.ts
7251
- var import_provider_utils35 = require("@ai-sdk/provider-utils");
7584
+ var import_provider_utils36 = require("@ai-sdk/provider-utils");
7252
7585
 
7253
7586
  // src/transcription/openai-transcription-api.ts
7254
- var import_provider_utils33 = require("@ai-sdk/provider-utils");
7587
+ var import_provider_utils34 = require("@ai-sdk/provider-utils");
7255
7588
  var import_v425 = require("zod/v4");
7256
- var openaiTranscriptionResponseSchema = (0, import_provider_utils33.lazySchema)(
7257
- () => (0, import_provider_utils33.zodSchema)(
7589
+ var openaiTranscriptionResponseSchema = (0, import_provider_utils34.lazySchema)(
7590
+ () => (0, import_provider_utils34.zodSchema)(
7258
7591
  import_v425.z.object({
7259
7592
  text: import_v425.z.string(),
7260
7593
  language: import_v425.z.string().nullish(),
@@ -7285,10 +7618,10 @@ var openaiTranscriptionResponseSchema = (0, import_provider_utils33.lazySchema)(
7285
7618
  );
7286
7619
 
7287
7620
  // src/transcription/openai-transcription-options.ts
7288
- var import_provider_utils34 = require("@ai-sdk/provider-utils");
7621
+ var import_provider_utils35 = require("@ai-sdk/provider-utils");
7289
7622
  var import_v426 = require("zod/v4");
7290
- var openAITranscriptionModelOptions = (0, import_provider_utils34.lazySchema)(
7291
- () => (0, import_provider_utils34.zodSchema)(
7623
+ var openAITranscriptionModelOptions = (0, import_provider_utils35.lazySchema)(
7624
+ () => (0, import_provider_utils35.zodSchema)(
7292
7625
  import_v426.z.object({
7293
7626
  /**
7294
7627
  * Additional information to include in the transcription response.
@@ -7391,15 +7724,15 @@ var OpenAITranscriptionModel = class {
7391
7724
  providerOptions
7392
7725
  }) {
7393
7726
  const warnings = [];
7394
- const openAIOptions = await (0, import_provider_utils35.parseProviderOptions)({
7727
+ const openAIOptions = await (0, import_provider_utils36.parseProviderOptions)({
7395
7728
  provider: "openai",
7396
7729
  providerOptions,
7397
7730
  schema: openAITranscriptionModelOptions
7398
7731
  });
7399
7732
  const formData = new FormData();
7400
- const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([(0, import_provider_utils35.convertBase64ToUint8Array)(audio)]);
7733
+ const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([(0, import_provider_utils36.convertBase64ToUint8Array)(audio)]);
7401
7734
  formData.append("model", this.modelId);
7402
- const fileExtension = (0, import_provider_utils35.mediaTypeToExtension)(mediaType);
7735
+ const fileExtension = (0, import_provider_utils36.mediaTypeToExtension)(mediaType);
7403
7736
  formData.append(
7404
7737
  "file",
7405
7738
  new File([blob], "audio", { type: mediaType }),
@@ -7444,15 +7777,15 @@ var OpenAITranscriptionModel = class {
7444
7777
  value: response,
7445
7778
  responseHeaders,
7446
7779
  rawValue: rawResponse
7447
- } = await (0, import_provider_utils35.postFormDataToApi)({
7780
+ } = await (0, import_provider_utils36.postFormDataToApi)({
7448
7781
  url: this.config.url({
7449
7782
  path: "/audio/transcriptions",
7450
7783
  modelId: this.modelId
7451
7784
  }),
7452
- headers: (0, import_provider_utils35.combineHeaders)(this.config.headers(), options.headers),
7785
+ headers: (0, import_provider_utils36.combineHeaders)(this.config.headers(), options.headers),
7453
7786
  formData,
7454
7787
  failedResponseHandler: openaiFailedResponseHandler,
7455
- successfulResponseHandler: (0, import_provider_utils35.createJsonResponseHandler)(
7788
+ successfulResponseHandler: (0, import_provider_utils36.createJsonResponseHandler)(
7456
7789
  openaiTranscriptionResponseSchema
7457
7790
  ),
7458
7791
  abortSignal: options.abortSignal,
@@ -7484,21 +7817,21 @@ var OpenAITranscriptionModel = class {
7484
7817
  };
7485
7818
 
7486
7819
  // src/version.ts
7487
- var VERSION = true ? "3.0.98" : "0.0.0-test";
7820
+ var VERSION = true ? "3.0.100" : "0.0.0-test";
7488
7821
 
7489
7822
  // src/openai-provider.ts
7490
7823
  function createOpenAI(options = {}) {
7491
7824
  var _a, _b;
7492
- const baseURL = (_a = (0, import_provider_utils36.withoutTrailingSlash)(
7493
- (0, import_provider_utils36.loadOptionalSetting)({
7825
+ const baseURL = (_a = (0, import_provider_utils37.withoutTrailingSlash)(
7826
+ (0, import_provider_utils37.loadOptionalSetting)({
7494
7827
  settingValue: options.baseURL,
7495
7828
  environmentVariableName: "OPENAI_BASE_URL"
7496
7829
  })
7497
7830
  )) != null ? _a : "https://api.openai.com/v1";
7498
7831
  const providerName = (_b = options.name) != null ? _b : "openai";
7499
- const getHeaders = () => (0, import_provider_utils36.withUserAgentSuffix)(
7832
+ const getHeaders = () => (0, import_provider_utils37.withUserAgentSuffix)(
7500
7833
  {
7501
- Authorization: `Bearer ${(0, import_provider_utils36.loadApiKey)({
7834
+ Authorization: `Bearer ${(0, import_provider_utils37.loadApiKey)({
7502
7835
  apiKey: options.apiKey,
7503
7836
  environmentVariableName: "OPENAI_API_KEY",
7504
7837
  description: "OpenAI"