Skip to content

Lesson 16 ยท The Claude API

Choosing Models: Tokens, Thinking and Effort

Pick a Claude model for the job, estimate token costs with December 2026 prices, and control reasoning depth with adaptive thinking and the effort setting.

Every API request involves a trade-off between quality, speed and cost. Three choices drive it: the model, how many tokens you send and receive, and how much effort the model spends.

Models and prices

These API model IDs and standard prices come from Anthropic's API reference as of December 2026, in US dollars per million tokens. All four have a 1-million-token context window, and the IDs have no date suffix.

Model API ID Input Output
Claude Fable 5.2 claude-fable-5-2 $8 $40
Claude Opus 5.5 claude-opus-5-5 $4 $20
Claude Sonnet 5.5 claude-sonnet-5-5 $2 $10
Claude Haiku 5.5 claude-haiku-5-5 $0.10 $0.50

The Haiku 5.5 price shown applies to prompts of up to 100,000 tokens; beyond that it is $0.50 input and $2.50 output. Check the official pricing page before you budget, because prices and models change, and cloud platforms may differ.

A way to choose:

  1. Write a test set of real tasks with a clear pass rule.
  2. Try a mid-size or small model first if the task is simple; start higher if it is hard.
  3. Compare pass rate, latency and cost per successful result.
  4. Keep the cheapest option that meets your quality bar.

Tokens and cost

You pay for input tokens (system prompt, history, documents, tool definitions) and output tokens (including thinking). A longer history costs more on every turn.

To measure before sending, use the token counting endpoint. The documentation describes it as free to use but rate limited, and its result as an estimate.

Python
count = client.messages.count_tokens(
    model="claude-opus-5-5",
    system="You are a helpful assistant.",
    messages=[{"role": "user", "content": document_text}],
)
print(count.input_tokens)

Count with the model you will use, because tokenizers differ between model generations. After a call, response.usage reports the actual numbers.

Python Estimate monthly cost from token counts

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The estimate leaves out caching, batch discounts, tool charges and taxes. It also assumes that every model uses the same number of tokens, which may not be true. Measure with your own data.

max_tokens

max_tokens is a hard ceiling on the output, and thinking counts toward it. It is not a target length. If it is too low, you get the stop reason max_tokens and a cut-off answer, perhaps with no visible text at all. To ask for a short reply, say so in the prompt and leave a safe ceiling.

Thinking

Current models can reason before answering. In general, either omit the thinking parameter or request adaptive thinking, in which the model decides how much to think:

Python
response = client.messages.create(
    model="claude-opus-5-5",
    max_tokens=8000,
    thinking={"type": "adaptive"},
    messages=[{"role": "user", "content": "Find the flaw in this schedule: ..."}],
)

On the 5.5 models, the old fixed budget_tokens setting is rejected. On Claude Opus 5.5, thinking cannot be disabled. Thinking behavior differs by model, so check the thinking documentation for the one you use. If you continue a conversation, send the assistant content back unchanged.

Effort

The effort setting controls how much work the model puts into a response. It goes inside output_config:

Python
response = client.messages.create(
    model="claude-opus-5-5",
    max_tokens=16000,
    output_config={"effort": "high"},
    messages=[{"role": "user", "content": "Review this design for failure cases: ..."}],
)
Level A sensible use
low Quick, simple or high-volume tasks
medium A balance; the default on Opus 5.5
high Harder reasoning and coding
xhigh, max The hardest work, when quality matters most

Do not assume that every model supports every level or uses the same default. Higher effort usually costs more and takes longer. It does not guarantee a correct answer. Test two or three levels on your own tasks.

Routing between models

Some applications send easy requests to a cheaper model and hard ones to a stronger model. Keep routing rules simple and measurable.

Python Compare cost per successful result

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The cheapest setup per success is not acceptable here, because it fails too often. Quality is a requirement first, and cost is compared among the options that meet it.

Ways to spend less

Before you switch models, look at what you send and receive:

  • Remove history, documents and tool definitions that the request does not need.
  • Ask for the output length you actually want.
  • Lower the effort level for easy tasks, and confirm on your test set that quality holds.
  • Cache a long, stable prefix and use batches for work that can wait; the next lesson covers both.

Change one thing at a time. If you change the model, prompt and effort together, you cannot tell which change moved the quality or the cost.

Pin what you tested

Write the model ID, effort level, prompt version and test results down together. When a new model appears, treat the switch as a change to your software: run the test set, compare quality, cost and speed, read some outputs yourself and keep a way to go back. Also check Anthropic's model deprecation page from time to time, so that a retirement date does not surprise you. A newer model may respond differently to an old prompt, for example by writing more or less.

Common mistake: choosing a model from a single impressive or disappointing example. One answer tells you very little. Use a set of tasks that resembles real traffic.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is max_tokens?

    It limits output; it is not a target.
  2. 2. Where does the effort setting go?

    Use output_config with an effort level.
  3. 3. Which thinking setting is rejected on the 5.5 models?

    Use adaptive thinking or leave the parameter out, and control depth with effort.
  4. 4. How should you compare models for production use?

    Measure against your own quality bar.

Summary

  • Model prices differ widely, so test before you choose.
  • Input and output tokens drive cost; count and monitor them.
  • Use adaptive thinking or omit it, and tune effort in output_config.
  • Compare cost among the options that meet your quality bar.

Next: Streaming, Errors, Caching and Batches

Your progress is saved in this browser. No account needed.