fix: normalize model names to lowercase in cost calculation and proxy request handling

This commit is contained in:
Praveen Thirumurugan
2025-10-18 01:40:56 +05:30
parent ac59778c46
commit 1b3ce75155
2 changed files with 2 additions and 2 deletions

View File

@@ -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;

View File

@@ -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,