What a JSON schema can check in an AI answer

Check response shape and factual correctness as two separate parts of the workflow.

Use the schema to make a readable contract

A schema can define which fields a structured result requires and the expected types or allowed values. For a museum-label review, it might require an object ID, a verdict drawn from a small set, and an array of issues. Supported structured output features can help a model conform to a supplied schema. Read the API-specific limits and behavior for cases such as refusal or interruption before relying on a completed result. 1 2 3

Verify that the structured fields are true

A date can satisfy a string rule while disagreeing with the source. A verdict can be in the allowed set while misclassifying a record. Choose a separate factual test for any value that affects a decision. In the museum example, compare one issue against the exact label passage and check that a mark of “verified” has a source. Keep those checks outside the shape validation so you can see why any test failed.

Make uncertainty expressible

If a source does not identify a maker, the output needs an allowed way to say so. A schema that demands a nonempty name can create pressure to fill it despite missing evidence. Allow an explicit null or uncertainty status where the workflow can continue safely. Test a missing-source case alongside a normal one, then check that the next system handles the uncertainty without treating it as a confirmed value.

Sources

  1. What is JSON Schema?
  2. OpenAI API structured model outputs guide
  3. Anthropic’s structured outputs documentation