Build
Structured outputs
Request JSON Schema and validate twice
Structured output is a model capability plus an application validation contract.
1. Define a closed schema
Use required properties and additionalProperties=false. Keep the schema portable across every eligible fallback.
{"type":"json_schema","json_schema":{"name":"risk_summary","strict":true,"schema":{"type":"object","properties":{"risk":{"type":"string"}},"required":["risk"],"additionalProperties":false}}}2. Select an eligible route
Confirm structured-output support in model metadata. Fail explicitly if policy cannot preserve the schema.
3. Validate again
Parse and validate with the same application schema. Model conformance does not grant business authorization or make values factually correct.
4. Observe failures
Track validation failure and incomplete terminal state separately without storing sensitive response content in routine telemetry.
