fix(ai): price anthropic 1h cache writes at 2x input (#5738)

anthropic 1h cache writes were billed at the 5m rate; split the bucket and price the 1h portion correctly
This commit is contained in:
Bucky
2026-06-15 15:21:14 +08:00
committed by GitHub
parent a851968170
commit 0be5bb6c96
4 changed files with 93 additions and 1 deletions

View File

@@ -535,6 +535,7 @@ export const streamAnthropic: StreamFunction<"anthropic-messages", AnthropicOpti
output.usage.output = event.message.usage.output_tokens || 0;
output.usage.cacheRead = event.message.usage.cache_read_input_tokens || 0;
output.usage.cacheWrite = event.message.usage.cache_creation_input_tokens || 0;
output.usage.cacheWrite1h = event.message.usage.cache_creation?.ephemeral_1h_input_tokens || 0;
// Anthropic doesn't provide total_tokens, compute from components
output.usage.totalTokens =
output.usage.input + output.usage.output + output.usage.cacheRead + output.usage.cacheWrite;