Claude extended thinking in n8n: building multi-step reasoning pipelines for complex agent decisions
Claudes extended thinking lets you allocate more compute to reasoning before the model answers. Here is when to use it in n8n workflows, how to wire the thinking block through subsequent nodes, and the cost/latency trade-offs.
Claude extended thinking in n8n: building multi-step reasoning pipelines for complex agent decisions
Most n8n workflows use Claude for text generation, summarisation, or classification — tasks where the model answers immediately with a response. Extended thinking changes this: instead of generating a response directly, Claude allocates additional compute to work through a problem before producing its final answer. The reasoning process is returned as a separate thinking block alongside the normal response.
This matters for agent workflows where the classification or routing decision is genuinely complex — where getting it wrong sends an entire workflow down the wrong path.
When extended thinking is worth it
Extended thinking is not a free upgrade. It increases latency (the thinking phase adds time before the response), and it costs tokens — the thinking blocks count against your context limit and are billed accordingly.
Use it when:
Do not use it for simple generation tasks — summarisation, tone rewrites, simple categorisation with clear labels. The thinking overhead is not justified.
How to call Claude with extended thinking from n8n
The Claude API supports extended thinking via the thinking parameter in the request body. In n8n, you call Claude through the HTTP Request node.
Here is the configuration for a node that calls Claude with extended thinking enabled:
Node type: HTTP Request
Method: POST
URL: https://api.anthropic.com/v1/messages
Headers:
`json
{
"x-api-key": "{{ $credentials.anthropicApiKey }}",
"anthropic-version": "2023-06-01",
"content-type": "application/json"
}
`
Body (JSON):
`json
{
"model": "claude-opus-4-7-20251101",
"max_tokens": 16000,
"thinking": {
"type": "enabled",
"budget_tokens": 10000
},
"messages": [
{
"role": "user",
"content": "{{ $json.userMessage }}"
}
]
}
`
The budget_tokens parameter sets the maximum number of tokens Claude can use for thinking. The model will use up to this budget but may use less. A value between 5,000 and 16,000 is typical for complex routing decisions. Higher values increase reasoning depth and cost.
Important constraint: When extended thinking is enabled, temperature must be 1 (the default) and cannot be overridden. If your existing workflow sets temperature, remove it before enabling thinking.
What the response looks like
The API response includes both thinking blocks and the final content block. The structure:
`json
{
"content": [
{
"type": "thinking",
"thinking": "Let me work through this step by step. The request mentions a refund for order #4821. First, I need to check whether..."
},
{
"type": "text",
"text": "ROUTE: refund_team\nREASON: Order is within 30-day window and value is below auto-approve threshold."
}
]
}
`
Your downstream nodes will typically want the text block, not the thinking block. In n8n, extract it with:
`
{{ $json.content.find(block => block.type === 'text').text }}
`
If you want to log the reasoning for debugging (useful during development), extract the thinking block with:
`
{{ $json.content.find(block => block.type === 'thinking').thinking }}
`
Wiring the thinking block through downstream nodes
A common pattern is to use the reasoning output — not just the final answer — to inform subsequent nodes. For example, a routing node that uses extended thinking can pass its reasoning to an audit log, a Slack notification, or a quality-check node.
Workflow structure:
`
[Trigger] → [Claude HTTP Request (extended thinking)] → [Set node: extract text + thinking] → [Switch node: route by decision] → [Branch A / Branch B / Branch C]
↓
[Airtable: log decision + reasoning]
`
In the Set node after the Claude call, extract both blocks:
`json
{
"decision": "{{ $json.content.find(b => b.type === 'text').text }}",
"reasoning": "{{ $json.content.find(b => b.type === 'thinking').thinking }}",
"model": "{{ $json.model }}",
"input_tokens": "{{ $json.usage.input_tokens }}",
"output_tokens": "{{ $json.usage.output_tokens }}"
}
`
The reasoning field is your audit trail. If a decision is questioned later, you have Claude's step-by-step logic stored with the output.
Practical patterns for complex routing
Pattern 1: Multi-condition classification
Prompt structure that works well with extended thinking:
`
You are a support routing agent. A customer has sent the following message:
---
{{ $json.customerMessage }}
---
Evaluate the following conditions in order:
1. Is this a billing inquiry, a technical issue, or a general question?
2. If billing: does the message mention a specific order number?
3. If technical: does the issue affect the user's ability to access their account?
4. If general: is this a feature request or a complaint?
Respond with:
CATEGORY: [billing|technical|general]
SUBCATEGORY: [order_dispute|account_access|feature_request|complaint|other]
PRIORITY: [high|medium|low]
REASONING: [one sentence]
`
Extended thinking processes the conditions sequentially before producing the structured output. The parsed response goes directly into a Switch node.
Pattern 2: Rule evaluation with exceptions
For workflows that apply business rules with edge cases — discount eligibility, content moderation thresholds, approval routing — provide the rules as a numbered list and ask Claude to reason through each one:
`
Apply the following discount eligibility rules to this order:
Rules:
1. Orders over €100 qualify for 10% discount
2. First-time customers qualify for 15% discount regardless of order value
3. Combined discounts cap at 15%
4. Wholesale accounts are excluded from all promotional discounts
Order data:
{{ JSON.stringify($json.order) }}
Is this order eligible for a discount? If yes, what percentage?
Respond: ELIGIBLE: yes/no | PERCENTAGE: N | RULE_APPLIED: [rule number]
`
Cost and latency expectations
A call with budget_tokens: 10000 typically takes 8–15 seconds and costs approximately 2–4x a standard call of the same input length. For a workflow that runs hundreds of times per day, this adds up. Profile your use case before deploying extended thinking in a high-volume node.
For development and testing, set budget_tokens to 5000 and increase only if reasoning quality is insufficient. Thinking token costs are displayed separately in your Anthropic usage dashboard.
---
More n8n and Claude integration patterns at [The Automation Factory](https://theagentfabric.vercel.app). If you are building multi-agent decision pipelines, see our guide to Claude tool use in n8n.