core practice · implementation task

Schema-constrained extraction

Define a JSON schema and use structured-output mode to extract typed fields from unstructured text. Validate the result and reject on failure.

The mechanism

Free text is unparseable glue between systems. Structured outputs constrain generation to a schema (via grammar/JSON mode) so the model's answer is a typed object your code can trust — or reject.

Study Structured Outputs

Expected evidence

A validated typed object, or an explicit rejection.

Try this drill in the practice workspace →

Hints when you need them
  • Use schema/JSON mode, not regex on prose.
  • Always validate before trusting downstream.

Watch for these mistakes

  • Parsing JSON out of prose with regex instead of schema mode
  • No validation step, so malformed output crashes downstream
  • Over-nesting schemas the model cannot reliably fill

Check the sources

Browse all practice briefs