Chapter 2.4 — Structured outputs and function calling¶
🎯 Objective¶
Show that structured output is an integration layer — not a correctness guarantee.
🧠 Concept¶
- Structured outputs — the model follows a schema (JSON, Pydantic). Reduces fragile parsing.
- Function calling — the model proposes a structured call to a function. The application validates, authorizes and executes it.
🛡️ What structured output guarantees¶
- The shape of the response.
- Basic types.
- Required fields.
⚠️ What it does NOT guarantee¶
- That the content is correct.
- That the proposed action is safe.
- That the business rule is being respected.
🏗️ Recommended pattern¶
LLM proposes -> schema validates -> policy authorizes -> executor acts -> log audits
📚 References¶
- OpenAI — Function calling: https://developers.openai.com/api/docs/guides/function-calling
- OpenAI — Structured outputs: https://developers.openai.com/api/docs/guides/structured-outputs