Learn · Prompt engineering & structured output · CCAR-F task 4.3

Structured output with schemas and tools

Get guaranteed JSON with structured outputs or a tool schema, design it with nullable fields and 'other' enums, and remember: shape is not truth.

Key ideas

Worked example: One tool per document type

When you don't know whether a document is an invoice, receipt or contract, define one extraction tool for each and set tool_choice to any: Claude must call one of them, and which one it picks tells you the type.

Exam traps

Official docs

Practise CCAR-F questions · Next lesson: Validation, retry and feedback loops