How reasoning models think

Imagine you're building a tutoring app. Ask a regular AI "If it takes 5 minutes to boil one egg, how long to boil three?" and it might answer "15 minutes." But that's wrong because you can boil them all at once! A reasoning model would think step-by-step and catch this.

Pattern matching vs Chain-of-thought

Pattern matching gives direct answers. Chain-of-Thought shows its work step by step.

Chain-of-Thought (CoT) prompting: Instead of just asking "What is the answer?", you ask "Solve this step-by-step and show your work." This simple change dramatically improves accuracy on complex problems. The AI reasons through each step before answering.

Chain-of-Thought is pure prompting, so it works with any model. Some newer models go one step further with a built-in extended thinking mode that you switch on through the API. You give the model a private token budget to reason before it writes the answer, using a thinking parameter with a budget_tokens limit. Let us wire up that call.

Fill in the blanks: Complete the extended thinking API call

Loading practice…

Our CoT prompt uses 5 specific steps: (1) Understand the problem, (2) Break it into parts, (3) Solve each part, (4) Verify the answer, (5) State the final answer. Each step forces the AI to slow down and reason rather than jumping to a conclusion.

06-reasoning-models.ipynb
python
def solve_with_reasoning(problem: str, temperature: float = 0.3, max_tokens: int = 2000) -> str:
    """Solve a problem using chain-of-thought reasoning."""
    prompt = f"""{problem}

Please solve this step-by-step:
1. First, understand what is being asked
2. Break down the problem into steps
3. Solve each step
4. Verify your answer
5. Provide the final answer

Show your reasoning for each step."""

    response = completion(
        model=DEFAULT_MODEL,
        messages=[{"role": "user", "content": prompt}],
        temperature=temperature,
        max_tokens=max_tokens
    )
    return response.choices[0].message.content

The CoT prompt template forces step-by-step thinking. Low temperature (0.3) keeps reasoning focused. Higher max_tokens allows detailed explanations.

Let us test this with a classic trick question that trips up most AI models when they answer too quickly without thinking step by step.

06-reasoning-models.ipynb
python
# The classic trick question
problem = "If it takes 5 minutes to boil one egg, how long to boil three?"

answer = solve_with_reasoning(problem)
print(answer)
# Step 1: Understand - We need boiling time for 3 eggs
# Step 2: Key insight - Eggs can boil simultaneously!
# Step 3: One egg takes 5 min. Three eggs in the
#          same pot also take 5 min.
# Step 4: Verify - This assumes a pot large enough
# Final answer: 5 minutes

Without CoT, many models answer "15 minutes." With step-by-step reasoning, the AI correctly identifies that eggs boil simultaneously.

AI prompt: Try it with AI

Loading practice…

Quiz: Quiz

Loading practice…

Flashcards: Flashcards

Loading practice…

Now you understand how Chain-of-Thought works and when to use it. Next, we will put reasoning to work on math and logic problems where step-by-step thinking makes the biggest difference.