@ai-sdk/openai 2.0.108 → 2.0.110

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2646,9 +2646,16 @@ var openaiResponsesChunkSchema = lazyValidator12(
2646
2646
  incomplete_details: z15.object({ reason: z15.string() }).nullish(),
2647
2647
  usage: z15.object({
2648
2648
  input_tokens: z15.number(),
2649
- input_tokens_details: z15.object({ cached_tokens: z15.number().nullish() }).nullish(),
2649
+ input_tokens_details: z15.object({
2650
+ cached_tokens: z15.number().nullish(),
2651
+ orchestration_input_tokens: z15.number().nullish(),
2652
+ orchestration_input_cached_tokens: z15.number().nullish()
2653
+ }).nullish(),
2650
2654
  output_tokens: z15.number(),
2651
- output_tokens_details: z15.object({ reasoning_tokens: z15.number().nullish() }).nullish()
2655
+ output_tokens_details: z15.object({
2656
+ reasoning_tokens: z15.number().nullish(),
2657
+ orchestration_output_tokens: z15.number().nullish()
2658
+ }).nullish()
2652
2659
  }),
2653
2660
  service_tier: z15.string().nullish()
2654
2661
  })
@@ -3071,9 +3078,16 @@ var openaiResponsesResponseSchema = lazyValidator12(
3071
3078
  incomplete_details: z15.object({ reason: z15.string() }).nullish(),
3072
3079
  usage: z15.object({
3073
3080
  input_tokens: z15.number(),
3074
- input_tokens_details: z15.object({ cached_tokens: z15.number().nullish() }).nullish(),
3081
+ input_tokens_details: z15.object({
3082
+ cached_tokens: z15.number().nullish(),
3083
+ orchestration_input_tokens: z15.number().nullish(),
3084
+ orchestration_input_cached_tokens: z15.number().nullish()
3085
+ }).nullish(),
3075
3086
  output_tokens: z15.number(),
3076
- output_tokens_details: z15.object({ reasoning_tokens: z15.number().nullish() }).nullish()
3087
+ output_tokens_details: z15.object({
3088
+ reasoning_tokens: z15.number().nullish(),
3089
+ orchestration_output_tokens: z15.number().nullish()
3090
+ }).nullish()
3077
3091
  }).optional()
3078
3092
  })
3079
3093
  )
@@ -4143,6 +4157,10 @@ var OpenAIResponsesLanguageModel = class {
4143
4157
  providerMetadata[providerKey].serviceTier = response.service_tier;
4144
4158
  }
4145
4159
  const usage = response.usage;
4160
+ const orchestrationUsage = getOrchestrationUsageMetadata(usage);
4161
+ if (orchestrationUsage != null) {
4162
+ providerMetadata[providerKey].usage = orchestrationUsage;
4163
+ }
4146
4164
  return {
4147
4165
  content,
4148
4166
  finishReason: mapOpenAIResponseFinishReason({
@@ -4208,6 +4226,7 @@ var OpenAIResponsesLanguageModel = class {
4208
4226
  let hasFunctionCall = false;
4209
4227
  const activeReasoning = {};
4210
4228
  let serviceTier;
4229
+ let orchestrationUsage;
4211
4230
  return {
4212
4231
  stream: response.pipeThrough(
4213
4232
  new TransformStream({
@@ -4608,6 +4627,9 @@ var OpenAIResponsesLanguageModel = class {
4608
4627
  if (typeof value.response.service_tier === "string") {
4609
4628
  serviceTier = value.response.service_tier;
4610
4629
  }
4630
+ orchestrationUsage = getOrchestrationUsageMetadata(
4631
+ value.response.usage
4632
+ );
4611
4633
  } else if (isResponseAnnotationAddedChunk(value)) {
4612
4634
  ongoingAnnotations.push(value.annotation);
4613
4635
  if (value.annotation.type === "url_citation") {
@@ -4651,6 +4673,9 @@ var OpenAIResponsesLanguageModel = class {
4651
4673
  if (serviceTier !== void 0) {
4652
4674
  providerMetadata[providerKey].serviceTier = serviceTier;
4653
4675
  }
4676
+ if (orchestrationUsage != null) {
4677
+ providerMetadata[providerKey].usage = orchestrationUsage;
4678
+ }
4654
4679
  controller.enqueue({
4655
4680
  type: "finish",
4656
4681
  finishReason,
@@ -4719,6 +4744,22 @@ function mapWebSearchOutput(action) {
4719
4744
  };
4720
4745
  }
4721
4746
  }
4747
+ function getOrchestrationUsageMetadata(usage) {
4748
+ var _a, _b, _c;
4749
+ const orchestrationInputTokens = (_a = usage == null ? void 0 : usage.input_tokens_details) == null ? void 0 : _a.orchestration_input_tokens;
4750
+ const orchestrationInputCachedTokens = (_b = usage == null ? void 0 : usage.input_tokens_details) == null ? void 0 : _b.orchestration_input_cached_tokens;
4751
+ const orchestrationOutputTokens = (_c = usage == null ? void 0 : usage.output_tokens_details) == null ? void 0 : _c.orchestration_output_tokens;
4752
+ if (orchestrationInputTokens == null && orchestrationInputCachedTokens == null && orchestrationOutputTokens == null) {
4753
+ return void 0;
4754
+ }
4755
+ return {
4756
+ ...orchestrationInputTokens != null && { orchestrationInputTokens },
4757
+ ...orchestrationInputCachedTokens != null && {
4758
+ orchestrationInputCachedTokens
4759
+ },
4760
+ ...orchestrationOutputTokens != null && { orchestrationOutputTokens }
4761
+ };
4762
+ }
4722
4763
  export {
4723
4764
  OpenAIChatLanguageModel,
4724
4765
  OpenAICompletionLanguageModel,