Skip to content

Commit ef716e9

Browse files
xiaoqianWXclaude
andcommitted
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 <noreply@anthropic.com>
1 parent f493450 commit ef716e9

3 files changed

Lines changed: 18 additions & 8 deletions

File tree

Sources/CodexBarCore/Vendored/CostUsage/CostUsageCache.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ enum CostUsageCacheIO {
1010
let root = cacheRoot ?? self.defaultCacheRoot()
1111
return root
1212
.appendingPathComponent("cost-usage", isDirectory: true)
13-
.appendingPathComponent("\(provider.rawValue)-v1.json", isDirectory: false)
13+
.appendingPathComponent("\(provider.rawValue)-v2.json", isDirectory: false)
1414
}
1515

1616
static func load(provider: UsageProvider, cacheRoot: URL? = nil) -> CostUsageCache {

Sources/CodexBarCore/Vendored/CostUsage/CostUsagePricing.swift

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ enum CostUsagePricing {
3333
inputCostPerToken: 1.25e-6,
3434
outputCostPerToken: 1e-5,
3535
cacheReadInputCostPerToken: 1.25e-7),
36+
"gpt-5.1-codex": CodexPricing(
37+
inputCostPerToken: 1.25e-6,
38+
outputCostPerToken: 1e-5,
39+
cacheReadInputCostPerToken: 1.25e-7),
40+
"gpt-5.1-codex-mini": CodexPricing(
41+
inputCostPerToken: 2.5e-7,
42+
outputCostPerToken: 2e-6,
43+
cacheReadInputCostPerToken: 2.5e-8),
44+
"gpt-5.1-codex-max": CodexPricing(
45+
inputCostPerToken: 1.25e-6,
46+
outputCostPerToken: 1e-5,
47+
cacheReadInputCostPerToken: 1.25e-7),
3648
"gpt-5.2": CodexPricing(
3749
inputCostPerToken: 1.75e-6,
3850
outputCostPerToken: 1.4e-5,
@@ -41,6 +53,10 @@ enum CostUsagePricing {
4153
inputCostPerToken: 1.75e-6,
4254
outputCostPerToken: 1.4e-5,
4355
cacheReadInputCostPerToken: 1.75e-7),
56+
"gpt-5.3-codex": CodexPricing(
57+
inputCostPerToken: 1.75e-6,
58+
outputCostPerToken: 1.4e-5,
59+
cacheReadInputCostPerToken: 1.75e-7),
4460
]
4561

4662
private static let claude: [String: ClaudePricing] = [
@@ -161,10 +177,6 @@ enum CostUsagePricing {
161177
if trimmed.hasPrefix("openai/") {
162178
trimmed = String(trimmed.dropFirst("openai/".count))
163179
}
164-
if let codexRange = trimmed.range(of: "-codex") {
165-
let base = String(trimmed[..<codexRange.lowerBound])
166-
if self.codex[base] != nil { return base }
167-
}
168180
return trimmed
169181
}
170182

Tests/CodexBarTests/CostUsagePricingTests.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ import Testing
55
struct CostUsagePricingTests {
66
@Test
77
func normalizesCodexModelVariants() {
8-
#expect(CostUsagePricing.normalizeCodexModel("openai/gpt-5-codex") == "gpt-5")
9-
#expect(CostUsagePricing.normalizeCodexModel("gpt-5.2-codex") == "gpt-5.2")
10-
#expect(CostUsagePricing.normalizeCodexModel("gpt-5.1-codex-max") == "gpt-5.1")
8+
#expect(CostUsagePricing.normalizeCodexModel("openai/gpt-5-codex") == "gpt-5-codex")
119
}
1210

1311
@Test

0 commit comments

Comments
 (0)