Grok 4
Grok 4 is xAI's high-capability Grok 4 reasoning model. It uses chain-of-thought reasoning for mathematics, science, and coding workloads with a context window of 256K tokens.
import { streamText } from 'ai'
const result = streamText({ model: 'xai/grok-4', prompt: 'Why is the sky blue?'})Frequently Asked Questions
How does Grok 4 compare to Grok 3?
Grok 4 is the full Grok 4 model. It scores higher than Grok 3 on reasoning benchmarks, plus improved instruction following and deeper chain-of-thought output.
Does Grok 4 show its reasoning process?
Yes. Grok 4 generates chain-of-thought reasoning traces visible in the API response. You can inspect and verify the model's reasoning steps.
What is the context window for Grok 4?
The context window is 256K tokens.
What does Grok 4 cost?
See the pricing section on this page for today's rates. AI Gateway exposes each provider's pricing for Grok 4.
How do I authenticate with Grok 4 through Vercel AI Gateway?
Use your Vercel AI Gateway API key with
xai/grok-4as the model identifier. AI Gateway handles provider routing automatically.When should I use Grok 4 versus Grok 4 Fast?
Use Grok 4 when reasoning depth and accuracy are paramount. Use Grok 4 Fast variants when you need faster responses and can accept some quality tradeoff on the hardest reasoning tasks.
Does Vercel AI Gateway support Zero Data Retention for Grok 4?
Zero Data Retention is not currently available for this model. ZDR on AI Gateway applies to direct gateway requests; BYOK flows aren't covered. See https://vercel.com/docs/ai-gateway/capabilities/zdr for details.