diff --git a/src/api/providers/unbound.ts b/src/api/providers/unbound.ts index 23e419c..921f07b 100644 --- a/src/api/providers/unbound.ts +++ b/src/api/providers/unbound.ts @@ -106,10 +106,20 @@ export class UnboundHandler implements ApiHandler, SingleCompletionHandler { } if (usage) { - yield { - type: "usage", - inputTokens: usage?.prompt_tokens || 0, - outputTokens: usage?.completion_tokens || 0, + if (this.getModel().id.startsWith("anthropic/")) { + yield { + type: "usage", + inputTokens: usage?.prompt_tokens || 0, + outputTokens: usage?.completion_tokens || 0, + cacheWriteTokens: (usage as any)?.cache_creation_input_tokens || 0, + cacheReadTokens: (usage as any)?.cache_read_input_tokens || 0, + } + } else { + yield { + type: "usage", + inputTokens: usage?.prompt_tokens || 0, + outputTokens: usage?.completion_tokens || 0, + } } } }