Guides
Reasoning
Reasoning models think before they answer, which helps with math, coding, complex planning and other multi-step tasks. Thinking tokens are billed at the output price, so match the reasoning depth to the difficulty of the task to balance quality and cost.
GPT models
Chat Completions uses reasoning_effort and the Responses API uses reasoning.effort. Typical values are low, medium and high:
from openai import OpenAI
client = OpenAI(api_key="sk-...", base_url="https://api.flyrouter.ai/v1")
resp = client.chat.completions.create(
model="gpt-6.1-sol",
reasoning_effort="high",
messages=[{"role": "user", "content": "Prove that the square root of 2 is irrational"}],
)
print(resp.choices[0].message.content)Reasoning tokens are reported in the reasoning-token breakdown of usage.
Claude models
Newer Claude models use adaptive thinking: the model decides whether and how long to think, and you set the overall effort with output_config.effort: low, medium, high, xhigh or max.
from anthropic import Anthropic
client = Anthropic(api_key="sk-...", base_url="https://api.flyrouter.ai")
with client.messages.stream(
model="claude-opus-5-5",
max_tokens=32000,
thinking={"type": "adaptive", "display": "summarized"},
output_config={"effort": "high"},
messages=[{"role": "user", "content": "Design a URL shortener that handles a million concurrent users. Explain the architecture and trade-offs."}],
) as stream:
msg = stream.get_final_message()
for block in msg.content:
if block.type == "thinking":
print("[thinking summary]", block.thinking)
elif block.type == "text":
print(block.text)display: "summarized"returns a summary of the reasoning. Without it, thinking blocks come back with empty text (the model still thinks, and it's still billed).- Rules of thumb:
lowfor chat and classification; start atmediumorhighfor everyday coding and agent work; usexhighormaxwhen correctness matters more than cost.
Old and new parameters
Newer models such as claude-opus-5-5, claude-sonnet-5-5, claude-haiku-5-5 and claude-fable-5-1 no longer accept {"type": "enabled", "budget_tokens": N} (400). Use {"type": "adaptive"} with output_config.effort instead. claude-opus-5-5, claude-sonnet-5-5 and claude-fable-5-1 also can't turn thinking off with {"type": "disabled"}; lower the effort if you want faster, cheaper answers. Older models such as claude-haiku-4-5 still use budget_tokens.
Tips
- Thinking can take a while, so use streaming and set
max_tokenshigh enough that the answer isn't cut off. - In multi-turn conversations, pass the thinking blocks the model returned back unchanged in the history. Don't edit or remove them.
- Simple tasks don't need deep reasoning. Lower effort is often faster and cheaper with no loss in quality.