@ai-sdk/openai 3.0.72 → 3.0.74

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 3.0.74
4
+
5
+ ### Patch Changes
6
+
7
+ - 466544d: feat(openai): add orchestration token usage details to Responses API usage
8
+
9
+ ## 3.0.73
10
+
11
+ ### Patch Changes
12
+
13
+ - 1274c07: fix(provider/openai): send client-executed tool calls as full function_call items in the Responses API so they pair with their function_call_output by call_id
14
+
3
15
  ## 3.0.72
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -229,9 +229,12 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
229
229
  output_tokens: number;
230
230
  input_tokens_details?: {
231
231
  cached_tokens?: number | null | undefined;
232
+ orchestration_input_tokens?: number | null | undefined;
233
+ orchestration_input_cached_tokens?: number | null | undefined;
232
234
  } | null | undefined;
233
235
  output_tokens_details?: {
234
236
  reasoning_tokens?: number | null | undefined;
237
+ orchestration_output_tokens?: number | null | undefined;
235
238
  } | null | undefined;
236
239
  };
237
240
  incomplete_details?: {
@@ -254,9 +257,12 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
254
257
  output_tokens: number;
255
258
  input_tokens_details?: {
256
259
  cached_tokens?: number | null | undefined;
260
+ orchestration_input_tokens?: number | null | undefined;
261
+ orchestration_input_cached_tokens?: number | null | undefined;
257
262
  } | null | undefined;
258
263
  output_tokens_details?: {
259
264
  reasoning_tokens?: number | null | undefined;
265
+ orchestration_output_tokens?: number | null | undefined;
260
266
  } | null | undefined;
261
267
  } | null | undefined;
262
268
  service_tier?: string | null | undefined;
package/dist/index.d.ts CHANGED
@@ -229,9 +229,12 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
229
229
  output_tokens: number;
230
230
  input_tokens_details?: {
231
231
  cached_tokens?: number | null | undefined;
232
+ orchestration_input_tokens?: number | null | undefined;
233
+ orchestration_input_cached_tokens?: number | null | undefined;
232
234
  } | null | undefined;
233
235
  output_tokens_details?: {
234
236
  reasoning_tokens?: number | null | undefined;
237
+ orchestration_output_tokens?: number | null | undefined;
235
238
  } | null | undefined;
236
239
  };
237
240
  incomplete_details?: {
@@ -254,9 +257,12 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
254
257
  output_tokens: number;
255
258
  input_tokens_details?: {
256
259
  cached_tokens?: number | null | undefined;
260
+ orchestration_input_tokens?: number | null | undefined;
261
+ orchestration_input_cached_tokens?: number | null | undefined;
257
262
  } | null | undefined;
258
263
  output_tokens_details?: {
259
264
  reasoning_tokens?: number | null | undefined;
265
+ orchestration_output_tokens?: number | null | undefined;
260
266
  } | null | undefined;
261
267
  } | null | undefined;
262
268
  service_tier?: string | null | undefined;
package/dist/index.js CHANGED
@@ -2751,7 +2751,7 @@ async function convertToOpenAIResponsesInput({
2751
2751
  hasApplyPatchTool = false,
2752
2752
  customProviderToolNames
2753
2753
  }) {
2754
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
2754
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
2755
2755
  let input = [];
2756
2756
  const warnings = [];
2757
2757
  const processedApprovalIds = /* @__PURE__ */ new Set();
@@ -2888,10 +2888,11 @@ async function convertToOpenAIResponsesInput({
2888
2888
  }
2889
2889
  break;
2890
2890
  }
2891
- if (store && id != null) {
2892
- if (hasPreviousResponseId) {
2893
- break;
2894
- }
2891
+ if (hasPreviousResponseId && store && id != null) {
2892
+ break;
2893
+ }
2894
+ const isProviderDefinedToolCall = hasLocalShellTool && resolvedToolName === "local_shell" || hasShellTool && resolvedToolName === "shell" || hasApplyPatchTool && resolvedToolName === "apply_patch" || ((_m = customProviderToolNames == null ? void 0 : customProviderToolNames.has(resolvedToolName)) != null ? _m : false);
2895
+ if (store && id != null && isProviderDefinedToolCall) {
2895
2896
  input.push({ type: "item_reference", id });
2896
2897
  break;
2897
2898
  }
@@ -2962,7 +2963,6 @@ async function convertToOpenAIResponsesInput({
2962
2963
  call_id: part.toolCallId,
2963
2964
  name: resolvedToolName,
2964
2965
  arguments: serializeToolCallArguments2(part.input),
2965
- id,
2966
2966
  ...namespace != null && { namespace }
2967
2967
  });
2968
2968
  break;
@@ -2979,7 +2979,7 @@ async function convertToOpenAIResponsesInput({
2979
2979
  part.toolName
2980
2980
  );
2981
2981
  if (resolvedResultToolName === "tool_search") {
2982
- const itemId = (_o = (_n = (_m = part.providerOptions) == null ? void 0 : _m[providerOptionsName]) == null ? void 0 : _n.itemId) != null ? _o : part.toolCallId;
2982
+ const itemId = (_p = (_o = (_n = part.providerOptions) == null ? void 0 : _n[providerOptionsName]) == null ? void 0 : _o.itemId) != null ? _p : part.toolCallId;
2983
2983
  if (store) {
2984
2984
  input.push({ type: "item_reference", id: itemId });
2985
2985
  } else if (part.output.type === "json") {
@@ -3020,7 +3020,7 @@ async function convertToOpenAIResponsesInput({
3020
3020
  break;
3021
3021
  }
3022
3022
  if (store) {
3023
- const itemId = (_r = (_q = (_p = part.providerOptions) == null ? void 0 : _p[providerOptionsName]) == null ? void 0 : _q.itemId) != null ? _r : part.toolCallId;
3023
+ const itemId = (_s = (_r = (_q = part.providerOptions) == null ? void 0 : _q[providerOptionsName]) == null ? void 0 : _r.itemId) != null ? _s : part.toolCallId;
3024
3024
  input.push({ type: "item_reference", id: itemId });
3025
3025
  } else {
3026
3026
  warnings.push({
@@ -3130,7 +3130,7 @@ async function convertToOpenAIResponsesInput({
3130
3130
  }
3131
3131
  const output = part.output;
3132
3132
  if (output.type === "execution-denied") {
3133
- const approvalId = (_t = (_s = output.providerOptions) == null ? void 0 : _s.openai) == null ? void 0 : _t.approvalId;
3133
+ const approvalId = (_u = (_t = output.providerOptions) == null ? void 0 : _t.openai) == null ? void 0 : _u.approvalId;
3134
3134
  if (approvalId) {
3135
3135
  continue;
3136
3136
  }
@@ -3204,7 +3204,7 @@ async function convertToOpenAIResponsesInput({
3204
3204
  outputValue = output.value;
3205
3205
  break;
3206
3206
  case "execution-denied":
3207
- outputValue = (_u = output.reason) != null ? _u : "Tool execution denied.";
3207
+ outputValue = (_v = output.reason) != null ? _v : "Tool execution denied.";
3208
3208
  break;
3209
3209
  case "json":
3210
3210
  case "error-json":
@@ -3265,7 +3265,7 @@ async function convertToOpenAIResponsesInput({
3265
3265
  contentValue = output.value;
3266
3266
  break;
3267
3267
  case "execution-denied":
3268
- contentValue = (_v = output.reason) != null ? _v : "Tool execution denied.";
3268
+ contentValue = (_w = output.reason) != null ? _w : "Tool execution denied.";
3269
3269
  break;
3270
3270
  case "json":
3271
3271
  case "error-json":
@@ -3405,9 +3405,16 @@ var openaiResponsesChunkSchema = (0, import_provider_utils27.lazySchema)(
3405
3405
  incomplete_details: import_v422.z.object({ reason: import_v422.z.string() }).nullish(),
3406
3406
  usage: import_v422.z.object({
3407
3407
  input_tokens: import_v422.z.number(),
3408
- input_tokens_details: import_v422.z.object({ cached_tokens: import_v422.z.number().nullish() }).nullish(),
3408
+ input_tokens_details: import_v422.z.object({
3409
+ cached_tokens: import_v422.z.number().nullish(),
3410
+ orchestration_input_tokens: import_v422.z.number().nullish(),
3411
+ orchestration_input_cached_tokens: import_v422.z.number().nullish()
3412
+ }).nullish(),
3409
3413
  output_tokens: import_v422.z.number(),
3410
- output_tokens_details: import_v422.z.object({ reasoning_tokens: import_v422.z.number().nullish() }).nullish()
3414
+ output_tokens_details: import_v422.z.object({
3415
+ reasoning_tokens: import_v422.z.number().nullish(),
3416
+ orchestration_output_tokens: import_v422.z.number().nullish()
3417
+ }).nullish()
3411
3418
  }),
3412
3419
  service_tier: import_v422.z.string().nullish()
3413
3420
  })
@@ -3422,9 +3429,16 @@ var openaiResponsesChunkSchema = (0, import_provider_utils27.lazySchema)(
3422
3429
  incomplete_details: import_v422.z.object({ reason: import_v422.z.string() }).nullish(),
3423
3430
  usage: import_v422.z.object({
3424
3431
  input_tokens: import_v422.z.number(),
3425
- input_tokens_details: import_v422.z.object({ cached_tokens: import_v422.z.number().nullish() }).nullish(),
3432
+ input_tokens_details: import_v422.z.object({
3433
+ cached_tokens: import_v422.z.number().nullish(),
3434
+ orchestration_input_tokens: import_v422.z.number().nullish(),
3435
+ orchestration_input_cached_tokens: import_v422.z.number().nullish()
3436
+ }).nullish(),
3426
3437
  output_tokens: import_v422.z.number(),
3427
- output_tokens_details: import_v422.z.object({ reasoning_tokens: import_v422.z.number().nullish() }).nullish()
3438
+ output_tokens_details: import_v422.z.object({
3439
+ reasoning_tokens: import_v422.z.number().nullish(),
3440
+ orchestration_output_tokens: import_v422.z.number().nullish()
3441
+ }).nullish()
3428
3442
  }).nullish(),
3429
3443
  service_tier: import_v422.z.string().nullish()
3430
3444
  })
@@ -4208,9 +4222,16 @@ var openaiResponsesResponseSchema = (0, import_provider_utils27.lazySchema)(
4208
4222
  incomplete_details: import_v422.z.object({ reason: import_v422.z.string() }).nullish(),
4209
4223
  usage: import_v422.z.object({
4210
4224
  input_tokens: import_v422.z.number(),
4211
- input_tokens_details: import_v422.z.object({ cached_tokens: import_v422.z.number().nullish() }).nullish(),
4225
+ input_tokens_details: import_v422.z.object({
4226
+ cached_tokens: import_v422.z.number().nullish(),
4227
+ orchestration_input_tokens: import_v422.z.number().nullish(),
4228
+ orchestration_input_cached_tokens: import_v422.z.number().nullish()
4229
+ }).nullish(),
4212
4230
  output_tokens: import_v422.z.number(),
4213
- output_tokens_details: import_v422.z.object({ reasoning_tokens: import_v422.z.number().nullish() }).nullish()
4231
+ output_tokens_details: import_v422.z.object({
4232
+ reasoning_tokens: import_v422.z.number().nullish(),
4233
+ orchestration_output_tokens: import_v422.z.number().nullish()
4234
+ }).nullish()
4214
4235
  }).optional()
4215
4236
  })
4216
4237
  )
@@ -6845,7 +6866,7 @@ var OpenAITranscriptionModel = class {
6845
6866
  };
6846
6867
 
6847
6868
  // src/version.ts
6848
- var VERSION = true ? "3.0.72" : "0.0.0-test";
6869
+ var VERSION = true ? "3.0.74" : "0.0.0-test";
6849
6870
 
6850
6871
  // src/openai-provider.ts
6851
6872
  function createOpenAI(options = {}) {