tool_choice

Tools

Definition

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.