xAI Grok API pricing is per-token. As of August 21, 2026, docs.x.ai lists grok-4.6 (released August 12, xAI's recommended model for everything including code) and grok-4.5 at $2.00/M input and $6.00/M output on a 500k context, grok-4.3 at $1.25/M input and $2.50/M output on 1M context, grok-build-0.1 (launched as grok-code-fast-1) at $1.00/M input and $2.00/M output on 256k context, and the grok-4.20-0309 variants at $1.25/M input and $2.50/M output. Cached input runs $0.20 to $0.50/M. Every rate doubles on prompts of 200k tokens or more. The older grok-4 and grok-3 are no longer listed.
Every price on this page is from xAI's official docs at docs.x.ai as of August 21, 2026. Model pricing changes frequently. Confirm the current rate on docs.x.ai before relying on these numbers.
xAI Grok API Pricing 2026: What Changed in August
Two changes since July. First, xAI released grok-4.6 on August 12, 2026 and now recommends it over grok-4.5 for everything, including code. It is priced identically to grok-4.5 at $2.00/M input and $6.00/M output on a 500k context. Second, grok-4.5's cached input dropped from $0.50/M to $0.30/M, so a heavily cached workload that stays on grok-4.5 now pays 40% less for its cached tokens than the same workload on grok-4.6 ($0.50/M). One removal to note: the models page no longer shows the grok-code-fast-1 alias; the fast coding model is listed as grok-build-0.1 only.
xAI Grok API Pricing at a Glance
xAI bills the Grok API per token, with separate rates for input (the tokens you send) and output (the tokens the model generates). Output is more expensive than input on every model, and cached input is the cheapest tier. There is no separate per-request fee, but server-side tools (web search, code execution) bill per call on top of tokens.
Five text models are listed on docs.x.ai as of August 2026: grok-4.6 (the recommended flagship, 500k context), grok-4.5 (same token rates, cheaper cache, 500k context), grok-4.3 (primary chat and coding, 1M context), grok-build-0.1, launched as grok-code-fast-1 (fast agentic coding, 256k context), and the grok-4.20-0309 variants (reasoning, non-reasoning, and multi-agent, 1M context). grok-4.3 and grok-4.20 share the same price. grok-build-0.1 is the cheapest per token; grok-4.6 and grok-4.5 are the most expensive.
The practical takeaway: grok-build-0.1 costs about 20% less per token than grok-4.3 ($1.00 vs $1.25 input, $2.00 vs $2.50 output), so high-volume agentic loops that fit in 256k tokens are cheaper there. Reach for grok-4.6 only when its top-end reasoning earns the $6.00/M output. And whichever model you pick, keep prompts under 200k tokens or every rate doubles.
Full Price Table by Model
All rates are per million tokens, in USD, from docs.x.ai as of August 21, 2026, for prompts under 200k tokens. Cached input applies to context that the API has already seen and stored, billed at a discount versus fresh input. See the next section for the doubled rates that apply at 200k tokens and above.
| Model | Context | Input | Output | Cached input |
|---|---|---|---|---|
| grok-4.6 | 500k | $2.00 | $6.00 | $0.50 |
| grok-4.5 | 500k | $2.00 | $6.00 | $0.30 |
| grok-4.3 | 1M | $1.25 | $2.50 | $0.20 |
| grok-build-0.1 (launched as grok-code-fast-1) | 256k | $1.00 | $2.00 | $0.20 |
| grok-4.20 (grok-4.20-0309 variants) | 1M | $1.25 | $2.50 | $0.20 |
grok-4.6 is the recommended flagship and, with grok-4.5, the most expensive per token at $6.00/M output; the two differ only on cached input, where grok-4.5 is $0.20/M cheaper. grok-4.3 and grok-4.20-0309 share $1.25/$2.50 per M and a 1M context. grok-build-0.1 is the cheapest at $1.00/$2.00 per M, on a 256k context. All five publish a cached-input rate, from $0.20/M on the 4.3-class models up to $0.50/M on grok-4.6.
The 200k-Token Tier: Rates Double
xAI splits pricing at a 200k-token prompt threshold. Requests under 200k tokens pay the standard rate. At 200k tokens or more, input, cached input, and output all double. This is the single detail most Grok pricing pages miss, and it is the difference between a $0.63 session and a $1.26 session on the same model.
| Model | Input | Cached input | Output |
|---|---|---|---|
| grok-4.6 | $4.00 | $1.00 | $12.00 |
| grok-4.5 | $4.00 | $0.60 | $12.00 |
| grok-4.3 | $2.50 | $0.40 | $5.00 |
| grok-build-0.1 | $2.00 | $0.40 | $4.00 |
| grok-4.20-0309 | $2.50 | $0.40 | $5.00 |
An agent that pastes a large repository or a long document past 200k tokens pays double on the entire request, not just the tokens over the line. Trimming the prompt back under 200k, or splitting the task, can halve the bill. This is a stronger lever than model choice when your context is large.
Server-Side Tool Pricing
xAI bills its server-side tools per call, on top of token usage. If a request invokes web search or runs code, that call is added to the token cost of the same request.
| Tool | Price | Billing |
|---|---|---|
| Web search | $5.00 | per 1,000 calls |
| X search | $5.00 | per 1,000 calls |
| Code execution | $5.00 | per 1,000 calls |
| Collections search | $2.50 | per 1,000 calls |
| File attachments | $10.00 | per 1,000 calls |
Image and video understanding and remote MCP tools are billed on tokens rather than per call. On agentic workloads that hit web or X search on every turn, tool calls can rival the token cost, so count them into any budget estimate.
Per-Model Notes
The five listed models map to distinct jobs. Picking the right one is the first lever on cost, before any caching or routing.
grok-4.6
Released August 12, 2026 and the model xAI now recommends for everything, including code. $2.00/M input, $6.00/M output, $0.50/M cached input, 500k context. Reach for it when the task justifies $6.00/M output; otherwise grok-4.3 does general coding for less.
grok-4.5
The previous flagship. Same token rates as grok-4.6 ($2.00/M in, $6.00/M out, 500k context) but cached input is $0.30/M instead of $0.50/M, so it wins on heavily cached workloads at the flagship tier.
grok-4.3
xAI's primary chat and coding model below the flagship tier. $1.25/M input, $2.50/M output, $0.20/M cached input, 1M-token context. Default choice for general coding, reasoning, and chat, and the largest context of the lineup. Recommended over the retired grok-4.
grok-build-0.1 (grok-code-fast-1)
xAI's fast agentic-coding model, launched under the grok-code-fast-1 alias and now listed as grok-build-0.1. $1.00/M input, $2.00/M output, $0.20/M cached input, 256k context. Cheapest per token, built for high-volume agentic loops that fit inside 256k.
grok-4.20-0309
Three variants covering reasoning, non-reasoning, and multi-agent modes. $1.25/M input, $2.50/M output, $0.20/M cached input, 1M-token context. Same price as grok-4.3, different serving modes.
Output tokens cost 2x to 3x input on every Grok model ($2.50 vs $1.25 on grok-4.3, $6.00 vs $2.00 on grok-4.6 and grok-4.5, $2.00 vs $1.00 on grok-build-0.1). In agentic coding, generated diffs, tool calls, and reasoning traces are the output. Trimming verbose output, not input, moves the bill the most.
Grok vs Groq: Not the Same API
One letter separates two unrelated companies, and search engines mix them constantly. Grok (with a k) is xAI's model family, the subject of this page, billed per token through api.x.ai. Groq (with a q) is an inference-hardware company that builds LPU chips and serves open-weight models such as Llama and Qwen through groq.com, with its own separate price list. Nothing on this page applies to Groq: different company, different models, different API, different rates. If you were looking for Groq's prices, go to groq.com/pricing; if you want xAI's Grok models, the tables above are current.
Retired Models: grok-4, grok-3, grok-4-fast
grok-4, grok-3, and grok-4-fast dropped off xAI's official models pricing page by June 2026 and remain absent as of August 21, 2026. They have been succeeded by the grok-4.6, grok-4.5, and grok-4.3 generation.
Because xAI no longer publishes rates for the retired models, this page does not quote prices for them. Any number you find for grok-4 or grok-3 today is from a cached or third-party source and may not match what xAI bills. For a new integration, use grok-4.6 or grok-4.3 for general work, or grok-build-0.1 for fast agentic coding.
Quoting a price xAI no longer publishes would be guessing. The FACTS rule on this page is to state only what the official source confirms. If you have an existing integration pinned to grok-4 or grok-3, check your xAI console for the rate you are actually billed and plan a migration to grok-4.3.
Worked Cost Example: A Coding Session
Take a coding agent session with 100 API calls. Assume each call averages 3,000 input tokens and 1,000 output tokens, for 4,000 tokens per call and 400,000 tokens total (300k input, 100k output). Below is the cost on each model at list price, with no caching.
| Model | Input cost | Output cost | Total |
|---|---|---|---|
| grok-4.6 ($2.00 / $6.00) | $0.600 | $0.600 | $1.200 |
| grok-4.3 ($1.25 / $2.50) | $0.375 | $0.250 | $0.625 |
| grok-build-0.1 ($1.00 / $2.00) | $0.300 | $0.200 | $0.500 |
| grok-4.20 ($1.25 / $2.50) | $0.375 | $0.250 | $0.625 |
grok-4.6 costs about $1.20 for the session, grok-4.3 about $0.63, and grok-build-0.1 about $0.50, roughly 20% less than grok-4.3. Now add caching. If 200k of the 300k input tokens are repeated context (system prompt, file contents, tool schemas) billed at $0.20/M instead of full input rate, the grok-4.3 input cost drops from $0.375 to about $0.165 (100k fresh at $1.25/M = $0.125, plus 200k cached at $0.20/M = $0.04). The session total falls to roughly $0.42, a 33% cut from caching alone.
Scale this to a team running 10,000 sessions per month and the gap is material: about $6,300/month on grok-4.3 at list price, versus about $4,200/month with caching, versus about $5,000/month if every session ran on grok-build-0.1, versus about $12,000/month if everything ran on grok-4.6. Mixing models by difficulty beats any single-model choice.
How to Call the Grok API
The xAI API is OpenAI-compatible. Point the OpenAI SDK at xAI's base URL, pass your xAI key, and set the model name. Chat-completions code written for OpenAI runs unchanged.
Calling Grok with the OpenAI SDK (Python)
from openai import OpenAI
client = OpenAI(
api_key=os.environ["XAI_API_KEY"],
base_url="https://api.x.ai/v1",
)
# grok-4.3: primary chat/coding, 1M context, $1.25/$2.50 per M
resp = client.chat.completions.create(
model="grok-4.3",
messages=[
{"role": "system", "content": "You are a coding assistant."},
{"role": "user", "content": "Refactor this function to use async/await."},
],
)
print(resp.choices[0].message.content)
# grok-build-0.1 (launched as grok-code-fast-1): fast agentic coding,
# 256k context, $1.00/$2.00 per M
fast = client.chat.completions.create(
model="grok-build-0.1",
messages=[{"role": "user", "content": "Add error handling to parseConfig()"}],
)The same pattern works from the TypeScript OpenAI SDK by setting baseURL to https://api.x.ai/v1. Because the surface matches OpenAI, you can swap a Grok call into existing code by changing the base URL, key, and model string only.
Calling Grok with the OpenAI SDK (TypeScript)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.XAI_API_KEY,
baseURL: "https://api.x.ai/v1",
});
const resp = await client.chat.completions.create({
model: "grok-4.3",
messages: [{ role: "user", content: "Write a unit test for sum()" }],
});
console.log(resp.choices[0].message.content);How to Reduce Grok API Costs
Four levers cut a Grok bill, in rough order of impact: cache repeated context, route by difficulty, trim output, and pick the right model for each task.
| Lever | Mechanism | Typical impact |
|---|---|---|
| Cache input | Reuse stored context at $0.20/M instead of $1.25/M fresh input | 20-40% off input |
| Route by difficulty | Easy turns to grok-build-0.1, hard turns to grok-4.3 or grok-4.6 | 40-70% on mixed loads |
| Trim output | Output costs 2x input; cap verbose generations | Direct, per-token |
| Right-size context | Use 256k grok-build-0.1 when 1M is not needed | 20% per token |
Routing is the largest lever on a mixed workload because most coding turns are easy. A router classifies each prompt and sends boilerplate, simple edits, and documentation to the cheaper model while reserving grok-4.3 for architecture and complex debugging. The savings come from the volume of easy turns, not from any single expensive call.
Morph's model router automates this. It classifies prompt difficulty in ~430ms into four tiers (easy, medium, hard, needs_info) and routes each call to the cheapest model that clears the quality bar, for 40-70% API cost savings at about $0.001 per classification. It exposes one OpenAI-compatible endpoint at api.morphllm.com across providers, so the same code can reach Grok, Claude, GPT, and Gemini models without per-provider plumbing. See LLM cost optimization for the full set of techniques, and the LLM cost calculator to model your own spend.
On a mixed coding workload, no single Grok model is optimal: grok-build-0.1 is cheapest but caps at 256k context, grok-4.3 carries 1M but costs 20% more per token, and grok-4.6 costs 2.4x grok-4.3 on output. A difficulty-aware router gets the cheap rate on the 60% of turns that are easy and the large context on the hard turns that need it, beating any fixed choice.
Frequently Asked Questions
How much does the Grok API cost?
As of August 21, 2026, grok-4.6 and grok-4.5 each cost $2.00 per million input tokens and $6.00 per million output on a 500k context (cached input $0.50/M and $0.30/M respectively). grok-4.3 costs $1.25 input and $2.50 output per million, with $0.20 per million cached input on a 1M-token context. grok-build-0.1 (launched as grok-code-fast-1) costs $1.00 input and $2.00 output per million on a 256k context. grok-4.20 matches grok-4.3 at $1.25 input and $2.50 output. Verify current numbers on docs.x.ai.
What is grok-4.6 pricing?
grok-4.6, released August 12, 2026, is the model xAI now recommends for everything, including code. $2.00/M input, $6.00/M output, $0.50/M cached input, 500k context; the rates double to $4.00/$12.00/$1.00 at 200k prompt tokens or more. It matches grok-4.5 on token rates; grok-4.5's cached input is $0.20/M cheaper.
What is the difference between grok-4.3 and grok-code-fast pricing?
grok-4.3 costs $1.25/M input and $2.50/M output on a 1M-token context and is xAI's primary chat and coding model below the flagship tier. grok-build-0.1, which launched under the grok-code-fast-1 alias, costs $1.00/M input and $2.00/M output on a 256k context. It is about 20% cheaper per token but carries a quarter of the context window. Use it for high-volume agentic loops; use grok-4.3 for large-context tasks.
Is the Grok API the same as the Groq API?
No. Grok is xAI's model family, billed per token through api.x.ai. Groq, with a q, is an unrelated inference-hardware company that serves open-weight models on its LPU chips at groq.com, with a separate price list. This page covers xAI's Grok only.
Does the Grok API have a free tier?
xAI's published pricing is per-token usage-based, with no free per-token allowance listed on the official models page as of August 2026. Promotional credits and trials have appeared and changed over time, so check x.ai for any current free credits. The numbers on this page are the standard usage-based rates.
Does Grok API pricing change by prompt length?
Yes. xAI charges a standard rate for prompts under 200k tokens and doubles input, cached input, and output once a request reaches 200k tokens or more, on every model. grok-4.3 bills $1.25/M input and $2.50/M output under 200k and $2.50/$5.00 at or above it; grok-4.6 goes from $2.00/$6.00 to $4.00/$12.00. The doubled rate applies to the whole request, not just the tokens past the line.
Is the Grok API OpenAI-compatible?
Yes. The xAI API is OpenAI-compatible. Point the OpenAI SDK at https://api.x.ai/v1, supply your xAI API key, and set the model to grok-4.6, grok-4.3, or grok-build-0.1. Existing OpenAI-shaped code that uses chat completions works without a rewrite.
How do I reduce Grok API costs?
Cache repeated context at $0.20/M cached input instead of resending system prompts, files, and tool definitions at full price. Route easy turns to grok-build-0.1 ($1.00/$2.00 per M) and reserve grok-4.6 or grok-4.3 for hard turns. Cut output tokens, which cost 2x input. A model router that classifies prompt difficulty automates the routing and can save 40-70% across mixed workloads.
What happened to grok-4 and grok-3 pricing?
grok-4, grok-3, and grok-4-fast dropped off xAI's official models pricing page by June 2026 and remain absent as of August 21, 2026. They have been succeeded by the grok-4.6, grok-4.5, and grok-4.3 generation. Because xAI no longer publishes their rates, this page does not quote prices for the retired models. Use grok-4.6, grok-4.3, or grok-build-0.1 for new integrations.
Sources
- docs.x.ai: models page (per-model token rates, cached input, context windows, 200k doubling; fetched August 21, 2026).
- docs.x.ai: pricing page (server-side tool rates per 1,000 calls; fetched August 21, 2026).
- DataNorth: xAI releases Grok 4.6 (August 12, 2026 release date).
Related Resources
The fastest endpoints are private deployments
Morph's top speeds come from dedicated deployments, not shared public endpoints: speculators trained on your traffic, caching tuned to your workload, and volume discounts over public per-token rates. Over 100 billion tokens per day run this way.
Stop Overpaying for Grok and Every Other Model
Morph's model router classifies prompt difficulty in ~430ms and routes each call to the cheapest model that clears the quality bar, for 40-70% API cost savings at about $0.001 per classification. One OpenAI-compatible endpoint at api.morphllm.com reaches Grok, Claude, GPT, and Gemini without per-provider plumbing.
