From 426230015197c5e69875eac98125bdccb67eeaca Mon Sep 17 00:00:00 2001 From: kesslerio Date: Fri, 5 Jun 2026 20:35:12 -0700 Subject: [PATCH 1/2] feat(cost): add pricing metadata for new flagship and cloud models Signed-off-by: kesslerio --- lib/server/cost-utils.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/server/cost-utils.js b/lib/server/cost-utils.js index 43788630..be220ecd 100644 --- a/lib/server/cost-utils.js +++ b/lib/server/cost-utils.js @@ -56,6 +56,14 @@ const kGlobalModelPricing = { "gemini-3.1-pro-preview": { input: 2.0, output: 12.0 }, "gemini-3-flash-preview": { input: 0.5, output: 3.0 }, "gemini-2.0-flash": { input: 0.1, output: 0.4 }, + "gpt-5.5": { input: 5.0, output: 30.0, cacheRead: 0.5, cacheWrite: 5.0 }, + "kimi-k2.6:cloud": { input: 0.8, output: 3.0, cacheRead: 0.1, cacheWrite: 0.8 }, + "deepseek-v4-flash:cloud": { input: 0.14, output: 0.28, cacheRead: 0.0028, cacheWrite: 0.14 }, + "glm-5.1:cloud": { input: 1.4, output: 4.4, cacheRead: 0.26, cacheWrite: 1.4 }, + "grok-4.3": { input: 1.25, output: 2.5, cacheRead: 0.2, cacheWrite: 1.25 }, + "qwen3-coder-next": { input: 0.11, output: 0.8, cacheRead: 0.0, cacheWrite: 0.11 }, + "gpt-5.4-mini": { input: 0.75, output: 3.0, cacheRead: 0.075, cacheWrite: 0.75 }, + "minimax-m3:cloud": { input: 0.6, output: 2.4, cacheRead: 0.06, cacheWrite: 0.6 }, }; const toInt = (value, fallbackValue = 0) => { From ed730c322be3ce40e2940cb9bb64ed714a8dd3c7 Mon Sep 17 00:00:00 2001 From: kesslerio Date: Fri, 5 Jun 2026 23:08:37 -0700 Subject: [PATCH 2/2] feat(cost): resolve prefix shadowing and align gpt-5.4-mini pricing Signed-off-by: kesslerio --- lib/server/cost-utils.js | 12 ++++++++---- tests/server/cost-utils.test.js | 27 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/lib/server/cost-utils.js b/lib/server/cost-utils.js index be220ecd..c0c84bb0 100644 --- a/lib/server/cost-utils.js +++ b/lib/server/cost-utils.js @@ -62,7 +62,7 @@ const kGlobalModelPricing = { "glm-5.1:cloud": { input: 1.4, output: 4.4, cacheRead: 0.26, cacheWrite: 1.4 }, "grok-4.3": { input: 1.25, output: 2.5, cacheRead: 0.2, cacheWrite: 1.25 }, "qwen3-coder-next": { input: 0.11, output: 0.8, cacheRead: 0.0, cacheWrite: 0.11 }, - "gpt-5.4-mini": { input: 0.75, output: 3.0, cacheRead: 0.075, cacheWrite: 0.75 }, + "gpt-5.4-mini": { input: 0.75, output: 4.5, cacheRead: 0.075, cacheWrite: 0.75 }, "minimax-m3:cloud": { input: 0.6, output: 2.4, cacheRead: 0.06, cacheWrite: 0.6 }, }; @@ -264,9 +264,13 @@ const resolvePricingFromFallbackMap = (model = "") => { if (!normalized) return null; const exact = kGlobalModelPricing[normalized]; if (exact) return exact; - const matchKey = Object.keys(kGlobalModelPricing).find((key) => - normalized.includes(key), - ); + const modelId = normalized.split("/").filter(Boolean).pop(); + if (modelId && kGlobalModelPricing[modelId]) { + return kGlobalModelPricing[modelId]; + } + const matchKey = Object.keys(kGlobalModelPricing) + .sort((a, b) => b.length - a.length) + .find((key) => normalized.includes(key)); return matchKey ? kGlobalModelPricing[matchKey] : null; }; diff --git a/tests/server/cost-utils.test.js b/tests/server/cost-utils.test.js index 53013284..52ba0751 100644 --- a/tests/server/cost-utils.test.js +++ b/tests/server/cost-utils.test.js @@ -29,4 +29,31 @@ describe("server/cost-utils", () => { expect(breakdown.pricingFound).toBe(true); expect(breakdown.totalCost).toBeCloseTo(5, 8); }); + + it("prices provider-qualified GPT-5.5 correctly without gpt-5 shadowing", () => { + const breakdown = deriveCostBreakdown({ + provider: "openai", + model: "openai/gpt-5.5", + inputTokens: 1_000_000, + outputTokens: 1_000_000, + }); + + expect(breakdown.pricingFound).toBe(true); + // GPT-5.5 is input: 5.0, output: 30.0 (total $35.0 per million) + // GPT-5 would be input: 1.25, output: 10.0 (total $11.25 per million) + expect(breakdown.totalCost).toBeCloseTo(35.0, 8); + }); + + it("prices provider-qualified GPT-5.4-mini correctly without gpt-5 shadowing", () => { + const breakdown = deriveCostBreakdown({ + provider: "openai", + model: "openai/gpt-5.4-mini", + inputTokens: 1_000_000, + outputTokens: 1_000_000, + }); + + expect(breakdown.pricingFound).toBe(true); + // GPT-5.4-mini is input: 0.75, output: 4.5 (total $5.25 per million) + expect(breakdown.totalCost).toBeCloseTo(5.25, 8); + }); });