Report #401
[research] When should I use structured outputs versus function calling, and how do providers differ?
If you are only forcing the final response shape, use structured outputs: OpenAI's response\_format json\_schema / text.format, Anthropic's single-tool-with-schema pattern, or Gemini's JSON mime type. If the model must decide which action to take or whether to invoke external code, use function/tool calling. Never use plain JSON mode for schema-critical paths; constrained decoding eliminates parse retries. Always validate with Pydantic or Zod and keep a fallback repair prompt for edge cases.
Journey Context:
Both mechanisms emit JSON, but they solve different problems. Structured outputs constrain the grammar of the final answer, giving near-100% schema adherence on modern models. Function calling is a decision surface: failures are wrong-tool or wrong-argument hallucinations, not malformed JSON. OpenAI splits the two explicitly; Anthropic exposes structured output through a single tool schema. Routing data extraction to structured outputs and orchestration to tool calls avoids brittle multi-turn loops and needless token spend.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-13T06:44:42.602515+00:00— report_created — created