Apply your own routing policies, reduce token costs automatically, and see every routing decision in real time with Merge Gateway.

What Grok 4.20 costs to run
Test Grok 4.20
with Gateway’s Simulator
See a prompt's output, token spend, latency, and more with Grok 4.20 .
Route requests to Grok 4.20 in minutes
1$ pip install merge-gateway-sdk1from merge_gateway import MergeGateway
2
3client = MergeGateway(api_key="YOUR_API_KEY")
4
5response = client.responses.create(
6 model="openai/gpt-5.2",
7 input=[
8 {"type": "message", "role": "system", "content": "You are a helpful programming tutor. Explain the concepts clearly with practical examples."},
9 {"type": "message", "role": "user", "content": "Explain the concept of recursion in programming with a simple set of examples."},
10 ],
11)
12
13print(response.output[0].content[0].text)1response = client.responses.create(
2 model="anthropic/claude-sonnet-4-20250514",
3 input=[
4 {"type": "message", "role": "system", "content": "You are a helpful programming tutor. Explain the concepts clearly with practical examples."},
5 {"type": "message", "role": "user", "content": "Explain the concept of recursion in programming with a simple set of examples."},
6 ],
7)1from openai import OpenAI
2
3client = OpenAI(
4 api_key="YOUR_API_KEY",
5 base_url="https://api-gateway.merge.dev/v1/openai",
6)1response = client.chat.completions.create(
2 model="gpt-5.2",
3 messages=[
4 {"role": "system", "content": "You are a helpful programming tutor. Explain the concepts clearly with practical examples."},
5 {"role": "user", "content": "Explain the concept of recursion in programming with a simple set of examples."},
6 ],
7)
8
9print(response.choices[0].message.content)1npm install merge-gateway-ai-sdk-provider ai1import { createMergeGateway } from "merge-gateway-ai-sdk-provider";
2
3const gateway = createMergeGateway({
4 apiKey: "YOUR_API_KEY",
5});1import { generateText } from "ai";
2
3const { text } = await generateText({
4 model: gateway("openai/gpt-4o"),
5 prompt: "Explain the concept of recursion in programming with a simple set of examples.",
6});
7
8console.log(text);1import { createOpenAI } from "@ai-sdk/openai";
2
3const gateway = createOpenAI({
4 apiKey: "YOUR_API_KEY",
5 baseURL: "https://api-gateway.merge.dev/v1/ai-sdk",
6});
7
8// All generateText/streamText calls work unchanged1from anthropic import Anthropic
2
3client = Anthropic(
4 api_key="YOUR_API_KEY",
5 base_url="https://api-gateway.merge.dev/v1/anthropic",
6)
7
8message = client.messages.create(
9 model="claude-sonnet-4-20250514",
10 max_tokens=1024,
11 messages=[
12 {"role": "user", "content": "Explain the concept of recursion in programming with a simple set of examples."},
13 ],
14)
15
16print(message.content[0].text)Explore other models available in Merge Gateway
Grok 4.20 FAQ
Heading
What other models does xAI offer?
xAI builds a focused family of Grok models spanning fast general-purpose inference to frontier reasoning at multiple price and capability tiers. Here are some other models xAI supports:
- Grok 4.3: Grok 4.3 is a reasoning model released April 30, 2026, priced at $1.25 per million input tokens and $2.50 per million output tokens, positioned as a more cost-efficient reasoning option for production workloads that require chain-of-thought processing without the higher token cost of Grok 4.20
- Grok 4: Grok 4 is xAI's flagship baseline reasoning model, scoring at the top of xAI's intelligence tier and available to SuperGrok and Premium+ subscribers as well as through the xAI API, making it the standard reference point for evaluating the Grok 4 family
- Grok 4 Heavy: Grok 4 Heavy is xAI's multi-agent reasoning model with a 256,000 token context window and parallel test-time compute, designed for the most demanding tasks where accuracy outweighs cost constraints and only available on the SuperGrok Heavy tier
- Grok 3: Grok 3 is a non-reasoning general-purpose model priced at $4.00 per million input tokens, suited for instruction following, text generation, and chat workloads that do not require extended chain-of-thought output
- Grok 3 Mini: Grok 3 Mini is the smallest model in the Grok 3 family, targeting high-volume or latency-sensitive workloads where the full Grok 3 capability set exceeds what the task requires
How does Grok 4.20 differ from xAI's other models?
Grok 4.20 is an updated iteration in the Grok 4 reasoning family, released after the base Grok 4 and positioned as a high-intelligence reasoning variant with a 2 million token context window.
- Pricing: Grok 4.20 costs $2.00 per million input tokens and $6.00 per million output tokens, with cache hits at $1.10 per million tokens (a 45% reduction). This makes it roughly 60% cheaper on input than Grok 3 and more than 75% cheaper on output than base Grok 4 ($27.50/M), while still sitting above Grok 4.3's $2.50/M output rate
- Context window: Grok 4.20 supports a 2 million token context window, twice the 1 million token limit of Grok 4.3 and Grok 4, making it the strongest option in the xAI lineup for very long document analysis, large codebase reviews, or extended multi-turn sessions
- Speed: At 201.5 output tokens per second, Grok 4.20 is faster than Grok 4.3 (140.6 t/s), though its time-to-first-token of 11.63 seconds reflects the latency characteristic of deep reasoning models
- Intelligence Index: Grok 4.20 scores 49 on the Artificial Analysis Intelligence Index, ranking #24 of 150 evaluated models, placing it firmly in the top tier across providers
- Verbosity: Grok 4.20 generated 61 million tokens during evaluation, well above the median for comparable reasoning models, indicating detailed, expansive responses that drive higher output token costs per request
- Use case fit: Grok 4.20 is best suited for tasks requiring both deep reasoning and very long context: large codebase analysis, lengthy document Q&A, and complex multi-step workflows where the 2M window prevents chunking overhead
Grok 4.20 is the right choice when reasoning depth and maximum context are both required and the higher output cost per token is acceptable.
What models should I consider using alongside Grok 4.20?
No single model is optimal for every task. Here are models worth pairing with Grok 4.20 depending on what your product needs:
- Grok 4.3 (xAI): For reasoning requests that fit within a 1 million token context, routing to Grok 4.3 at $2.50 per million output tokens saves meaningful cost compared to Grok 4.20's $6.00 rate while staying within the xAI provider and preserving chain-of-thought capability
- Claude Opus 4 (Anthropic): For tasks requiring precise structured output, nuanced instruction adherence, or document transformation where response quality benchmarks are published and verifiable, Claude Opus 4 provides a well-documented high-intelligence alternative from a different provider
- Gemini 2.5 Pro (Google): For long-context retrieval tasks where cost per token matters more than reasoning depth, Gemini 2.5 Pro offers competitive intelligence scores at a lower per-token rate and serves as a strong cross-provider fallback for context-heavy workloads
- GPT-5 (OpenAI): For high-stakes reasoning tasks where provider redundancy is a requirement, GPT-5 offers comparable frontier-tier intelligence from a separate infrastructure, reducing single-provider risk when Grok 4.20 is unavailable
- Llama 4 Scout (Meta): For high-volume, lower-complexity requests in the same pipeline, Llama 4 Scout at $0.17 per million input tokens provides a cost-efficient fallback that handles multimodal inputs and standard instruction tasks without depleting the budget allocated for Grok 4.20 on harder requests
What are the challenges of using Grok 4.20 in my product?
Like any production LLM, Grok 4.20 comes with tradeoffs worth planning for:
- Cost at scale: At $6.00 per million output tokens and a tendency toward verbose responses (61M tokens in evaluation versus a typical median), Grok 4.20 can accumulate significant output costs quickly. Teams need active per-project budget caps to avoid unexpected spend at volume
- Provider dependency: All traffic to Grok 4.20 routes through xAI's own infrastructure. There is no major cloud marketplace redundancy, so an xAI-specific outage, rate limit change, or model deprecation directly affects availability with no automatic fallback unless you have one configured at the gateway layer
- High time-to-first-token: A TTFT of 11.63 seconds is typical for deep reasoning models but rules out latency-sensitive user-facing interfaces. Streaming mitigates perceived wait time, but applications expecting sub-second response starts need a different model or a fast-path fallback
- Verbosity management: Grok 4.20's tendency to produce expansive responses means prompt discipline is required. Without explicit length instructions or output constraints, responses can be far longer than needed, inflating both latency and cost
- No multimodal output: Grok 4.20 accepts text and image inputs but produces text output only. Workflows requiring generated images, audio, or other output modalities need a separate model routed in parallel
Why should I use Merge Gateway to route LLM requests with Grok 4.20 and every other model?
Using Grok 4.20 through Merge Gateway gives you access to the model itself and the infrastructure layer around it:
- One API, every provider: Access Grok 4.20 and every other major LLM through a single endpoint and API key. Change providers by swapping the model string and no application code changes are required
- Intelligent routing and automatic failover: Merge routes around xAI outages automatically. Routing policies based on cost, latency, or quality can reduce spend by 40–60% without touching your application code
- Cost governance: Set hard or soft project budgets so Grok 4.20 spend stays within plan. Every request is attributed to a model, project, and tag in a unified billing dashboard across all providers
- Build Your Own Router: Define what "best" means for your traffic by selecting from curated ML benchmarks or adding your own eval scores. The router scores each available model against your weights and picks the winner per request, with a plain-language explanation of every decision
- Security and compliance controls: Apply DLP rules and prompt injection protection before every request reaches xAI. Enforce per-project model and region policies without adding that logic to your application
How can I start routing requests to Grok 4.20 via Merge Gateway?
Getting Grok 4.20 running through Merge Gateway takes a few minutes:
1. Create an account and get your API key from the dashboard.
2. Install the Merge Gateway SDK: run pip install merge-gateway-sdk (Python) or npm install merge-gateway-sdk (Node). Alternatively, if you're already using the OpenAI SDK, set base_url = "https://api-gateway.merge.dev/v1/openai" and your existing code works as-is.
3. Make your first request using the provider/model format. For Grok 4.20, the model string is xai/grok-4.20. Swap the model string to route to any other provider without changing anything else.
4. Configure a routing policy in the dashboard to set failover behavior, cost limits, and optimization strategy. Your first policy can be as simple as naming Grok 4.20 as primary for long-context reasoning tasks with Grok 4.3 as a cost-optimized fallback for shorter requests.
Full setup instructions and SDK references are in the Merge Gateway docs.
Try Grok 4.20 through Merge Gateway
Route, observe, and control AI requests across providers from one API.





