Sub topic 9
Reasoning tokens and when extra thinking pays off
This chapter assumes you have read the earlier chapters on token pricing and agent loop cost. You should know that output tokens usually cost more than input tokens, and that each turn of an agent loop resends the growing context. You should also be able to read short Python functions.
What reasoning tokens are
A reasoning token (also called a thinking token) is a token the model generates while working out an answer, before it writes the visible reply. Models with an extended thinking mode produce a block of intermediate steps first. They then produce the final text or tool call.
Three facts shape the cost:
- Providers generally bill reasoning tokens as output tokens, at the output rate. Check your provider's documentation for the exact rule.
- The reasoning text is often hidden or summarized in the response. You still pay for the full reasoning, not for the summary you see.
- The number of reasoning tokens varies per request. Some APIs let you set a budget or an effort level, which is a limit or a hint, not an exact count.
Because output tokens are the expensive kind, a model that thinks for 8,000 tokens before a 500-token edit can cost more for that one step than the entire input of a mid-sized context.
Pricing a request with thinking
The cost function from the pricing chapter still applies. You add the reasoning tokens to the output count.
def request_cost(usage, price):
"""Cost in USD of one request. Prices are USD per million tokens."""
return (
usage["input_tokens"] * price["input"]
+ usage["output_tokens"] * price["output"]
) / 1_000_000
# Placeholder prices, not real rates. Use your provider's current price list.
price = {"input": 3.0, "output": 15.0}
visible_output = 1_000
reasoning = 8_000
no_thinking = {"input_tokens": 20_000, "output_tokens": visible_output}
with_thinking = {
"input_tokens": 20_000,
"output_tokens": visible_output + reasoning, # reasoning is billed as output
}
print(request_cost(no_thinking, price)) # 0.075
print(request_cost(with_thinking, price)) # 0.195The request with thinking costs 2.6 times as much. The input did not change. The whole increase comes from the extra output tokens.
Some providers report reasoning tokens in a separate usage field. Others fold them into the output count. When you read usage data, find out which one your provider does. If you assume the output count is only visible text, you will underestimate spend.
Where thinking accumulates in a loop
In an agent loop, thinking happens on every turn that uses it. A 20-turn session with 4,000 reasoning tokens per turn adds 80,000 output tokens. At the placeholder output rate above, that is 1.20 USD of output from reasoning alone.
Whether the reasoning from earlier turns is resent as input on later turns depends on the provider and the API mode. Some APIs drop earlier reasoning blocks from the context. Others require you to pass them back in certain cases, such as when the model is mid-way through a tool-use sequence. If they are resent, they also add to context growth, and the context-growth chapter's arithmetic applies to them too. Read your provider's rules and confirm them in the usage data.
When extra thinking pays off
Extra thinking helps when the answer depends on a chain of dependent steps and a wrong early step spoils everything after it. It helps less when the answer is mostly retrieval or formatting.
| Step type | Thinking likely to help? | Reason |
|---|---|---|
| Planning a multi-file change | Yes | Steps depend on each other, and mistakes are costly to undo |
| Debugging a failure with unclear cause | Yes | The model must weigh several hypotheses |
| Designing an interface or data model | Yes | Trade-offs need to be compared before writing code |
| A mechanical edit, such as renaming a variable | No | The answer is obvious, and thinking only adds cost |
| Summarizing tool output | Usually no | The task is compression, not reasoning |
| Running a command and reporting the result | No | There is little to decide |
A useful test is to ask what a retry costs. If a wrong answer is cheap to detect and fix, such as a failing unit test, a cheaper step plus a retry may cost less than thinking hard each time. If a wrong answer is expensive, such as a bad plan that leads to ten wasted turns, thinking up front is cheap insurance.
Thinking is not a free quality dial
More thinking does not always give better results. Common failure modes:
- Overthinking simple tasks. The model spends thousands of tokens on a trivial edit. You pay for tokens that change nothing.
- Diminishing returns. Going from no thinking to a modest budget often helps a lot. Going from a large budget to a very large one often helps little.
- Higher latency. Thinking tokens are generated before the answer, so the first visible output arrives later. In an interactive session, that delay is part of the cost.
- Budget truncation. If the thinking budget is too small for the problem, the model may stop reasoning early and answer with partial analysis. A budget is a ceiling, and the model may use less than it.
- Interaction with output limits. Reasoning tokens usually count toward the maximum output setting. If you set a low maximum, a long reasoning pass can leave little or no room for the visible answer.
Thinking versus a bigger model
You have two ways to buy more capability for a step: more thinking on a smaller model, or a larger model with little or no thinking. Neither always wins.
Thinking raises only the output side of the bill, and only for the steps where you enable it. A larger model raises the price of every token on every step it handles, including a long input context. For a step with a big context and a small decision, thinking on a smaller model can be cheaper. For a step where the smaller model lacks the knowledge or skill, no amount of thinking closes the gap, and the larger model is the better choice.
You cannot settle this from price lists. You settle it by measuring cost per resolved task, which a later chapter covers.
Controlling thinking in practice
Practical settings, in order of how often they help:
- Turn thinking off by default for mechanical steps. Enable it for planning and debugging.
- Use effort levels or budgets where the API offers them. Start low and raise the setting only when failures justify it.
- Set the output limit with the thinking budget in mind. Keep room for the answer.
- Log reasoning tokens per step kind. You can then see which steps burn thinking tokens without improving results.
- Compare outcomes, not just cost. A step that costs more but halves the retry rate may be cheaper overall.
You can combine this with routing from a later chapter. The routing table can name a thinking setting alongside the model:
ROUTES = {
"plan": {"model": "large-model", "thinking_budget": 8_000},
"debug": {"model": "mid-model", "thinking_budget": 4_000},
"edit": {"model": "mid-model", "thinking_budget": 0},
"run_tests": {"model": "small-model", "thinking_budget": 0},
}
DEFAULT = {"model": "mid-model", "thinking_budget": 0}
def pick_settings(step_kind):
return ROUTES.get(step_kind, DEFAULT)
print(pick_settings("plan")) # {'model': 'large-model', 'thinking_budget': 8000}
print(pick_settings("other")) # {'model': 'mid-model', 'thinking_budget': 0}The model names and budgets are placeholders. A budget of 0 means the code should not request extended thinking for that step. How you pass this to the API depends on the provider.
Estimating the cost of a thinking policy
You can compare two policies before running them. Suppose a session has 20 turns. Under policy A, none use thinking. Under policy B, 3 planning or debugging turns use 6,000 reasoning tokens each.
def thinking_output_cost(turns_with_thinking, reasoning_per_turn, price_output):
"""Extra output cost in USD from reasoning tokens."""
return turns_with_thinking * reasoning_per_turn * price_output / 1_000_000
policy_a = thinking_output_cost(0, 0, 15.0)
policy_b = thinking_output_cost(3, 6_000, 15.0)
print(policy_a, policy_b) # 0.0 0.27Policy B adds 0.27 USD per session at the placeholder rate. If it raises the share of sessions that finish without a rework loop, it can pay for itself. If each rework loop costs more than 0.27 USD divided by the improvement in success rate, the policy is worth it. For example, if a rework costs 1.50 USD and policy B prevents one rework in every five sessions, it saves 0.30 USD per session on average, a little more than it costs.
Edge cases
- Cached prefixes and thinking settings. On some providers, changing the thinking configuration between turns can invalidate part of the cache. A cache hit may need the same settings as before. Check the provider's caching rules before you toggle thinking per turn.
- Hidden reasoning in usage logs. If your logging only counts visible text, your estimates will be off. Use the token counts from the API response, not a count of the text you can see.
- Streaming and timeouts. Long reasoning delays the first token. Set client timeouts with that in mind.
- Non-reasoning models that think aloud. Asking a model to "think step by step" in the prompt produces visible tokens that you also pay for as output. It is the same cost, only in the open.
Exercise
A step has 30,000 input tokens and produces 600 visible output tokens. With thinking enabled, the model also generates 5,000 reasoning tokens. Using placeholder prices of 3.0 USD per million input tokens and 15.0 USD per million output tokens, what does the step cost with and without thinking, and what share of the thinking cost comes from the reasoning tokens?
Show answer
Without thinking: 30,000 × 3.0 / 1,000,000 = 0.09 USD of input, plus 600 × 15.0 / 1,000,000 = 0.009 USD of output, for 0.099 USD. With thinking: output is 5,600 tokens, so 5,600 × 15.0 / 1,000,000 = 0.084 USD, plus 0.09 USD of input, for 0.174 USD. The reasoning tokens add 5,000 × 15.0 / 1,000,000 = 0.075 USD, which is about 43 percent of the 0.174 USD total.
Exercise
Your agent edits a config file by renaming one key. A teammate proposes enabling a large thinking budget for every step to improve quality. Give two reasons this is a poor default, and name one kind of step where you would still enable thinking.
Show answer
First, a rename is mechanical, so extra reasoning adds output cost and latency without changing the result. Second, thinking is billed at the output rate on every turn, so a blanket setting multiplies cost across the whole loop. Thinking is still worth enabling for planning a multi-file change or debugging a failure with an unclear cause, where a wrong early decision causes costly rework.