Debian Codegraph @

examples/thinking.py

raw
1 import anthropic
2
3 client = anthropic.Anthropic()
4
5 response = client.messages.create(
6 model="claude-sonnet-5-5",
7 max_tokens=16000,
8 thinking={"type": "adaptive", "display": "summarized"},
9 output_config={"effort": "high"},
10 messages=[
11 {
12 "role": "user",
13 "content": "Create a haiku about Anthropic. Think carefully about syllable counts before answering.",
14 }
15 ],
16 )
17
18 for block in response.content:
19 if block.type == "thinking":
20 print(f"Thinking: {block.thinking}")
21 elif block.type == "text":
22 print(f"Text: {block.text}")