Grok’s reasoning mode instructs the model to think through a problem before producing a final response, trading higher token usage for better accuracy on complex tasks. TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/phpaisdk/xai/llms.txt
Use this file to discover all available pages before exploring further.
aisdk/xai provider exposes this through the portable Reasoning::effort() helper, which maps directly onto the reasoning_effort field in the underlying OpenAI-compatible request body.
Enabling Reasoning
Pass aReasoning::effort() instance to the ->reasoning() builder method on any Generate::text() call. The provider serialises the effort level and forwards it to the xAI API automatically:
Effort Levels
TheReasoning::effort() helper accepts one of three string values:
| Level | Behaviour |
|---|---|
'low' | Minimal reasoning steps — fastest response, lowest token cost. Suitable for most everyday tasks. |
'medium' | Balanced reasoning depth. A good default when you need more careful answers without the full cost of high effort. |
'high' | Maximum reasoning depth — slowest response, highest token cost. Best reserved for complex multi-step problems, mathematical proofs, or code that requires exhaustive analysis. |
reasoning_effort parameter in the OpenAI-compatible request body sent to xAI. The test suite confirms this mapping:
Supported Models
Reasoning is available on models that declare thereasoning capability in resources/models.json:
| Model pattern | Reasoning support |
|---|---|
grok-4* (e.g. grok-4, grok-4.3) | ✅ Yes |
grok-3* (e.g. grok-3, grok-3-mini) | ✅ Yes |
grok-2* (e.g. grok-2-vision) | ❌ No |
grok-2* family does not list the reasoning capability in the model catalog. Passing ->reasoning() to a grok-2 model will be ignored or may produce an API error — use grok-3* or grok-4* for reasoning tasks.