xAI's documentation uses the following code-fixing example to demonstrate the basic way to call Grok 4.6:
Find and fix the bug, then explain it: function median(a){a.sort();return a[a.length/2]}The prompt's structure is simple, but it contains three explicit actions: find the problem, fix the problem, and explain the problem. The example code itself has potential issues, including a missing sort comparator and an undefined rule for even-length inputs, making it suitable for checking whether the model examines edge cases rather than merely rewriting the syntax.
Model name: grok-4.6
Context window: 500,000 tokens
Reasoning levels: low, medium, high (default), and xhigh
APIs: Responses API, Chat Completions
Tools: function calling, web search, X search, code execution
Input/output pricing: $2 / $6 per million tokens
The Responses API recommends setting prompt_cache_key; Chat Completions can use x-grok-conv-id to route the same conversation to the same server where possible, improving cache-hit rates.
Long Agent loops can be paired with context compaction to prevent the context from growing continuously.
Tasks with frequent tool calls should use function calling rather than having the model guess tool parameters in natural language.
You are a senior [ROLE].
Goal: [ONE CONCRETE OUTCOME].
Context: [RELEVANT CODE, DATA, OR LINKS].
Constraints: [STACK, BOUNDARIES, THINGS NOT TO INVENT].
Done means: [NUMBERED ACCEPTANCE CRITERIA].
Return: [EXACT OUTPUT FORMAT].
Before finishing, verify [TESTS, EDGE CASES, OR EXTERNAL FACTS].This template is a working template organized around the calling capabilities described in the official documentation; it is not a verbatim excerpt from xAI's documentation.
Grok 4.6