Broken JSON wastes credits and time. Use strict formats and schema hints to keep responses parseable in production.
Constrain the shape
Show an explicit JSON schema and a single worked example. Ask for only the fields you need. Avoid nested prose.
Return JSON only
Say: “Return JSON only. No markdown, no prose.” Strip explanations to reduce token count and parsing risk.
Validate and retry
Validate against a schema server-side. On failure, retry with a shorter prompt and the validation error. Cap retries to avoid runaway costs.
Key takeaways
- Explicit schemas cut malformed output.
- Forbid prose; keep responses terse.
- Automate validation + limited retries.