Repository navigation
Conversation
xAI shipped Grok 4.6 on 2026-08-12 and it is the current flagship, but there is no row for it here, so calc_price(model_ref='grok-4.6') raises LookupError. Adds it with the long-context tier it ships with: prompts at or above 200k tokens bill at double for every token in the request.
There was a problem hiding this comment.
All reported issues were addressed across 7 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
…ext tier" This reverts aada952. grok-4.6 is already covered by pydantic#584, which was cut from main precisely so it would not collide with this branch, and which carries four agreeing sources and a test. I added it here without checking my own open PRs first. Restoring the deliberate separation.
xAI's tables read "< 200k prompt tokens" and ">= 200k prompt tokens", and the footnote says a request whose prompt *reaches* the threshold is billed at the higher rate for every token. A tier here fires on tokens > start, so start had to be 199999 for a 200000-token prompt to land on the higher rate; at 200000 it was still billed base. The cliff test now pins both sides of the real boundary.
|
Pushed a correction to this branch. cubic flagged the "at or above" wording, but the wording was right and the data was wrong: xAI's tables read Same question hangs over the 37 pre-existing |
There was a problem hiding this comment.
1 issue found across 6 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="tests/test_price_calc.py">
<violation number="1" location="tests/test_price_calc.py:1158">
P2: The mixed-case assertion expects 1.182, but input alone is priced at the tier rate this test pins: 300_000 tokens at 4/Mtok = 1.20, plus cache reads 10_000*1/Mtok = 0.01 and output 1_000*12/Mtok = 0.012, for a total of 1.222. Since 1.182 is below the input bill alone, the assertion cannot pass with the higher tier active at 300k (tier.start is 199999 and calc_unit_price picks the tier when total_input_tokens > tier.start). Update the expected value to 1.222.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| under = calc_price(Usage(input_tokens=199_999), 'grok-4.6', provider_id='x-ai') | ||
| assert under.input_price == snapshot(Decimal('0.399998')) | ||
|
|
||
| at = calc_price(Usage(input_tokens=200_000), 'grok-4.6', provider_id='x-ai') |
There was a problem hiding this comment.
P2: The mixed-case assertion expects 1.182, but input alone is priced at the tier rate this test pins: 300_000 tokens at 4/Mtok = 1.20, plus cache reads 10_0001/Mtok = 0.01 and output 1_00012/Mtok = 0.012, for a total of 1.222. Since 1.182 is below the input bill alone, the assertion cannot pass with the higher tier active at 300k (tier.start is 199999 and calc_unit_price picks the tier when total_input_tokens > tier.start). Update the expected value to 1.222.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At tests/test_price_calc.py, line 1158:
<comment>The mixed-case assertion expects 1.182, but input alone is priced at the tier rate this test pins: 300_000 tokens at 4/Mtok = 1.20, plus cache reads 10_000*1/Mtok = 0.01 and output 1_000*12/Mtok = 0.012, for a total of 1.222. Since 1.182 is below the input bill alone, the assertion cannot pass with the higher tier active at 300k (tier.start is 199999 and calc_unit_price picks the tier when total_input_tokens > tier.start). Update the expected value to 1.222.</comment>
<file context>
@@ -1149,14 +1149,17 @@ def test_grok_4_6_long_context_cliff():
- over = calc_price(Usage(input_tokens=200_001), 'grok-4.6', provider_id='x-ai')
- assert over.input_price == snapshot(Decimal('0.800004'))
+ at = calc_price(Usage(input_tokens=200_000), 'grok-4.6', provider_id='x-ai')
+ assert at.input_price == snapshot(Decimal('0.8'))
</file context>
xAI shipped Grok 4.6 on 2026-08-12 and it is their current flagship, but this repo has no row for it. Today:
This adds it, with the long-context tier it ships with.
Prices
input_mtokcache_read_mtokoutput_mtokcontext_window: 500000.Note the cache-read base of 0.50 is genuinely 4.6's number —
grok-4.5is 0.30. (That distinction is why #583 corrects 4.5's row; this branch is cut frommainand doesn't touch 4.5.)Sources
Four, agreeing exactly:
x-ai/grok-4.6,context_length: 500000:{"prompt": "0.000002", "completion": "0.000006", "input_cache_read": "0.0000005", "overrides": [{"min_prompt_tokens": 200000, "prompt": "0.000004", "completion": "0.000012", "input_cache_read": "0.000001"}]}xai/grok-4.6carriescost {input 2, cache_read 0.5, output 6}plustiers[0] {input 4, cache_read 1, output 12, tier {type context, size 200000}}. Fifteen provider entries list the model; every one that resells at list price (openrouter, opencode, edenai, github-copilot, perplexity-agent, crossmodel, vercel, kilo, nano-gpt, abacus, ofox) carries these same numbers. The three that differ are marked-up or discounted resellers (bedrock 2.2/6.6, requesty 1.8/5.4, merge-gateway 1.5/4.5), which is the expected shape.grok-4.5,grok-4.3,grok-4.20andgrok-build-0.1.Cliff, not a marginal tier
TieredPricesalready means cliff, which is what xAI documents, so no code change is needed. Worth spelling out because it's a 43% difference at the top of the window:Grok 4.6 has the largest dear band of anything in this repo — 300k of its 500k advertised window, 60%, bills at the higher rate.
Boundary
TieredPricesresolves withtotal_input_tokens > tier.start, so exactly 200,000 tokens bills at base here, while xAI's "reaches 200k" reads as at-or-above. One token, and it's the repo-wide convention across every existing tiered row, so I've matched it rather than special-cased this model. Same note as #583 — flagging it once more so it's a known choice rather than an oversight.Not changed, worth a maintainer's call
grok-latestcurrently matchesgrok-4.5. With 4.6 released it's arguably stale, but repointing an alias is a routing decision with a blast radius beyond this PR, so I've left it alone and given 4.6 onlygrok-4.6,grok-4.6-latest, the datedgrok-4.6-YYYYMMDDforms and theirx-ai/prefixes.Tests
test_grok_4_6_long_context_cliffpins both sides of the threshold (200,000 → $0.40, 200,001 → $0.80), asserts a 500k prompt is $2.00 and explicitly not the $1.40 a marginal reading gives, and checks a mixed usage with cache reads and output resolves to $1.182.Verification
Generated payloads rebuilt with
make build; the only non-x_ai.ymlsource change is the provider model count inREADME.md(17 → 18), written byinject_providers.