@ai-sdk/anthropic 2.0.56 → 2.0.58

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.
@@ -497,8 +497,10 @@ var anthropicMessagesChunkSchema = lazySchema2(
497
497
  }).nullish()
498
498
  }),
499
499
  usage: z2.looseObject({
500
+ input_tokens: z2.number().nullish(),
500
501
  output_tokens: z2.number(),
501
- cache_creation_input_tokens: z2.number().nullish()
502
+ cache_creation_input_tokens: z2.number().nullish(),
503
+ cache_read_input_tokens: z2.number().nullish()
502
504
  })
503
505
  }),
504
506
  z2.object({
@@ -2745,8 +2747,17 @@ var AnthropicMessagesLanguageModel = class {
2745
2747
  return;
2746
2748
  }
2747
2749
  case "message_delta": {
2750
+ if (value.usage.input_tokens != null && usage.inputTokens !== value.usage.input_tokens) {
2751
+ usage.inputTokens = value.usage.input_tokens;
2752
+ }
2748
2753
  usage.outputTokens = value.usage.output_tokens;
2749
- usage.totalTokens = ((_f = usage.inputTokens) != null ? _f : 0) + ((_g = value.usage.output_tokens) != null ? _g : 0);
2754
+ if (value.usage.cache_read_input_tokens != null) {
2755
+ usage.cachedInputTokens = value.usage.cache_read_input_tokens;
2756
+ }
2757
+ if (value.usage.cache_creation_input_tokens != null) {
2758
+ cacheCreationInputTokens = value.usage.cache_creation_input_tokens;
2759
+ }
2760
+ usage.totalTokens = ((_f = usage.inputTokens) != null ? _f : 0) + ((_g = usage.outputTokens) != null ? _g : 0);
2750
2761
  finishReason = mapAnthropicStopReason({
2751
2762
  finishReason: value.delta.stop_reason,
2752
2763
  isJsonResponseFromTool: usesJsonResponseTool