Lv.1 0 XP

tool_choice for Structured Output — auto vs any vs forced

⚡ Exam Tested 7 min +30 XP
💡
THE ANALOGY

Ordering at a restaurant. 'Whatever you recommend' (auto) might get you a meal or just a drink. 'I must order food' (any) guarantees you get a dish but the waiter picks. 'I want the salmon specifically' (forced) guarantees exactly that dish. For structured output pipelines, you almost always want forced.

⚠️ EXAM TRAP — The Wrong Answer People Choose

Using tool_choice: 'auto' in a document processing pipeline. Auto means Claude MAY respond with text instead of calling the extraction tool. For guaranteed structured output, use 'any' (unknown document type) or forced (known document type).

KEY POINTS
1 auto: Claude decides whether to call a tool or return text — NOT suitable for extraction pipelines.
2 any: Claude MUST call a tool, chooses which — use when document type determines the right schema.
3 forced: Claude MUST call THIS specific tool — use when you know the document type.
4 The exam scenario for 'any': multiple extraction schemas exist, document type is unknown, Claude reads and picks the right schema.
5 Forced extraction: pre-classify document type, then force the matching schema tool.