Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 62 additions & 5 deletions Sources/QuotaBarCore/Resources/Pricing/price-book.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,36 @@
"providers": {
"codex": {
"source": "https://developers.openai.com/api/docs/pricing",
"checkedAt": "2026-11-11",
"checkedAt": "2026-11-19",
"models": [
{
"id": "gpt-6.2-astra",
"showInSettings": true,
"periods": [
{
"rates": {
"input": 8, "output": 40, "cacheWrite": 10, "cacheRead": 0.4,
"thresholdTokens": 272000,
"inputAbove": 16, "outputAbove": 60, "cacheWriteAbove": 20, "cacheReadAbove": 0.8
},
"fastMultiplier": 2
}
]
},
{
"id": "gpt-6.2-sol",
"showInSettings": true,
"periods": [
{
"rates": {
"input": 2, "output": 10, "cacheWrite": 2.5, "cacheRead": 0.1,
"thresholdTokens": 272000,
"inputAbove": 4, "outputAbove": 15, "cacheWriteAbove": 5, "cacheReadAbove": 0.2
},
"fastMultiplier": 2
}
]
},
{
"id": "gpt-6-astra",
"showInSettings": true,
Expand Down Expand Up @@ -198,14 +226,22 @@
},
{
"id": "gpt-6-rosalind",
"note": "Life-sciences model, limited to approved research.",
"note": "OpenAI first listed the promotional rates on 2026-11-17 and guarantees them at least through 2026-12-31.",
"periods": [
{
"rates": {
"input": 15, "output": 75, "cacheWrite": 18.75, "cacheRead": 1.5,
"thresholdTokens": 272000,
"inputAbove": 30, "outputAbove": 112.5, "cacheWriteAbove": 37.5, "cacheReadAbove": 3
}
},
{
"from": "2026-11-17",
"rates": {
"input": 10, "output": 50, "cacheWrite": 12.5, "cacheRead": 1,
"thresholdTokens": 272000,
"inputAbove": 20, "outputAbove": 75, "cacheWriteAbove": 25, "cacheReadAbove": 2
}
}
]
},
Expand All @@ -223,11 +259,32 @@
{ "rates": { "input": 5, "output": 25, "cacheRead": 0.5 } }
]
},
{
"id": "gpt-6.2-astra-law",
"note": "Promotional rates apply at least through 2026-12-31.",
"periods": [
{
"rates": {
"input": 8, "output": 40, "cacheWrite": 10, "cacheRead": 0.4,
"thresholdTokens": 272000,
"inputAbove": 16, "outputAbove": 60, "cacheWriteAbove": 20, "cacheReadAbove": 0.8
}
}
]
},
{
"id": "gpt-6-astra-law",
"note": "Legal model configuration. Promotional pricing is available at least through 2026-12-31; no confirmed end date or subsequent rates. No published cache-write, long-context, or Fast rates.",
"note": "Promotional rates apply at least through 2026-12-31. The 2026-11-17 price list includes a long-context tier.",
"periods": [
{ "rates": { "input": 10, "output": 50, "cacheRead": 1 } }
{ "rates": { "input": 10, "output": 50, "cacheRead": 1 } },
{
"from": "2026-11-17",
"rates": {
"input": 10, "output": 50, "cacheRead": 1,
"thresholdTokens": 272000,
"inputAbove": 20, "outputAbove": 75, "cacheReadAbove": 2
}
}
]
},
{
Expand All @@ -240,7 +297,7 @@
},
"claude": {
"source": "https://platform.claude.com/docs/en/about-claude/pricing",
"checkedAt": "2026-11-11",
"checkedAt": "2026-11-19",
"models": [
{
"id": "claude-fable-5-2",
Expand Down
35 changes: 35 additions & 0 deletions Sources/QuotaBarTests/PriceBookTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ enum PriceBookTests {
Self.reportsStaleSources()
Self.publishedRates()
Self.novemberPublishedRates()
Self.november17OpenAIRates()
Self.rejectsMalformedBooks()
}

Expand Down Expand Up @@ -325,6 +326,40 @@ enum PriceBookTests {
}
}

private static func november17OpenAIRates() {
let book = PriceBook.bundled
let astra = ModelPricing(
input: 8, output: 40, cacheWrite: 10, cacheRead: 0.4, thresholdTokens: 272_000,
inputAbove: 16, outputAbove: 60, cacheWriteAbove: 20, cacheReadAbove: 0.8
)
let sol = ModelPricing(
input: 2, output: 10, cacheWrite: 2.5, cacheRead: 0.1, thresholdTokens: 272_000,
inputAbove: 4, outputAbove: 15, cacheWriteAbove: 5, cacheReadAbove: 0.2
)
for (id, expected) in [("gpt-6.2-astra", astra), ("gpt-6.2-sol", sol)] {
Harness.expectEqual(book.rates(for: id, provider: .codex, day: "2026-11-17"), expected,
"\(id) Standard rates at launch")
Harness.expectEqual(book.rates(for: id, provider: .codex, day: "2026-11-17", fast: true),
expected.scaled(by: 2), "\(id) Fast rates at launch")
}
let rosalind = ModelPricing(
input: 10, output: 50, cacheWrite: 12.5, cacheRead: 1, thresholdTokens: 272_000,
inputAbove: 20, outputAbove: 75, cacheWriteAbove: 25, cacheReadAbove: 2
)
Harness.expectEqual(book.rates(for: "gpt-6-rosalind", provider: .codex, day: "2026-11-16"),
rosalind.scaled(by: 1.5), "Rosalind retains its pre-promotion rates")
let law = ModelPricing(
input: 10, output: 50, cacheRead: 1, thresholdTokens: 272_000,
inputAbove: 20, outputAbove: 75, cacheReadAbove: 2
)
for (id, expected) in [("gpt-6-rosalind", rosalind), ("gpt-6-astra-law", law), ("gpt-6.2-astra-law", astra)] {
Harness.expectEqual(book.rates(for: id, provider: .codex, day: "2026-11-17"), expected,
"\(id) promotional rates include the published long-context tier")
Harness.expect(book.rates(for: id, provider: .codex, day: "2026-11-17", fast: true) == nil,
"\(id) has no published Fast rates")
}
}

private static func rejectsMalformedBooks() {
func book(models: String, schemaVersion: Int = 1) -> String {
"""
Expand Down
10 changes: 5 additions & 5 deletions docs/pricing.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Claude and OpenAI models that are on their makers' current price lists and still
"providers": {
"codex": {
"source": "https://developers.openai.com/api/docs/pricing",
"checkedAt": "2026-08-26",
"checkedAt": "2026-11-19",
"models": [
{
"id": "gpt-5.6-sol",
Expand All @@ -23,7 +23,7 @@ Claude and OpenAI models that are on their makers' current price lists and still
"thresholdTokens": 272000, "inputAbove": 8, "outputAbove": 30 },
"fastMultiplier": 2
},
{ "from": "2026-11-22", "rates": { "input": 5, "output": 30 } }
{ "from": "2026-12-01", "rates": { "input": 5, "output": 30 } }
]
}
]
Expand All @@ -44,8 +44,8 @@ A model has these keys:
A period has these keys:

- `from` is the first Gregorian day in the local time zone (`yyyy-MM-dd`) the rates apply to, regardless of the system calendar. Recording and query bounds use the same day keys. The first period has no `from` and covers every earlier day. Later periods need one, in ascending order.
- `rates` are USD per million tokens. `input` and `output` are required. `cacheWrite` is the five-minute rate. Leave `cacheWrite1h` out when it is 2x input, which is Anthropic's published ratio. Rates ending in `Above` need `thresholdTokens`. The third-party rates cache uses the same keys and rules.
- `fastMultiplier` prices Fast usage as that multiple of every rate in the period, cache rates included. It covers Codex's priority tier and Claude's Fast mode (`usage.speed: "fast"` in Claude Code transcripts). Leave it out and Fast usage of the model stays unpriced. Use `1` for a model that accepts Fast requests but bills them at Standard rates, such as Claude Opus 4.6.
- `rates` are USD per million tokens. `input` and `output` are required. `cacheWrite` is the five-minute Claude rate or the 30-minute OpenAI rate. The book does not distinguish OpenAI's 12-hour writes. Leave `cacheWrite1h` out when it is 2x input, which is Anthropic's published ratio. Rates ending in `Above` need `thresholdTokens`. The third-party rates cache uses the same keys and rules.
- `fastMultiplier` prices Fast usage as that multiple of every rate in the period, cache rates included. It covers Codex's Fast (priority) tier and Claude's Fast mode (`usage.speed: "fast"` in Claude Code transcripts). Leave it out and Fast usage of the model stays unpriced. Use `1` for a model that accepts Fast requests but bills them at Standard rates, such as Claude Opus 4.6. Codex logs marked Ultrafast currently resolve to Standard because the usage store distinguishes only Standard and Fast.

## Common changes

Expand All @@ -65,7 +65,7 @@ After any edit, update `checkedAt` for the provider or model you compared, then
make test
```

`PriceBookTests` loads the bundled book and fails on unknown keys, missing rates, unordered periods, duplicate names, or a listed model with no price today. It pins historical rates on 2026-09-25, the additions checked on 2026-11-11, and the GPT-5.6 Sol promotion ending on 2026-11-30, including Fast and long-context rates. Editing an old period fails; adding a new period does not. It prints a note when a provider was last checked more than 45 days ago.
`PriceBookTests` loads the bundled book and fails on unknown keys, missing rates, unordered periods, duplicate names, or a listed model with no price today. It pins historical rates on 2026-09-25, the November additions, the 2026-11-17 Rosalind and Astra for Law rate changes, and the GPT-5.6 Sol promotion ending on 2026-11-30, including Fast and long-context rates. Editing an old period fails; adding a new period does not. It prints a note when a provider was last checked more than 45 days ago.

## Models outside the book

Expand Down
Loading