1#### Get Started1#### Get Started
2 2
3# Grok 4.63# Grok 4.7
4 4
5Grok 4.6 is SpaceXAI's frontier model built for coding, agentic tasks, and knowledge work.5Grok 4.7 is SpaceXAI's frontier model built for coding, agentic tasks, and knowledge work.
6 6
7## Using the API7## Using the API
8 8
9If you already have an [API key](https://console.x.ai/team/default/api-keys?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-grok-4-6\&utm_content=api-keys), set the model name to `grok-4.6`:9If you already have an [API key](https://console.x.ai/team/default/api-keys?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-grok-4-7\&utm_content=api-keys), set the model name to `grok-4.7`:
10 10
11```python customLanguage="pythonXAI"11```python customLanguage="pythonXAI"
12import os12import os
15 15
16client = Client(api_key=os.getenv("XAI_API_KEY"))16client = Client(api_key=os.getenv("XAI_API_KEY"))
17 17
18chat = client.chat.create(model="grok-4.6")18chat = client.chat.create(model="grok-4.7")
19chat.append(user("Find and fix the bug, then explain it: function median(a){a.sort();return a[a.length/2]}"))19chat.append(user("Find and fix the bug, then explain it: function median(a){a.sort();return a[a.length/2]}"))
20 20
21response = chat.sample()21response = chat.sample()
27import { generateText } from 'ai';27import { generateText } from 'ai';
28 28
29const { text } = await generateText({29const { text } = await generateText({
30 model: xai.responses('grok-4.6'),30 model: xai.responses('grok-4.7'),
31 prompt:31 prompt:
32 'Find and fix the bug, then explain it: function median(a){a.sort();return a[a.length/2]}',32 'Find and fix the bug, then explain it: function median(a){a.sort();return a[a.length/2]}',
33});33});
44});44});
45 45
46const response = await client.responses.create({46const response = await client.responses.create({
47 model: 'grok-4.6',47 model: 'grok-4.7',
48 input: [48 input: [
49 {49 {
50 role: 'user',50 role: 'user',
62 -H "Content-Type: application/json" \62 -H "Content-Type: application/json" \
63 -H "Authorization: Bearer $XAI_API_KEY" \63 -H "Authorization: Bearer $XAI_API_KEY" \
64 -d '{64 -d '{
65 "model": "grok-4.6",65 "model": "grok-4.7",
66 "input": "Find and fix the bug, then explain it: function median(a){a.sort();return a[a.length/2]}"66 "input": "Find and fix the bug, then explain it: function median(a){a.sort();return a[a.length/2]}"
67 }'67 }'
68```68```
73 73
74| Property | Value |74| Property | Value |
75|----------|-------|75|----------|-------|
76| Model name | `grok-4.6` |76| Model name | `grok-4.7` |
77| Context window | 500,000 tokens |77| Context window | 500,000 tokens |
78| Knowledge cutoff | February 1, 2026 |78| Knowledge cutoff | May 2026 |
79| Modalities | Text and image input; text output |79| Modalities | Text and image input; text output |
80| Output limit | No text output limit |80| Output limit | No text output limit |
81| Input price | $2.00 / 1M tokens |81| Input price | $2.00 / 1M tokens |
84| APIs | [Responses API](/developers/rest-api-reference/inference/responses#create-new-response), [Chat Completions](/developers/rest-api-reference/inference/chat-completions#chat-completions) |84| APIs | [Responses API](/developers/rest-api-reference/inference/responses#create-new-response), [Chat Completions](/developers/rest-api-reference/inference/chat-completions#chat-completions) |
85| Tools | [Function calling](/developers/tools/function-calling), [web search](/developers/tools/web-search), [X search](/developers/tools/x-search), [code execution](/developers/tools/code-execution) |85| Tools | [Function calling](/developers/tools/function-calling), [web search](/developers/tools/web-search), [X search](/developers/tools/x-search), [code execution](/developers/tools/code-execution) |
86 86
87Rate limits and live pricing for your team are on the [model detail page](/developers/models/grok-4.6) and [Pricing](/developers/pricing).87Rate limits and live pricing for your team are on the [model detail page](/developers/models/grok-4.7) and [Pricing](/developers/pricing).
88
89For benchmark results and demos, see the [announcement](https://x.ai/news/grok-4-6).
90 88
91## Important details89## Important details
92 90
93* **We highly recommend setting a [`prompt_cache_key`](/developers/advanced-api-usage/prompt-caching/maximizing-cache-hits)** (Responses API; `x-grok-conv-id` header on Chat Completions). It routes a conversation's requests to the same server, making cache hits reliable; without it you often pay full input price on a cache-cold server. See [What Breaks Caching](/developers/advanced-api-usage/prompt-caching/multi-turn) for common mistakes.91* **We highly recommend setting a [`prompt_cache_key`](/developers/advanced-api-usage/prompt-caching/maximizing-cache-hits)** (Responses API; `x-grok-conv-id` header on Chat Completions). It routes a conversation's requests to the same server, making cache hits reliable; without it you often pay full input price on a cache-cold server. See [What Breaks Caching](/developers/advanced-api-usage/prompt-caching/multi-turn) for common mistakes.
94* **Long agent loops** additionally benefit from [context compaction](/developers/advanced-api-usage/context-compaction); for tool-heavy workloads see [function calling](/developers/tools/function-calling).92* **Long agent loops** additionally benefit from [context compaction](/developers/advanced-api-usage/context-compaction); for tool-heavy workloads see [function calling](/developers/tools/function-calling).
93* **Encrypted reasoning is always returned on the Responses API.** `POST /v1/responses` responses from `grok-4.7` include `reasoning.encrypted_content` even when `include` does not list it, so multi-turn conversations keep the model's reasoning without extra configuration. Pass the reasoning items back unchanged in the next request's `input`; see [Encrypted reasoning content](/developers/model-capabilities/text/reasoning#encrypted-reasoning-content). Chat Completions is unchanged.
94
95## Fast variant
96
97Grok 4.7 Fast is the same model served on faster infrastructure, billed at twice the standard token rates. It is available only in Cursor and [Grok Build](/build/overview), and it is not included in Grok Build's free tier. It is not available on the public xAI API. Rates are on the [Pricing](/developers/pricing#grok-47-fast-pricing-cursor-and-grok-build-only) page.
95 98
96## Where it runs99## Where it runs
97 100
98* **xAI API**: get a key from the [console](https://console.x.ai/?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-grok-4-6\&utm_content=console-home)101* **xAI API**: get a key from the [console](https://console.x.ai/?utm_source=docs\&utm_medium=referral\&utm_campaign=developers-grok-4-7\&utm_content=console-home)
99* **US regional endpoint**: currently the only model served at `https://us.api.x.ai/v1`, which keeps inference in the United States, with token usage priced at a 10% premium; see [Regional Endpoints](/developers/advanced-api-usage/regions)102* **US regional endpoint**: also served at `https://us.api.x.ai/v1`, which keeps inference in the United States, with token usage priced at a 10% premium; see [Regional Endpoints](/developers/advanced-api-usage/regions)
100* **Grok Build**: the default model of the [coding agent](/build/overview), on the API and CLI103* **Grok Build**: the default model of the [coding agent](/build/overview)
101* **Cursor**: available on all plans104* **Cursor**: available on all plans
102* **Model gateways**: OpenRouter, Vercel, and Cloudflare105* **Model gateways**: OpenRouter, Vercel, and Cloudflare
103 106
104## Learn more107## Learn more
105 108
106* [Reasoning](/developers/model-capabilities/text/reasoning#the-reasoning_effort-parameter) - controlling `reasoning_effort`, including `"xhigh"`109* [Reasoning](/developers/model-capabilities/text/reasoning#the-reasoning_effort-parameter) - controlling `reasoning_effort`, including `"xhigh"`
107* [Announcement](https://x.ai/news/grok-4-6) - launch post with demos and full benchmark figures110* [Announcement](https://x.ai/news/grok-4-7) - launch post with demos and full benchmark figures
108* [Models](/developers/models) - compare available models and their capabilities111* [Models](/developers/models) - compare available models and their capabilities
109* [Pricing](/developers/pricing) - token pricing for all models112* [Pricing](/developers/pricing) - token pricing for all models