Structured Output
Constraining model generation to produce valid, machine-parseable formats like JSON or XML.
Full Definition
Structured output goes beyond instructing a model to 'respond in JSON' — it uses constrained decoding, grammar-guided generation, or function-calling APIs to guarantee that the model's output conforms to a specified schema. OpenAI's JSON mode, Anthropic's tool-use feature, and libraries like Outlines or Guidance implement this at the token sampling level, making schema-invalid tokens impossible to generate. This is essential in production pipelines where model output is parsed programmatically — an unparseable response breaks the application. Structured output removes the need for fragile regex post-processing and makes model responses reliably consumable by downstream code.
Examples
Using OpenAI's function-calling API to guarantee a model returns a JSON object matching a Pydantic schema when extracting entities from text.
Using the Guidance library to constrain a model to output a valid SQL SELECT statement with no free-form text.
Apply this in your prompts
PromptITIN automatically uses techniques like Structured Output to build better prompts for you.