◉CLAUDE LABJP
●SONNET 4.5 — Sonnet 4.5 was retired from the Claude API on 11/30. Calls now return an error. Move to Sonnet 5.5●PROJECTS — The Enterprise Analytics API now reports daily usage for the new projects experience (beta)●OPUS 4.5 — claude-opus-4-5 retires on 2027/1/22, 52 days from now. The replacement is claude-opus-5-5●LANGUAGE — Some users say Claude switches to another language mid-session while they write in English●NEW — New: Weekly usage looks like it jumped right after a plan upgrade? Check this first●COWORK — Handing Cowork a folder for the first time? Start with a task that only reads files●SONNET 4.5 — Sonnet 4.5 was retired from the Claude API on 11/30. Calls now return an error. Move to Sonnet 5.5●PROJECTS — The Enterprise Analytics API now reports daily usage for the new projects experience (beta)●OPUS 4.5 — claude-opus-4-5 retires on 2027/1/22, 52 days from now. The replacement is claude-opus-5-5●LANGUAGE — Some users say Claude switches to another language mid-session while they write in English●NEW — New: Weekly usage looks like it jumped right after a plan upgrade? Check this first●COWORK — Handing Cowork a folder for the first time? Start with a task that only reads files
Articles/API & SDK
⬡ API & SDK/2026-04-23Intermediate

Using tool_choice to Cut Wasted Inference: Four Modes and Cost Patterns for Production

tool_choice is one of the most underused parameters in the Claude API. The four modes — auto, any, tool, and none — each change both behavior and token cost. Here are the patterns I reach for in production, with runnable code.

tool-use25cost-optimization31api39production111

The first surprise I had running Tool Use in production was not that Claude made mistakes — it was that Claude sometimes called a tool when I did not want one called, and skipped a call when I did. Responses looked clever; the bill was about 1.5 times what I had planned. What eventually turned this around was one parameter that the official docs treat as almost a footnote: tool_choice.

In practice, understanding tool_choice is the difference between a pipeline that quietly wastes output tokens and one that does not. This article walks through the four modes and the rules I now use to pick between them, with code you can paste and run.

Four modes, one parameter

tool_choice sits next to tools on a Messages API request. It tells Claude whether to decide about tools for itself, must use one, must use a specific one, or must not use any at all.

from anthropic import Anthropic
 
client = Anthropic()
 
response = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=1024,
    tools=[
        {
            "name": "get_weather",
            "description": "Return the current weather for a city",
            "input_schema": {
                "type": "object",
                "properties": {"city": {"type": "string"}},
                "required": ["city"],
            },
        }
    ],
    tool_choice={"type": "auto"},  # <-- flip this
    messages=[{"role": "user", "content": "What is the weather in Tokyo?"}],
)

The four modes behave like this:

  • auto (default) — Claude decides whether to call a tool. Best fit for open-ended chat.
  • any — Claude must call one of the declared tools, but chooses which.
  • tool — Claude must call the named tool ({"type": "tool", "name": "get_weather"}).
  • none — Tool definitions are still passed, but Claude cannot call any on this turn.

One detail that is easy to miss: with any and tool, the API starts the assistant turn directly at the tool_use block. The short natural-language preamble ("I'll look up the weather for you...") never appears. That saves output tokens and latency — but it comes with a trade-off, covered under the traps below.

When I reach for each mode

Running enough production traffic, you start to see "auto is fine, but something else would be cheaper and faster." Here is the checklist I apply.

auto — free-form conversation

If your assistant handles small talk alongside tool-capable requests, auto is the only mode that lets it stay conversational. It avoids the anti-pattern of the bot dutifully firing a tool for "thanks!".

any — classifiers and structured output

Whenever the turn must produce a structured result — a category, a scored object, a routing decision — any is almost always the right pick. Each tool becomes a candidate output shape. Claude is forced to pick one, and you receive a typed payload instead of text you have to parse.

# Route an inbound ticket into one of three categories
response = client.messages.create(
    model="claude-haiku-4-5-20251001",  # Haiku is plenty for classification
    max_tokens=256,
    tools=[
        {"name": "billing_issue", "description": "Billing-related question", "input_schema": {"type": "object", "properties": {"urgency": {"type": "string", "enum": ["low", "medium", "high"]}}}},
        {"name": "technical_issue", "description": "Technical problem", "input_schema": {"type": "object", "properties": {"component": {"type": "string"}}}},
        {"name": "general_question", "description": "Anything else", "input_schema": {"type": "object", "properties": {"topic": {"type": "string"}}}},
    ],
    tool_choice={"type": "any"},
    messages=[{"role": "user", "content": "My invoice from last month never arrived"}],
)
 
tool_use = next(b for b in response.content if b.type == "tool_use")
print(tool_use.name)   # -> 'billing_issue'
print(tool_use.input)  # -> {'urgency': 'medium'}

You get a typed, schema-validated payload for free — no prompt gymnastics for JSON mode, no regex fallback for misshapen output.

tool — "the turn ends with exactly this"

tool mode is blunt, so I avoid it as a default. It earns its keep in two specific places:

  • The tail of a conversation, where save_conversation absolutely has to be called.
  • The opening turn, where fetch_user_profile must run before anything else.

The trick is to switch it on for one turn and switch back to auto next. Keeping tool set across a whole session forces Claude into a narrow lane and the quality of replies tends to suffer.

none — debugging and graceful degradation

The mode that quietly earned my trust is none. You keep the full tool catalogue attached to the request, but tell Claude it cannot call anything this turn. Real uses I have seen:

  • A summarization turn at the end of a session, where you do not want another tool call creeping in.
  • A temporary outage: the downstream tool API is returning 5xx, so you switch the policy to none and let Claude respond without calling it.
  • A "what can you do?" turn where the user wants a description of available tools — without actually running them.

That last one is surprisingly effective. Ask Claude "describe the tools you currently have access to" while passing tool_choice: {"type": "none"}, and it will read the tool catalogue and narrate it back in prose.

What this does to the bill — measure it on your own logs

I cannot give you one reduction figure and stand behind it. The savings depend on how many tools you declare, how long their descriptions are, the prompt, and the model — all of which change how much preamble auto produces. On a small classification toolset I saw a large drop in output tokens, but please do not copy that ratio onto your workload.

What I can say is directional:

  • Under auto, Claude may add a short explanation before a tool call, and you pay for those output tokens.
  • any and tool begin at tool_use, so that preamble disappears.
  • none forbids calls, so the output is prose only. Tool definitions are still sent, and still billed as input.

The tool-use pricing docs also list the extra system-prompt tokens added automatically, broken out by tool_choice. The difference is small per request but compounds at volume; check the current table, since the numbers get revised.

To compare on your own traffic, send the same ~100 prompts with only tool_choice changed and aggregate usage:

from collections import defaultdict
 
def measure(prompts, tool_choice):
    total = defaultdict(int)
    for text in prompts:
        r = client.messages.create(
            model=MODEL,  # the model ID you actually run
            max_tokens=512,
            tools=TOOLS,
            tool_choice=tool_choice,
            messages=[{"role": "user", "content": text}],
        )
        total["input"] += r.usage.input_tokens
        total["output"] += r.usage.output_tokens
    n = len(prompts)
    return {k: v / n for k, v in total.items()}
 
for choice in ({"type": "auto"}, {"type": "any"}):
    print(choice["type"], measure(SAMPLE_PROMPTS, choice))

If auto clearly emits more output than any, the turns where a tool call is certain are worth switching. If the gap is small, leave it alone. For the broader design, see Claude API cost optimization — production patterns; revisiting tool_choice is an easy place to start.

A dynamic wrapper

In practice, it helps to wrap mode selection in a single function that reads the turn's purpose. Here is a minimal TypeScript sketch:

import Anthropic from "@anthropic-ai/sdk";
 
const client = new Anthropic();
 
type TurnKind = "greeting" | "classify" | "respond" | "summarize";
 
function pickToolChoice(kind: TurnKind) {
  switch (kind) {
    case "greeting":
      return { type: "none" as const };        // never call a tool on hello
    case "classify":
      return { type: "any" as const };         // must produce a typed class
    case "respond":
      return { type: "auto" as const };        // free-form chat
    case "summarize":
      return { type: "tool" as const, name: "save_summary" }; // end-of-session save
  }
}
 
async function runTurn(kind: TurnKind, userMessage: string) {
  return client.messages.create({
    model: "claude-sonnet-4-6",
    max_tokens: 1024,
    tools: /* the stable set shared across all turns */ [],
    tool_choice: pickToolChoice(kind),
    messages: [{ role: "user", content: userMessage }],
  });
}

One subtle but important rule: keep the tools array identical across turns. If you add or remove tool definitions between requests, the cache from tools onward is invalidated. Changing only tool_choice is gentler: it affects the cached message blocks, while the tools and system-prompt caches survive.

I got this wrong at first. On a session with a long history, switching modes every turn means rebuilding the message cache each time, and the cache-write surcharge can outweigh the output tokens you saved. Switch only on turns where the benefit is clear. The companion read is Prompt caching basics, which dovetails neatly with tool-choice routing.

Traps worth knowing about

any with a single tool behaves like tool

If your tools array has exactly one entry and you pass any, Claude will almost always call it — but the guarantee is weaker than tool. Behavior drifts slightly between model snapshots. When you need certainty, use tool explicitly.

tool does not make long arguments free

No preamble is emitted, but the input JSON still costs output tokens. A tool that takes a whole summary as its argument will be expensive regardless of mode, so design arguments around IDs and labels where you can. Setting max_tokens near 200 for pure tool-call turns bounds runaway output — just not so low that a legitimate argument is cut off mid-JSON.

Keep tool_result history under none

With none, you can safely leave prior tool_use / tool_result exchanges in the messages array. In fact you should — Claude uses them to ground its response. Attempting to strip them out corrupts the context. If tool-result bookkeeping is tripping you up, Tool Use error handling patterns is a good companion.

any and tool cannot be combined with extended thinking

When extended thinking is on, only auto and none are accepted; any or tool returns an error. Wanting deep reasoning and wanting a forced call are different turns. I use auto with thinking where reasoning matters, and a thinking-free tool where the call must happen.

Leave any on inside an agent loop and it never ends

After a tool runs, you send the tool_result back and ask again. If tool_choice is still any or tool, Claude must call a tool every time and never gets to write the final answer. The loop runs until your turn limit, and you pay for every lap.

I found this out reading a batch log in the morning — the same tool call repeated down the screen, and my stomach dropped. Force only the first move, and go back to auto the moment results come back. That is the line I hold now.

Pair with disable_parallel_tool_use for transactional turns

For workflows where exactly one tool call per turn is the only acceptable outcome (payment processing, state transitions), pass:

tool_choice = {"type": "auto", "disable_parallel_tool_use": True}

This blocks Claude from emitting multiple tool_use blocks in a single response and removes a class of race conditions from your execution layer.

What to try next

Open your logs, pick ten live Tool Use requests, and check how many are still on auto. For each one, ask: "is the decision here genuinely open, or do I actually know the answer?" Every request where the answer is "I know" is a candidate for any, tool, or none. Flip those and watch one day of traffic — the line item will usually move.

If that goes well, pull the mode-picker into a single function so every turn announces its purpose. That small piece of structure is the foundation for every other Tool Use optimization you will reach for later. For a broader survey of Tool Use patterns that pair well with this approach, the advanced Tool Use guide keeps a map of where each technique shines.

Share

Thank You for Reading

Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $10 for lifetime access
View Membership →

If you found this article helpful, a small tip ($1.50) would mean a lot to us. Your support helps keep this site ad-free and covers server and hosting costs.

Related Articles

⬡ API & SDK2026-05-26
Stabilizing Claude API Structured Responses in Production — Notes on tool_use, JSON Schema, and Layered Validation
Getting Claude to return JSON takes a few lines. Keeping that JSON usable in production is a different problem. Here is the layered design I landed on after running a wallpaper classification pipeline through Claude API, built around tool_use, JSON Schema, and domain validation.
⬡ API & SDK2026-05-22
Why tool_result could not be submitted Keeps Coming Back, and How to Build a Recovery Handler That Actually Holds
Run a Claude agent long enough and one day it starts: 'tool_result could not be submitted', back to back, and retries change nothing. The error message hides four completely different root causes. Here is what I learned debugging it on the always-on agent jobs I run as an indie developer, with the TypeScript recovery handler I now ship in production.
⬡ API & SDK2026-05-05
The Real Cost of Claude API Extended Thinking in Production — ROI Data by Task Type
Three months of measured cost, quality, and speed data for Extended Thinking across five task categories. Learn exactly when extended thinking is worth it—and when it's not.