feat: enable prompt caching and cache token tracking for google-vertex-anthropic (#20266)

Signed-off-by: Major Hayden <major@mhtx.net>
This commit is contained in:
Major Hayden
2026-03-31 15:16:14 -05:00
committed by GitHub
parent 4dd866d5c4
commit 26cc924ea2
4 changed files with 78 additions and 0 deletions

View File

@@ -257,6 +257,9 @@ export namespace Session {
const cacheReadInputTokens = safe(input.usage.cachedInputTokens ?? 0)
const cacheWriteInputTokens = safe(
(input.metadata?.["anthropic"]?.["cacheCreationInputTokens"] ??
// google-vertex-anthropic returns metadata under "vertex" key
// (AnthropicMessagesLanguageModel custom provider key from 'vertex.anthropic.messages')
input.metadata?.["vertex"]?.["cacheCreationInputTokens"] ??
// @ts-expect-error
input.metadata?.["bedrock"]?.["usage"]?.["cacheWriteInputTokens"] ??
// @ts-expect-error