From 1b3ce751558904c16843e764bc3c22a0006906ad Mon Sep 17 00:00:00 2001 From: Praveen Thirumurugan Date: Sat, 18 Oct 2025 01:40:56 +0530 Subject: [PATCH] fix: normalize model names to lowercase in cost calculation and proxy request handling --- cost.ts | 2 +- proxy.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cost.ts b/cost.ts index 22edc97..da02e0c 100644 --- a/cost.ts +++ b/cost.ts @@ -28,7 +28,7 @@ export function calculateCost(model: string, usage?: Usage): number | null { if (!usage) return null; const { prompt_tokens = 0, completion_tokens = 0, prompt_tokens_details = { cached_tokens: 0 } } = usage; - const cost = MODEL_COSTS[model] || MODEL_COSTS["default"]; + const cost = MODEL_COSTS[model.toLowerCase()] || MODEL_COSTS["default"]; let inputCost = 0; let cachedCost = 0; diff --git a/proxy.ts b/proxy.ts index ef6f063..6d7598f 100644 --- a/proxy.ts +++ b/proxy.ts @@ -163,7 +163,7 @@ const server = http.createServer(async (req, res) => { timestamp: new Date(), request_method: method, request_path: path, - model: requestJson?.model || "default", + model: (requestJson?.model || "default").toLowerCase(), completion_tokens: usage.completion_tokens || null, prompt_tokens: usage.prompt_tokens || null, total_tokens: usage.total_tokens || null,