Grok API Pricing: How xAI Bills Tokens, Context Windows, Tools, and Media
Pricing for xAI’s Grok API centers on pay-per-token usage for text models, paired with separate per-unit billing for voice, image, video, storage, and server-side agent tools. For its flagship grok-4.7 model (with a 500K-token context window), standard global pricing is $2.00 per 1M input tokens, $0.50 per 1M cached input tokens, and $6.00 per 1M output tokens—provided the prompt stays below the 200K-token long-context threshold.
Rather than treating long prompts as a minor add-on or a smooth sliding scale, xAI’s rate card flips to a higher tier once a prompt hits 200K tokens, and it charges separately when agentic workflows invoke search or code execution. Understanding where those thresholds and extra meters sit is the difference between a predictable API bill and a surprise spike.
Text Models and the 200K Long-Context Cliff
xAI’s text API separates input, cached input, and output tokens per million, and applies a distinct long-context rate schedule once a prompt reaches 200K tokens. Crucially, crossing that threshold doesn’t only surcharge the overflow tokens—xAI bills the entire request at the long-context rates.
| Model | Context Window | Standard Input (<200K) | Cached Input (<200K) | Standard Output (<200K) | Long-Context Input (≥200K) | Long-Context Cached (≥200K) | Long-Context Output (≥200K) |
|---|---|---|---|---|---|---|---|
grok-4.7 |
500K | $2.00 / 1M | $0.50 / 1M | $6.00 / 1M | $4.00 / 1M | $1.00 / 1M | $12.00 / 1M |
grok-4.6 |
500K | $2.00 / 1M | $0.50 / 1M | $6.00 / 1M | $4.00 / 1M | $1.00 / 1M | $12.00 / 1M |
grok-4.5 |
500K | $2.00 / 1M | $0.30 / 1M | $6.00 / 1M | $4.00 / 1M | $0.60 / 1M | $12.00 / 1M |
grok-4.3 |
1M | $1.25 / 1M | $0.20 / 1M | $2.50 / 1M | $2.50 / 1M | $0.40 / 1M | $5.00 / 1M |
grok-4.20 variants |
1M | $1.25 / 1M | $0.20 / 1M | $2.50 / 1M | $2.50 / 1M | $0.40 / 1M | $5.00 / 1M |
Note: grok-4.20 pricing above covers the grok-4.20-0309-non-reasoning, grok-4.20-0309-reasoning, and grok-4.20-multi-agent-0309 variants. Lighter models such as grok-build-0.1 also exist on lower tiers ($1.00 input / $2.00 output standard, with a 256K context window).
Three structural details shape real-world text spend:
- 3x output-to-input spread: Across the Grok 4 lineup, output tokens cost three times as much as standard input tokens ($6.00 vs. $2.00 on
grok-4.7; $2.50 vs. $1.25 ongrok-4.3). Verbose generations and multi-step reasoning outputs drive costs faster than long system prompts below 200K tokens. - Prompt caching discount: Repeated prompt prefixes hit cached rates—such as $0.50/1M on
grok-4.7and $0.20/1M ongrok-4.3below 200K tokens. If a request crosses 200K tokens, cached token rates also double. - Regional endpoint multiplier: Routing requests to the US regional endpoint runs inference in the United States at 1.1x the global token rates (a 10% premium).
Agentic Tools, Voice, Image, and Video Meters
Modern Grok API applications rarely stop at plain text completion. xAI bills several capabilities on separate unit meters rather than bundling them into token counts:
Tool Invocation Costs
When your model calls xAI’s built-in tools, charges accrue per 1,000 calls (or per 1,000 items returned for X search):
- Web Search (
web_search): $5 per 1k calls. - X Search (
x_search): $5 per 1k posts and $10 per 1k profiles. - Code Execution (
code_execution/code_interpreter): $5 per 1k calls. - File Attachments (
attachment_search): $5 per 1k calls. - Collections Search (
collections_search/file_search): $2.50 per 1k calls. - Visual & MCP Tools: Image and video understanding on search results (
view_image,view_x_video) and remote MCP tools are billed on a token basis.
Voice, Image, and Video APIs
- Voice API: Speech-to-speech (
grok-voice-3.0) runs at $0.08/minute ($4.80/hour) plus $0.004 per text input. Speech-to-text costs $0.10/hour (REST) or $0.20/hour (streaming), while text-to-speech costs $15.00 per 1M characters. - Image API: Image generation and editing start around $0.02 per image on
grok-imagine-image(1K/2K), whilegrok-imagine-image-2.0scales from $0.04 to $0.08 per output image depending on resolution and quality tier, plus per-image input fees ($0.002 or $0.01/img). - Video API: Video generation starts at $0.02/second on
grok-imagine-video-1.5-lite(480p) and scales up with resolution and model tier—reaching $0.25/second at 1080p ongrok-imagine-video-1.5, alongside per-image/second media input fees. - Files & Collections Storage/Downloads: Stored files cost $0.025/GiB/day, collections cost $0.10/GiB/day, and downloads cost $0.20/GiB.
Rate Tiers, Cost Tracking, and Practical Ways to Control Spend
xAI operates on a prepaid credit or enterprise invoice model, and API usage is separate from consumer Grok or X subscriptions. Rate limits—measured in requests per second (RPS), tokens per minute (TPM), or concurrent sessions (CST) for voice—scale across Tier 0 through Tier 4 (plus Enterprise) based on cumulative spend since January 1, 2026, and tiers do not downgrade once unlocked.
To keep costs predictable as traffic grows, focus on three operational levers:
- Keep prompts under 200K tokens when possible: Because hitting 200K tokens doubles the rate across the entire prompt and output rather than just the excess, chunking or summarizing large contexts below 200K can cut per-call cost in half.
- Match model tier to task complexity: Reserve
grok-4.7($2/$6) for hard coding, complex reasoning, and primary agent loops, and test lighter options likegrok-4.3($1.25/$2.50) orgrok-build-0.1($1/$2) for high-volume classification, extraction, or routing. - Track per-request cost and tool loops: Use xAI’s per-response
cost_in_usd_ticksfield (10 billion ticks per dollar, net of caching) to attribute spend by feature or tenant, and cap tool-calling iterations so runawayweb_searchorx_searchloops don’t quietly outspend the model tokens themselves.
Leave a Reply