Skip to content

Add grok-4.6, which is missing entirely - #584

Closed
xyzs996 wants to merge 2 commits into
pydantic:mainfrom
xyzs996:add-grok-4-6
Closed

xyzs996 wants to merge 2 commits into
pydantic:mainfrom
xyzs996:add-grok-4-6

Conversation

@xyzs996

@xyzs996 xyzs996 commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

xAI shipped Grok 4.6 on 2026-08-12 and it is their current flagship, but this repo has no row for it. Today:

>>> from genai_prices import calc_price, Usage
>>> calc_price(Usage(input_tokens=1000), 'grok-4.6', provider_id='x-ai')
LookupError: Unable to find model with model_ref='grok-4.6' in x-ai

This adds it, with the long-context tier it ships with.

Prices

base at/above 200k prompt tokens
input_mtok 2 4
cache_read_mtok 0.5 1
output_mtok 6 12

context_window: 500000.

Note the cache-read base of 0.50 is genuinely 4.6's number — grok-4.5 is 0.30. (That distinction is why #583 corrects 4.5's row; this branch is cut from main and doesn't touch 4.5.)

Sources

Four, agreeing exactly:

  1. xAI's own docs — https://docs.x.ai/docs/models/grok-4.6: "Requests whose prompt reaches 200k tokens are billed at the higher rate for all tokens in the request."
  2. OpenRouter's live API — 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"}]}
  3. models.dev — xai/grok-4.6 carries cost {input 2, cache_read 0.5, output 6} plus tiers[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.
  4. The sibling rows in this repo — same 2x-at-200k structure as grok-4.5, grok-4.3, grok-4.20 and grok-build-0.1.

Cliff, not a marginal tier

TieredPrices already 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:

500k-token prompt, cliff (correct)    500_000 x $4  = $2.00
500k-token prompt, read as marginal   200_000 x $2
                                    + 300_000 x $4  = $1.40

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

TieredPrices resolves with total_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-latest currently matches grok-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 only grok-4.6, grok-4.6-latest, the dated grok-4.6-YYYYMMDD forms and their x-ai/ prefixes.

Tests

test_grok_4_6_long_context_cliff pins 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

make lint       61 files already formatted; all checks passed
make typecheck  0 errors, 0 warnings, 0 notes
make test       854 passed, 41 xfailed, 100.00% coverage
npm run ci      1852 passed, 1 skipped

Generated payloads rebuilt with make build; the only non-x_ai.yml source change is the provider model count in README.md (17 → 18), written by inject_providers.

Review in cubic

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.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 7 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread prices/providers/x_ai.yml Resolved
xyzs996 added a commit to xyzs996/genai-prices that referenced this pull request Aug 22, 2026
…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.
@xyzs996

xyzs996 commented Aug 22, 2026

Copy link
Copy Markdown
Contributor Author

Note for whoever reviews these together: I briefly pushed grok-4.6 onto #583's branch by mistake and have reverted it (7482098), so this PR is still the only place grok-4.6 is added and the two branches do not overlap. #586 was a third duplicate of the same file and is closed.

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.
@xyzs996

xyzs996 commented Aug 23, 2026

Copy link
Copy Markdown
Contributor Author

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 < 200k prompt tokens / >= 200k prompt tokens, and the footnote says a request whose prompt reaches the threshold is billed at the higher rate for every token. Tiers here fire on total_input_tokens > tier.start, so start: 200000 billed an exactly-200,000-token prompt at the base rate. Now start: 199999, and the cliff test pins 199,999 vs 200,000 instead of 200,000 vs 200,001.

Same question hangs over the 37 pre-existing start: 272000 OpenAI entries, but their page only labels the cheap column "<272K context length" and says nothing about 272000 itself, so I left those alone — your call.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread tests/test_price_calc.py
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')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

@dsfaccini

Copy link
Copy Markdown
Contributor

This comment was posted by Codex Desktop using gpt-5.6-sol on behalf of David.

Consolidated in #615, which has now merged. Thank you @xyzs996 — your original commit authorship was preserved in #615 so your contribution remains credited.

@dsfaccini dsfaccini closed this Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants