Repository Public
1<!-- source: https://docs.x.ai/developers/model-capabilities/text/reasoning (from https://docs.x.ai/llms-full.txt, retrieved 2026-09-19T05:28:55Z) -->2#### Model Capabilities34# Reasoning56## Key Features78* **Think Before Responding**: Reasoning models think through problems step-by-step before delivering an answer.9* **Math & Quantitative Strength**: Excels at numerical challenges, logic puzzles, and complex analytical tasks.10* **Reasoning Trace**: Usage metrics expose `reasoning_tokens`. Some models can also return encrypted reasoning via `include: ["reasoning.encrypted_content"]` (see below).1112### Encrypted Reasoning Content1314The reasoning content is encrypted by us and can be returned if you pass `include: ["reasoning.encrypted_content"]` to the Responses API. You can send the encrypted content back to provide more context to a previous conversation. See [Adding encrypted thinking content](/developers/model-capabilities/text/generate-text#adding-encrypted-thinking-content) for more details on how to use the content.1516> [!TIP]17>18> When using the Vercel AI SDK, encrypted reasoning content is automatically included under the hood as long as `store: false` is not specified. No additional configuration is needed.1920## The `reasoning_effort` parameter2122`grok-4.6` and `grok-4.5` support the `reasoning_effort` parameter, which controls how much effort the model spends thinking before responding.2324If not specified, `reasoning_effort` defaults to `"high"`. Reasoning cannot be disabled.2526`presencePenalty`, `frequencyPenalty`, and `stop` cannot be used with reasoning models. Requests that include them return an error.2728### Effort levels2930| Setting | Description | Best For |31|---|---|---|32| `"low"` | Uses some reasoning tokens, but still fast | Latency-sensitive agentic use and simple tool calling. |33| `"medium"` | More thinking for less-latency sensitive applications | Complex data analysis and long-context reasoning. |34| `"high"` (default) | Uses more reasoning tokens for deeper thinking | Very challenging problems, complex math, multi-step logic, competition-level tasks |35| `"xhigh"` | Maximum reasoning depth, with correspondingly higher latency | The hardest problems, where answer quality matters more than response time |3637> [!TIP]38>39> `"xhigh"` is available on `grok-4.6` and later. On models that do not support it, such as `grok-4.5`, requests with `"xhigh"` are treated as `"high"`.4041### Setting reasoning effort4243The following example sets `reasoning_effort` to `"high"` for a challenging math proof. You can substitute `"low"`, `"medium"`, or (on supported models) `"xhigh"` as needed.4445```python customLanguage="pythonXAI" highlightedLines="13"46import os4748from xai_sdk import Client49from xai_sdk.chat import system, user5051client = Client(52 api_key=os.getenv("XAI_API_KEY"),53 timeout=3600,54)5556chat = client.chat.create(57 model="grok-4.6",58 reasoning_effort="high",59 messages=[system("You are a highly intelligent AI assistant.")],60)61chat.append(user("Find all prime numbers p such that p^2 + 2 is also prime. Prove your answer."))6263response = chat.sample()6465print("Final Response:")66print(response.content)67```6869```python customLanguage="pythonOpenAISDK" highlightedLines="13"70import os71import httpx72from openai import OpenAI7374client = OpenAI(75 base_url="https://api.x.ai/v1",76 api_key=os.getenv("XAI_API_KEY"),77 timeout=httpx.Timeout(3600.0),78)7980response = client.responses.create(81 model="grok-4.6",82 reasoning={"effort": "high"},83 input=[84 {"role": "system", "content": "You are a highly intelligent AI assistant."},85 {"role": "user", "content": "Find all prime numbers p such that p^2 + 2 is also prime. Prove your answer."},86 ],87)8889message = next(item for item in response.output if item.type == "message")90text = next(c.text for c in message.content if c.type == "output_text")9192print("Final Response:")93print(text)94```9596```typescript customLanguage="javascriptAISDK" highlightedLines="9"97import { xai } from '@ai-sdk/xai';98import { generateText } from 'ai';99100const result = await generateText({101 model: xai.responses('grok-4.6'),102 system: 'You are a highly intelligent AI assistant.',103 prompt: 'Find all prime numbers p such that p^2 + 2 is also prime. Prove your answer.',104 providerOptions: {105 xai: { reasoningEffort: 'high' },106 },107});108109console.log('Final Response:', result.text);110```111112```bash customLanguage="bash" highlightedLines="7"113curl https://api.x.ai/v1/responses \114 -H "Content-Type: application/json" \115 -H "Authorization: Bearer $XAI_API_KEY" \116 -m 3600 \117 -d '{118 "model": "grok-4.6",119 "reasoning": {"effort": "high"},120 "input": [121 {122 "role": "system",123 "content": "You are a highly intelligent AI assistant."124 },125 {126 "role": "user",127 "content": "Find all prime numbers p such that p^2 + 2 is also prime. Prove your answer."128 }129 ]130}'131```132133### Multi-agent model134135For `grok-4.20-multi-agent`, the `reasoning.effort` parameter controls **how many agents** collaborate on a request rather than reasoning depth. See the [Multi Agent](/developers/model-capabilities/text/multi-agent) documentation for details.136137### Summary table138139| Model | `reasoning` parameter | Behavior |140|---|---|---|141| `grok-4.6` | `reasoning.effort`: `"low"` / `"medium"` / `"high"` (default) / `"xhigh"` | Controls reasoning depth (cannot be disabled) |142| `grok-4.5` | `reasoning.effort`: `"low"` / `"medium"` / `"high"` (default) | Controls reasoning depth (cannot be disabled) |143| `grok-4.20-multi-agent` | `reasoning.effort`: `"low"` / `"medium"` / `"high"` / `"xhigh"` | Controls agent count (4 or 16) |144145## Summarized Reasoning Content146147For `grok-4.6`, we expose summarizations of the model's internal reasoning. Here's an example of how to stream the reasoning summary deltas alongside the final response:148149```python customLanguage="pythonXAI"150import os151152from xai_sdk import Client153from xai_sdk.chat import system, user154155client = Client(156 api_key=os.getenv("XAI_API_KEY"),157 timeout=3600, # Override default timeout with longer timeout for reasoning models158)159160chat = client.chat.create(161 model="grok-4.6",162 messages=[system("You are a highly intelligent AI assistant.")],163)164chat.append(user("A projectile is launched at 30 m/s at 37° above horizontal from a 45 m cliff. Find its speed on impact. (g=10 m/s²)"))165166content_started = False167168print("\n\n--------- Reasoning ---------", flush=True)169170latest_response = None171for response, chunk in chat.stream():172 if chunk.reasoning_content:173 print(chunk.reasoning_content, end="", flush=True)174```175176```python customLanguage="pythonOpenAISDK"177import os178import httpx179from openai import OpenAI180181client = OpenAI(182 base_url="https://api.x.ai/v1",183 api_key=os.getenv("XAI_API_KEY"),184 timeout=httpx.Timeout(3600.0),185)186187stream = client.responses.create(188 model="grok-4.6",189 input=[190 {"role": "system", "content": "You are a highly intelligent AI assistant."},191 {"role": "user", "content": "A projectile is launched at 30 m/s at 37° above horizontal from a 45 m cliff. Find its speed on impact. (g=10 m/s²)"},192 ],193 stream=True,194)195196print("\n\n--------- Reasoning ---------", flush=True)197for event in stream:198 if event.type in ("response.reasoning_text.delta", "response.reasoning_summary_text.delta"):199 print(event.delta, end="", flush=True)200```201202```typescript customLanguage="javascriptAISDK"203import { xai } from '@ai-sdk/xai';204import { streamText } from 'ai';205206const result = streamText({207 model: xai.responses('grok-4.6'),208 system: 'You are a highly intelligent AI assistant.',209 prompt: 'A projectile is launched at 30 m/s at 37° above horizontal from a 45 m cliff. Find its speed on impact. (g=10 m/s²)'210});211212console.log("\n\n--------- Reasoning ---------")213214for await (const part of result.fullStream) {215 if (part.type === 'reasoning-delta') {216 process.stdout.write(part.text);217 } 218}219```220221```bash customLanguage="bash"222curl https://api.x.ai/v1/responses \223 -H "Content-Type: application/json" \224 -H "Authorization: Bearer $XAI_API_KEY" \225 -m 3600 \226 -d '{227 "input": [228 {229 "role": "system",230 "content": "You are a highly intelligent AI assistant."231 },232 {233 "role": "user",234 "content": "A ball is thrown upward at 25 m/s from the top of a 60 m building. Find the maximum height above the ground. (g=10 m/s²)"235 }236 ],237 "model": "grok-4.6",238 "stream": true239}'240```241242### Sample Output243244```output245--------- Reasoning ---------246The problem is: A projectile is launched at 30 m/s at 37° above horizontal from a 45 m cliff. Find its speed on impact. (g=10 m/s²)247I need to find the speed when the projectile hits the ground. It's launched at 30 m/s at 37° from a 45 m cliff, with g=10 m/s².248249Conservation of energy is a good approach. The initial kinetic energy is (1/2)mv² with v=30 m/s, and initial potential energy is mgh with h=45 m, taking ground as zero.250251At impact, potential energy is zero, so initial KE + initial PE = final KE.252253Thus, (1/2)m(30)² + mg(45) = (1/2)m v_f²254255v_f² = 900 + 2*10*45 = 900 + 900 = 1800256257v_f = sqrt(1800) = 30√2 m/s ≈ 42.4 m/s258259The angle doesn't affect the final speed because the initial kinetic energy and potential energy change are the same regardless of direction, as long as the speed and height are the same.260261Yes, that makes sense. The final speed is sqrt(v0² + 2gh), independent of the launch angle.262```263264When you use a reasoning model, the reasoning tokens are billed as part of your total consumption.265