Why it matters
Free text is fine for a person but fragile for code. If a model sometimes writes "Total: 1,200" and sometimes "twelve hundred dollars", the next step breaks. With a schema, the model must return a field called total as a number, an enum for status, and so on.
Ways to get it
- Ask in the prompt and show an example; works most of the time.
- Use the provider's schema or JSON mode, where the platform constrains the output so it parses.
- Use function calling, where the model fills arguments for a described function.
Still validate
A correct format does not mean correct content. The model can return a perfectly valid date that is wrong. Check ranges, required fields and cross-field logic (end date after start date) in your own code, retry on failure, and send odd cases to a human. Keep schemas small and descriptions clear, since each field name and description acts as an instruction to the model.
Questions, answered
Slightly, because the schema counts as input tokens. It usually saves money overall by reducing retries and parsing code.
Allow null for optional fields and tell the model to leave them empty rather than guess.