tool_choice
ToolsDefinition
API parameter controlling how Claude selects tools. 'auto' (default): Claude decides whether to use tools. 'any': Claude must use at least one tool. 'none': Claude cannot use tools. '{type: tool, name: X}': Claude must use the specific named tool. Used to force structured output via a schema tool.
Example Usage
Set tool_choice: {type: 'tool', name: 'extract_data'} to force Claude to use your extraction schema and guarantee structured JSON output.
Related Concepts
Structured Output via Tool Use & JSON Schemas
Prompt EngineeringTool use with JSON schemas eliminates syntax errors but not semantic errors
tool_choice Options & Forced Tool Selection
Prompt Engineeringtool_choice: 'auto' may return text; 'any' guarantees a tool call; forced selection guarantees a specific tool