From ef716e9b7fd764a0b5734b648674457783288ef6 Mon Sep 17 00:00:00 2001 From: xiaoqianWX Date: Thu, 12 Feb 2026 11:54:33 +0800 Subject: [PATCH] Add Codex model pricing and remove -codex suffix stripping - Add pricing for gpt-5.1-codex, gpt-5.1-codex-max, gpt-5.1-codex-mini, gpt-5.3-codex - Fix gpt-5.1-codex-mini/max pricing (values were swapped) - Remove -codex suffix fallback in normalizeCodexModel to ensure exact pricing lookups - Bump cost-usage cache schema to v2 to invalidate stale normalized keys Co-Authored-By: Claude Opus 4.6 --- .../Vendored/CostUsage/CostUsageCache.swift | 2 +- .../Vendored/CostUsage/CostUsagePricing.swift | 20 +++++++++++++++---- .../CodexBarTests/CostUsagePricingTests.swift | 4 +--- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Sources/CodexBarCore/Vendored/CostUsage/CostUsageCache.swift b/Sources/CodexBarCore/Vendored/CostUsage/CostUsageCache.swift index e56131a41..415d2e96d 100644 --- a/Sources/CodexBarCore/Vendored/CostUsage/CostUsageCache.swift +++ b/Sources/CodexBarCore/Vendored/CostUsage/CostUsageCache.swift @@ -10,7 +10,7 @@ enum CostUsageCacheIO { let root = cacheRoot ?? self.defaultCacheRoot() return root .appendingPathComponent("cost-usage", isDirectory: true) - .appendingPathComponent("\(provider.rawValue)-v1.json", isDirectory: false) + .appendingPathComponent("\(provider.rawValue)-v2.json", isDirectory: false) } static func load(provider: UsageProvider, cacheRoot: URL? = nil) -> CostUsageCache { diff --git a/Sources/CodexBarCore/Vendored/CostUsage/CostUsagePricing.swift b/Sources/CodexBarCore/Vendored/CostUsage/CostUsagePricing.swift index 0e6557a66..3f0221289 100644 --- a/Sources/CodexBarCore/Vendored/CostUsage/CostUsagePricing.swift +++ b/Sources/CodexBarCore/Vendored/CostUsage/CostUsagePricing.swift @@ -33,6 +33,18 @@ enum CostUsagePricing { inputCostPerToken: 1.25e-6, outputCostPerToken: 1e-5, cacheReadInputCostPerToken: 1.25e-7), + "gpt-5.1-codex": CodexPricing( + inputCostPerToken: 1.25e-6, + outputCostPerToken: 1e-5, + cacheReadInputCostPerToken: 1.25e-7), + "gpt-5.1-codex-mini": CodexPricing( + inputCostPerToken: 2.5e-7, + outputCostPerToken: 2e-6, + cacheReadInputCostPerToken: 2.5e-8), + "gpt-5.1-codex-max": CodexPricing( + inputCostPerToken: 1.25e-6, + outputCostPerToken: 1e-5, + cacheReadInputCostPerToken: 1.25e-7), "gpt-5.2": CodexPricing( inputCostPerToken: 1.75e-6, outputCostPerToken: 1.4e-5, @@ -41,6 +53,10 @@ enum CostUsagePricing { inputCostPerToken: 1.75e-6, outputCostPerToken: 1.4e-5, cacheReadInputCostPerToken: 1.75e-7), + "gpt-5.3-codex": CodexPricing( + inputCostPerToken: 1.75e-6, + outputCostPerToken: 1.4e-5, + cacheReadInputCostPerToken: 1.75e-7), ] private static let claude: [String: ClaudePricing] = [ @@ -161,10 +177,6 @@ enum CostUsagePricing { if trimmed.hasPrefix("openai/") { trimmed = String(trimmed.dropFirst("openai/".count)) } - if let codexRange = trimmed.range(of: "-codex") { - let base = String(trimmed[..