Skip to Content
ModelsClaudeExtended thinking

Claude extended thinking

This page explains how to enable Claude’s extended thinking and read the thinking content. For model IDs and endpoints, see the Claude family overview.

Key pointPass thinking on the native API and a reasoning object on the OpenAI-compatible API. Do not set temperature when thinking is enabled.

Extended thinking lets the model reason before answering, which helps with math, code and multi-step analysis. In our tests, the following models reliably returned thinking content on the default provider: Opus 5.5, Opus 5, Opus 4.8, Opus 4.6, Sonnet 4.6, Haiku 5.5, Haiku 4.5, Fable 5.

Anthropic-native API

There are two modes:

ModeSyntaxNotes
Fixed budget"thinking": {"type": "enabled", "budget_tokens": 2000}budget_tokens must be at least 1024 and less than max_tokens
Adaptive"thinking": {"type": "adaptive"}The model decides how deeply to think; tune it with settings such as "output_config": {"effort": "low"}
claude_thinking.py
import os import anthropic client = anthropic.Anthropic(base_url="https://api.ofox.io/anthropic", api_key=os.environ["OFOX_API_KEY"]) message = client.messages.create( model="anthropic/claude-opus-5.5", max_tokens=4000, thinking={"type": "enabled", "budget_tokens": 2000}, messages=[{"role": "user", "content": "A bat and a ball cost $1.10 in total. The bat costs $1 more than the ball. How much does the ball cost?"}], ) for block in message.content: if block.type == "thinking": print("[Thinking]", block.thinking) elif block.type == "text": print("[Answer]", block.text)
  • In the response content, thinking blocks come first, followed by text blocks. Each thinking block carries a signature, which must be passed back unchanged in multi-turn tool calling.
  • When streaming, thinking content arrives as thinking_delta events, followed by a single signature_delta event, and then text_delta begins.
  • When thinking is enabled, do not set temperature (or set it to 1), and do not set top_k.
  • Tokens spent on thinking count toward output_tokens and are billed at the output rate.

OpenAI-compatible API

Enable it with a reasoning object, where max_tokens is the thinking budget:

claude_thinking_openai.py
import os from openai import OpenAI client = OpenAI(base_url="https://api.ofox.io/v1", api_key=os.environ["OFOX_API_KEY"]) resp = client.chat.completions.create( model="anthropic/claude-sonnet-4.6", max_tokens=4000, extra_body={"reasoning": {"max_tokens": 2000}}, messages=[{"role": "user", "content": "A bat and a ball cost $1.10 in total. The bat costs $1 more than the ball. How much does the ball cost?"}], ) msg = resp.choices[0].message details = getattr(msg, "reasoning_details", None) or [] print("[Thinking]", "".join(d.get("text", "") for d in details)) print("[Answer]", msg.content)
  • In non-streaming responses, thinking content is in message.reasoning_details; concatenate the text of each item in order.
  • In streaming responses, thinking content is in delta.reasoning_content.

For other errors, see Common errors.

Last updated on