Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

fix(callLogs): support Claude format usage and include cache tokens (#476)

Prakersh Maheshwari4953727aa718
diff --git a/src/lib/usage/callLogs.ts b/src/lib/usage/callLogs.ts
index 8c6bfc5875..c58e6496c6 100644
--- a/src/lib/usage/callLogs.ts
+++ b/src/lib/usage/callLogs.ts
@@ -184,8 +184,11 @@ export async function saveCallLog(entry: any) {
account,
connectionId: entry.connectionId || null,
duration: entry.duration || 0,
- tokensIn: entry.tokens?.prompt_tokens || 0,
- tokensOut: entry.tokens?.completion_tokens || 0,
+ tokensIn:
+ (entry.tokens?.prompt_tokens || entry.tokens?.input_tokens || 0) +
+ (entry.tokens?.cache_read_input_tokens || entry.tokens?.cached_tokens || 0) +
+ (entry.tokens?.cache_creation_input_tokens || 0),
+ tokensOut: entry.tokens?.completion_tokens || entry.tokens?.output_tokens || 0,
requestType: entry.requestType || null,
sourceFormat: entry.sourceFormat || null,
targetFormat: entry.targetFormat || null,