Menu
CoddyTech

Effort and Thinking

Part of the Calling Models From Code section of Coddy's AI Engineering journey. Lesson 8 of 22.

Claude Opus 5.5 can think before it answers, and it decides for itself when a question needs it. You set how much it may think with effort, inside output_config: "low", "medium" (the default on Opus 5.5), "high", "xhigh" or "max". Thinking cannot be turned off on this model; low effort is the way to keep it short.

for effort in ["low", "max"]:
    response = client.messages.create(
        model="claude-opus-5-5",
        max_tokens=1000,
        output_config={"effort": effort},
        messages=[{"role": "user", "content": "What is 17 * 23?"}],
    )
    print(effort, [block.type for block in response.content], response.usage.output_tokens)

This prints low ['text'] 5, then max ['thinking', 'text'] 261. The thinking block comes first, and by default its text is empty: you get a summary only if you ask for one. Its tokens still count as output tokens, so you pay for them and they use up max_tokens. The stand-in thinks only at high and above, with a fixed number of tokens; a real model thinks as much as the question needs.

challenge icon

Challenge

Medium

See what effort changes in a reply. The starter reads a question and an effort level.

  1. Send the question with model="claude-opus-5-5", max_tokens=1000 and output_config={"effort": effort}.
  2. Print Effort: and the level.
  3. Print Thinking blocks: and how many blocks have the type thinking.
  4. Print Answer: and the text of the text block.
  5. Print Output tokens: and the output token count.

For example, for the input What is 12 * 12? and xhigh the program prints:

Effort: xhigh
Thinking blocks: 1
Answer: 12 * 12 = 144
Output tokens: 133

At low there is no thinking block and the same answer costs 5 output tokens.

Try it yourself

import coddy_ai as anthropic  # in production: import anthropic

client = anthropic.Anthropic()

question = input()
effort = input()

# Send the question at the given effort, then print the effort,
# the number of thinking blocks, the answer and the output tokens
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Calling Models From Code

Practice on your own: Online Python compiler