Hidden thinking uses the same token budget
The thinking sizes are made up. A real model decides by itself how long to think, within the effort you set.
Reasoning models write hidden thinking tokens before the visible answer. That helps on multi-step problems, and it costs time and money, and the thinking shares your max_tokens budget, which creates a classic trap: an empty reply with finish_reason: length.
Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.
Ready for more? This phase has 5 hands-on exercises with automatic checks.
Practice questions
Write the code in the editor, run it, then open the model answer to compare.
Write fake_call(needed, answer_tokens, max_tokens) that returns (reasoning_used, answer_used, finish) using the rules in the example. Print the result for (300, 25, 100) and (300, 25, 400).
Write min_budget(needed, answer_tokens) and print it for needed=120 and answer_tokens=25. Add a 10 percent safety margin, rounded up, and print that too.
Explain it without notes
Why do reasoning models help on multi-step problems?
What is the max_tokens trap and how do you avoid it?
When would you not use a reasoning model?
How do reasoning tokens show up in cost and latency?
Expected output
effort=low max_tokens=100 -> finish=stop reasoning= 40 answer=25 (complete) cost=0.000130
effort=high max_tokens=100 -> finish=length reasoning=100 answer= 0 (empty) cost=0.000200
effort=medium max_tokens=200 -> finish=stop reasoning=120 answer=25 (complete) cost=0.000290
effort=high max_tokens=320 -> finish=length reasoning=300 answer=20 (cut off) cost=0.000640
effort=high max_tokens=400 -> finish=stop reasoning=300 answer=25 (complete) cost=0.000650