@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.
package/dist/index.mjs CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  } from "@ai-sdk/provider-utils";
12
12
 
13
13
  // src/version.ts
14
- var VERSION = true ? "2.0.56" : "0.0.0-test";
14
+ var VERSION = true ? "2.0.58" : "0.0.0-test";
15
15
 
16
16
  // src/anthropic-messages-language-model.ts
17
17
  import {
@@ -512,8 +512,10 @@ var anthropicMessagesChunkSchema = lazySchema2(
512
512
  }).nullish()
513
513
  }),
514
514
  usage: z2.looseObject({
515
+ input_tokens: z2.number().nullish(),
515
516
  output_tokens: z2.number(),
516
- cache_creation_input_tokens: z2.number().nullish()
517
+ cache_creation_input_tokens: z2.number().nullish(),
518
+ cache_read_input_tokens: z2.number().nullish()
517
519
  })
518
520
  }),
519
521
  z2.object({
@@ -2760,8 +2762,17 @@ var AnthropicMessagesLanguageModel = class {
2760
2762
  return;
2761
2763
  }
2762
2764
  case "message_delta": {
2765
+ if (value.usage.input_tokens != null && usage.inputTokens !== value.usage.input_tokens) {
2766
+ usage.inputTokens = value.usage.input_tokens;
2767
+ }
2763
2768
  usage.outputTokens = value.usage.output_tokens;
2764
- usage.totalTokens = ((_f = usage.inputTokens) != null ? _f : 0) + ((_g = value.usage.output_tokens) != null ? _g : 0);
2769
+ if (value.usage.cache_read_input_tokens != null) {
2770
+ usage.cachedInputTokens = value.usage.cache_read_input_tokens;
2771
+ }
2772
+ if (value.usage.cache_creation_input_tokens != null) {
2773
+ cacheCreationInputTokens = value.usage.cache_creation_input_tokens;
2774
+ }
2775
+ usage.totalTokens = ((_f = usage.inputTokens) != null ? _f : 0) + ((_g = usage.outputTokens) != null ? _g : 0);
2765
2776
  finishReason = mapAnthropicStopReason({
2766
2777
  finishReason: value.delta.stop_reason,
2767
2778
  isJsonResponseFromTool: usesJsonResponseTool