Production systems need reliable output formats, not free-form text.
JSON Mode: Force model to output valid JSON. Specify schema in prompt.
Function Calling: Define function signatures. Model outputs structured calls. You execute and return results.
Why structured output matters:
- Parsing is reliable (no regex hacks)
- Downstream systems can process output
- Fewer format errors
Interview question: "How do you ensure LLM output is valid JSON?"
Use JSON mode if available. Include schema in prompt. Few-shot examples of correct format. Validate and retry on failure.