GrepBoard/Manuals
605 manuals ·

Claude API: tool_choice "tool" and "any" are not supported

·Tested on Claude API official docs · 2026-10·Test scope ↓·5 steps

Claude API 400 tool_choice "tool" and "any" are not supported: Opus 5.5 and others reject forced tool use. Use auto with strict tools or structured outputs.

text
tool_choice: type "tool" and "any" are not supported for this model.

You sent tool_choice: {"type": "any"} or {"type": "tool", "name": "..."} to a model that does not support forced tool use, and it returns 400 invalid_request_error. Change tool_choice to auto, then add strict tool use or structured outputs depending on whether you need schema-valid tool inputs or a fixed JSON answer.

[1] Check the model. Per the official errors page and the define-tools page, forced tool use is blocked in two cases.

Model or settingany / toolUse instead
Claude Opus 5.5, Sonnet 5.5, Fable 5.1, Mythos 5.1400 (this message)auto + strict tool use, or structured outputs
Request with manual extended thinking (thinking: {"type": "enabled"})errorauto or none

auto (the default) and none are accepted in both cases. The models in the table reject forced use regardless of thinking settings. By contrast, models with adaptive thinking on by default, such as Opus 5 and Haiku 5.5, accept forced tool use, but the docs say the response then starts with the tool call and skips thinking. Sending the same tool_choice to the token counting endpoint (/v1/messages/count_tokens) returns the same 400.

[2] If you forced the tool to get well-formed inputs, use auto plus strict. Add strict: true to the tool definition. The docs say this constrains sampling to schema-valid output, guaranteeing the inputs match your JSON Schema.

json
{  "model": "claude-opus-5-5",  "max_tokens": 1024,  "tool_choice": {"type": "auto"},  "tools": [{    "name": "get_weather",    "description": "Get the current weather in a given location",    "strict": true,    "input_schema": {      "type": "object",      "properties": {"location": {"type": "string"}},      "required": ["location"],      "additionalProperties": false    }  }],  "messages": [{"role": "user", "content": "What is the weather in San Francisco?"}]}

Put strict at the same level as name, description and input_schema. Strict guarantees the shape of the input, not that the tool gets called. The docs also note that prompting still influences which tool auto picks.

[3] Handle responses that skip the tool. With auto the model may answer in text, so check whether stop_reason is tool_use and branch if not. A system prompt line such as "always call get_weather for this question" leans the model toward the tool, but it is not the guarantee forcing gave you. If the flow must have a tool call, handle it in code: when the response has no tool call, append a user message asking it to answer by calling the tool and send once more.

[4] If what you really wanted was a fixed JSON answer, move to structured outputs. This covers code that defined a dummy tool and forced it just to extract or classify data. Drop the tool and put the schema in output_config.format; the answer arrives in the text block, matching the schema.

json
"output_config": {  "format": {    "type": "json_schema",    "schema": {      "type": "object",      "properties": {"name": {"type": "string"}, "email": {"type": "string"}},      "required": ["name", "email"],      "additionalProperties": false    }  }}

Change the reading code too: parse the text block as JSON instead of reading input from a tool_use block. Both features can be used in the same request.

[5] If you do not build the request yourself, find where tool_choice comes from. A framework's "structured output" or "force tool" option may be adding it. Turn that option off or upgrade to a version that supports the approaches above; if you cannot fix it now, the only fallback is to switch back temporarily to a model that accepts forced use (for example, Opus 5).

For other 400s caused by thinking settings, see Fix Claude API 400 "thinking.type.enabled is not supported". For a 400 when sending tool results back, see Fix Claude API 400 "tool_use without tool_result".

#claude#api#tool-use#troubleshooting