Some models can “think” before responding — breaking down complex problems step by step. This improves accuracy for math, logic, coding, and analysis tasks.
Anthropic Extended Thinking
const agent = new Agent ({
name: 'Math Tutor' ,
instructions: 'Solve problems step by step.' ,
model: anthropic ( 'claude-sonnet-4-6' ),
modelConfig: {
thinking: { type: 'enabled' , budgetTokens: 10000 }
}
});
const result = await agent . process ({ message: 'What is 17! / 15!?' });
console . log ( result . message ); // "272"
// Thinking content available in traces (Portal > Executions)
OpenAI Reasoning Models (o-series)
OpenAI’s o-series models reason natively — no configuration needed:
const agent = new Agent ({
name: 'Analyst' ,
instructions: 'Analyze data carefully.' ,
model: openai ( 'o4-mini' ),
});
Models: o1, o3, o3-mini, o4-mini
Reasoning models don’t support temperature, top_p, frequency_penalty, presence_penalty, or stop. These parameters are automatically stripped.
Gemini Thinking
Gemini 2.5+ models support thinking with a token budget:
const agent = new Agent ({
name: 'Coder' ,
instructions: 'Write clean code.' ,
model: gemini ( 'gemini-2.5-flash' ),
modelConfig: {
thinking: { type: 'enabled' , budgetTokens: 2048 }
}
});
xAI Reasoning Models
xAI Grok models with -reasoning in the name use chain-of-thought:
const agent = new Agent ({
name: 'Researcher' ,
instructions: 'Research thoroughly.' ,
model: xai ( 'grok-4-1-fast-reasoning' ),
});
Thinking in Streaming
When using processStream(), thinking content arrives as separate chunks:
const stream = await agent . processStream ({ message: 'Solve this equation...' });
for await ( const chunk of stream ) {
if ( chunk . type === 'thinking' ) {
console . log ( '[Thinking]' , chunk . data . content );
} else if ( chunk . type === 'content' ) {
process . stdout . write ( chunk . data . content );
}
}
Testing in Prompt Studio
Test thinking directly in the Portal without deploying an agent:
Go to Prompts and open any prompt
Click the config icon (sliders) in the top bar
Click Thinking to enable it (set budget tokens if needed)
Send a message — the thinking content appears as a collapsible “Pensou sobre a resposta” block
Works with Anthropic and Gemini providers. OpenAI and xAI reasoning models think natively without the toggle.
With LLM Standalone
const thinker = LLM . anthropic ( 'claude-sonnet-4-6' , {
thinking: { type: 'enabled' , budgetTokens: 8000 }
});
const result = await thinker . generate ( 'Solve: if 2x + 5 = 17, what is x?' );
console . log ( result . text ); // "x = 6"
console . log ( result . thinking ); // "Let me solve step by step: 2x + 5 = 17, 2x = 12, x = 6"
Provider Support
Provider How Configuration Anthropic thinking parameterthinking: { type: 'enabled', budgetTokens: N }OpenAI Native (o-series models) Just use o1/o3/o4-mini models Gemini thinkingConfigthinking: { type: 'enabled', budgetTokens: N }xAI Reasoning model names Use grok-*-reasoning models Groq Not supported - Bedrock Not supported -
Next Steps
Structured Output Get guaranteed JSON responses
Streaming Real-time streaming responses