Sub topic 1
Step-by-step reasoning in language models
Prerequisites
You should know how to call an LLM API, write basic prompts, and read Python. You should also understand tokens, context windows, and output limits.
Step-by-step reasoning
A standard chat model usually predicts the next response tokens directly. A reasoning model spends additional computation working through intermediate steps before producing its answer. These steps can help with multi-step arithmetic, code debugging, planning, and constraint-heavy tasks.
The internal process is related to chain-of-thought reasoning, but you should not assume that the model exposes its full chain of thought. APIs may return only the final answer or a short reasoning summary.
Spending compute at inference time
Inference is the process of running a trained model to produce an answer. Test-time compute means spending more resources during inference instead of using the same fixed amount for every request.
A harder problem may benefit from more internal work. An easy request may not. More computation usually increases latency and token usage, so reasoning is a quality-versus-cost decision.
flowchart TD
A[Prompt] --> B{Task difficulty}
B -->|Low| C[Low reasoning effort]
B -->|High| D[Higher reasoning effort]
C --> E[Final answer]
D --> F[Internal reasoning]
F --> EWhat a reasoning model is
A reasoning model is trained or configured to spend tokens on intermediate problem solving. It is different from a standard chat model because the API may expose controls for that extra work, such as an effort level or a thinking budget.
The model still receives your prompt and returns an answer. You usually do not need to force it to “think step by step.” Such instructions can add unnecessary output or conflict with the model’s intended behavior. State the task, constraints, and success conditions clearly.
Reasoning tokens: hidden, billed and counted
Reasoning tokens are tokens used for internal computation. They may be hidden from the response, but they can still count toward usage and billing. They can also consume the model’s output allocation. If an API has a maximum output-token setting, reasoning tokens may leave fewer tokens available for the visible answer.
Usage metadata may report reasoning tokens separately:
print(response.usage.output_tokens_details.reasoning_tokens)
print(response.usage.output_tokens)The exact field names and billing rules depend on the provider and model. Check the model’s API documentation before estimating cost.
Setting an effort level
An effort parameter selects a provider-defined amount of reasoning:
response = client.responses.create(
model="o4-mini",
reasoning={"effort": "low"},
input="Find the shortest path through this graph."
)Use low effort for simple, high-volume requests. Use higher effort when correctness on a difficult task is worth additional latency and cost.
Exercise
Why might a reasoning model produce a shorter visible answer while using more tokens?
Show answer
Some tokens are spent on hidden internal reasoning before the final answer.