Skip to main content
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);
  }
}

Provider Support

ProviderHowConfiguration
Anthropicthinking parameterthinking: { type: 'enabled', budgetTokens: N }
OpenAINative (o-series models)Just use o1/o3/o4-mini models
GeminithinkingConfigthinking: { type: 'enabled', budgetTokens: N }
xAIReasoning model namesUse grok-*-reasoning models
GroqNot supported-
BedrockNot supported-

Next Steps

Structured Output

Get guaranteed JSON responses

Streaming

Real-time streaming responses