How can I force structured outputs like JSON or CSV?
Give a strict schema, forbid extra text, and include one valid example. Ask the model to validate against the schema before returning. Parse on your side and auto-retry with a correction hint if parsing fails. Keep field names and types simple.
In practice
Schema comments (brief field notes) improve accuracy more than long narratives.
Where to start
- [01]Define your schema with required/optional fields.
- [02]Provide a minimal working example.
- [03]Add a parser + retry loop.
- [04]Track field-level error rates over time.
JSON output promptstructured output AILLM CSV