HAMZA KAREEM / CONCEPTS hamzawi.dev

Lesson 1522 min read

Reasoning Tokens (Billing & max_tokens)

the output you pay for and never see

AI engineeringAI engineering / LLM cost & inference

The myth

"Thinking is the model's internal business. It isn't in my response, so it doesn't cost me anything and it doesn't touch my max_tokens."

Actually

Reasoning tokens are billed as output tokens, at the full output rate, and they are spent from the same max_tokens ceiling as your answer. The only thing you don't get is the text.

What that costs, concretely

Claude Opus 5.5 output is $20/1M. One request that reasons 8,000 tokens, then writes a 500-token answer:

billed output = 8,000 + 500 = 8,500 tokens
cost          = 8,500 x $20 / 1e6 = $0.17
visible       = 500 tokens -> 6% of what you paid for

Read it off the response instead of guessing:

const r = await client.messages.create({
  model: "claude-opus-5-5",
  max_tokens: 16000,
  output_config: { effort: "medium" },
  messages: [{ role: "user", content: q }],
});
console.log(r.usage.output_tokens, r.stop_reason);

usage.output_tokens already includes the reasoning. There is no separate counter to subtract.

Trap 1: max_tokens is a shared budget

max_tokens: 1024 with thinking on is not "a short answer". The model reasons first, hits the ceiling mid-thought, and you get stop_reason: "max_tokens" with an empty or truncated text block. Classification endpoints copied from older code fail exactly this way. Give it room (~16k non-streaming, ~64k streaming) and control length in the prompt, not with the ceiling.

Trap 2: the stream that looks frozen

On current models thinking.display defaults to "omitted" — thinking blocks still arrive, with empty text. Your UI shows nothing for 20 seconds, then everything at once. Nothing is broken; you just opted out of the summary by default:

thinking: { type: "adaptive", display: "summarized" }

Display changes visibility only. Billing is identical either way.

Trap 3: don't strip thinking out of history

Append the whole response.content array back onto messages, not just the text. In a tool loop, the reasoning behind a tool call lives in that block — drop it and the next turn re-derives it, costing more tokens for worse continuity. On current models those blocks are also bound to the model and the conversation, so rewriting earlier turns silently invalidates them.

The knob that actually exists

A fixed budget_tokens is gone on current models (send it and you get a 400). Depth is output_config.effort: low | medium | high | xhigh | max. The default is medium on Opus 5.5 and high on most others — so "I didn't configure anything" is still a choice you made.

Your exercise

Take one real prompt from your app. Run it at effort: "low", "medium" and "high", logging usage.output_tokens each time, and compute cost per answer at $20/1M. Then ask the honest question: is the high-effort answer actually better for your task, or did you pay 4x for the same verdict? Chat and classification routes usually score the same at low.