Sub topic 3
What a Reasoning Model Is
This chapter assumes you have called an LLM API from code, that you know what tokens, context windows and maximum output tokens are, and that you can read short Python programs. It builds the working model that the rest of the tutorial relies on. Later chapters cover the controls (effort levels, thinking budgets) and the costs in detail.
The short definition
A reasoning model is a language model that has been trained to produce a long internal chain of thought before it writes its final answer. The chain of thought is a sequence of ordinary tokens. The model uses it to break a problem into parts, try an approach, check a result, and revise. Only after that does it write the answer you see.
A standard chat model can also reason step by step if you ask it to. The difference is where the behavior comes from:
- In a standard model, step-by-step output is something you request in the prompt. The model does it if you ask, and the quality depends on how you ask.
- In a reasoning model, the behavior is trained in. The model decides on its own how much to think, and it does so on every request unless you limit it.
Where the idea comes from
Two earlier ideas lead to reasoning models.
Chain-of-thought prompting showed that a model gives better answers on multi-step problems when it writes out intermediate steps before the final answer. Each generated token becomes input for the next one, so the written steps work as scratch space. A model that writes "3599 = 60² − 1 = (60−1)(60+1)" can use that line when it reaches its conclusion. A model that must answer in one token cannot.
Test-time compute is the amount of computation a model spends while answering, as opposed to while being trained. Chain-of-thought text is one way to spend more of it: more generated tokens means more forward passes through the network before the answer is committed. For a long time, improving a model meant spending more compute on training. Reasoning models add a second lever. You can also improve results by letting the model spend more compute on each question.
Reasoning models combine the two. Training (typically with reinforcement learning on problems whose answers can be checked, such as math and code) rewards the model for chains of thought that lead to correct answers. The model learns habits that prompting alone does not reliably produce, such as re-checking an intermediate result, abandoning a dead end, and trying a different method.
What happens during one request
From your code, a reasoning model looks like any other model behind a chat or responses endpoint. Internally, a request goes through these phases:
- The model reads your prompt, including any system or developer instructions and earlier turns.
- It generates reasoning tokens. These are not part of the answer. They can include planning, trial calculations, self-checks and corrections.
- It generates the answer tokens, which are the text you asked for.
- The API returns the answer, usage counts that include the reasoning tokens, and (depending on the provider) a summary of the reasoning or the thinking itself.
The key point for an API user is that phase 2 takes time and tokens. Nothing streams to the user while it runs, unless you display a reasoning summary. The wait before the first visible answer token is therefore longer and less predictable than with a standard model.
Seeing it in a response
The following call uses the OpenAI Responses API. It sets a low effort level, then prints the answer and how many of the output tokens went to reasoning.
from openai import OpenAI
client = OpenAI()
response = client.responses.create(
model="o4-mini",
reasoning={"effort": "low"},
input="A train leaves at 14:10 and arrives at 17:45. How long is the trip?",
)
print(response.output_text)
print("reasoning tokens:", response.usage.output_tokens_details.reasoning_tokens)
print("total output tokens:", response.usage.output_tokens)The answer is a single short line, such as "3 hours 35 minutes". The usage numbers are more instructive. The output token total is larger than the length of that line, and the difference is the reasoning. The reasoning_tokens figure is a part of output_tokens, not an addition to it.
The same idea in the Anthropic Messages API is called extended thinking:
import anthropic
client = anthropic.Anthropic()
response = client.messages.create(
model="claude-sonnet-4-5",
max_tokens=4096,
thinking={"type": "enabled", "budget_tokens": 2000},
messages=[
{"role": "user", "content": "Is 3599 a prime number? Explain briefly."}
],
)
for block in response.content:
if block.type == "thinking":
print("[thinking]", block.thinking)
elif block.type == "text":
print("[answer]", block.text)The response content is a list of blocks. A thinking block carries the model's reasoning and a text block carries the answer. Here max_tokens must be larger than budget_tokens, because thinking counts toward the output limit. (3599 is not prime: it equals 59 × 61.)
The two APIs differ in vocabulary and in what they expose, which later chapters cover. Both show the same underlying structure: reasoning first, answer second, and both are counted as output.
What changes compared with a standard model
| Aspect | Standard chat model | Reasoning model |
|---|---|---|
| Step-by-step work | Only if the prompt asks for it | Done by default, in a separate reasoning phase |
| Output tokens | Roughly the length of the visible answer | Visible answer plus reasoning tokens |
| Time to first answer token | Short and fairly steady | Longer, varies with problem difficulty |
| Cost per request | Mostly driven by prompt and answer length | Often dominated by reasoning tokens on hard problems |
| Reasoning visibility | The visible text is the whole output | Raw reasoning is often hidden or summarized |
| Strength | Writing, summarizing, extraction, chat, fast lookups | Multi-step math, code, planning, constraint puzzles, ambiguous analysis |
| Controls | Temperature, max tokens | Effort level or thinking budget, plus output limits |
Some of these controls change by model. Several reasoning models restrict or ignore sampling parameters such as temperature, so check the documentation for the model you use.
Common misconceptions
"The reasoning is the model's real thought process"
The reasoning text is generated the same way as any other output. It is useful because the model conditions on it when writing the answer. It is not guaranteed to be a faithful record of how the network reached its result. Treat it as a working trace that often helps debugging, not as proof of why the model answered as it did.
"Reasoning models are just better chat models"
They are better on some tasks and worse on others. For simple lookups, rewrites and classification, the reasoning phase adds cost and delay and often adds no accuracy. A reasoning model can also over-analyze a simple question. The chapter on overthinking returns to this.
"I only pay for the answer I see"
You pay for reasoning tokens even when the API does not return them. They are billed as output tokens. You can see the count in the usage object, but you cannot always see the text.
"More thinking always means a better answer"
Accuracy gains flatten as the reasoning grows. On easy tasks they flatten almost at once. The practical question is how much reasoning a task needs, and you answer it by measuring, as later chapters show.
Edge cases to know about now
- Short answers can hide large costs. A one-line reply may follow thousands of reasoning tokens. Judge cost from the usage object, not from the visible text.
- The output limit is shared. If the limit is reached during reasoning, you can receive an empty or truncated answer even though the request succeeded. Output limits get their own chapter.
- Reasoning varies run to run. Two identical requests may use different amounts of reasoning and reach the answer by different routes.
- Short context for the reasoning. Reasoning tokens occupy space in the context window during the request. On multi-turn conversations, providers differ on whether earlier reasoning is kept or dropped, which affects both context size and billing.
- Not every model reasons. Some model families offer one model that can switch reasoning on or off, while others ship separate reasoning and non-reasoning models. Check which kind you have before assuming a parameter will work.
A practical way to see the difference
To build intuition, take one hard question and one easy question, and send each to a reasoning model. Compare the reasoning token counts. On the easy question, expect a small number. On the hard question, expect a much larger one. The model adjusts how much it thinks to the problem, within whatever limit you set. This adaptive behavior is the main practical change from a standard model, and the controls in the next chapters exist to bound it.
Summary of the working model
- A reasoning model generates a hidden or partly visible chain of thought, then an answer.
- The chain of thought comes from training, not from prompt wording, and it is built from ordinary output tokens.
- Those tokens count toward output limits, cost and latency.
- The amount of reasoning adapts to the difficulty of the task, and you can bound it with effort levels or budgets.
- Reasoning helps most on multi-step problems and helps least on simple ones.
Exercise
You send a short factual question to a reasoning model and get a one-sentence answer, but the usage object reports 1,800 output tokens. Where did the tokens go, and how are they billed?
Show answer
Most of the output tokens were reasoning tokens, the internal chain of thought generated before the answer. They are counted inside the output token total and billed at the output token rate, even if the API does not return the reasoning text. The visible one-sentence answer accounts for only a small share of the 1,800.
Exercise
A teammate says, "A reasoning model is a standard model that we prompt with 'think step by step'." Give two differences that show why this is incomplete.
Show answer
First, in a reasoning model the step-by-step behavior is trained in, usually with reinforcement learning on checkable problems, so it happens by default and includes habits such as self-checking and backtracking. Second, the reasoning is a separate phase whose tokens are counted and billed as output, often hidden or summarized, and controlled through effort levels or thinking budgets. A prompt-induced chain of thought is just part of the visible answer text.
Exercise
In the Anthropic example, why must maxtokens be larger than budgettokens?
Show answer
Thinking tokens count toward the output limit. If max_tokens were not larger than the thinking budget, the model could use the whole limit on thinking and have no room left to write the answer.