JSON mode or schema-constrained output forces valid JSON; function (tool) calling makes the model return a function name with structured arguments that match a schema.
Validate every response with a schema library (such as Pydantic), and retry with the validation error fed back to the model if parsing fails.
Keep schemas simple, include field descriptions and enums, and set low temperature.
Use constrained decoding when you need a guarantee of valid structure.
Loading…