Skip to content
AI Skills Central

Type to search Agent Skills, workflows, tutorials, tools and the glossary.

Structured outputs

Topic: Prompting and contextAlso called JSON mode

Definition

Constraining or validating model output so it matches a schema, usually JSON Schema, and can be parsed reliably by your code.

In more detail

Many APIs can guarantee that output matches a schema you supply. Even then, validate the result in your code and design the schema so the model has an honest way to say a value was not found.

There are two levels of support. JSON mode only promises valid JSON; schema-constrained output, where the provider restricts generation to match your JSON Schema, also guarantees the fields and types. Keep schemas simple, give fields clear names and descriptions, allow null or an explicit 'not found' value, and remember that a valid shape says nothing about whether the values are correct.

  • Constrained decoding

    Masking out disallowed tokens during generation so a language model can only emit text matching a schema or grammar.

  • Prompt engineering

    Designing, testing and refining prompts so a model produces the output you need reliably, across many inputs and not just one.

  • Tool calling

    A model emitting a structured request to call a defined function, which your code runs and whose result is then fed back to the model.

  • Stop sequence

    A string sent with a request that makes the model stop generating as soon as it produces that text.

  • Structured outputs

    Getting reliable JSON and other schema-shaped output from a model, and validating it.

    SkillBeginner

  • Get reliable JSON from an LLM with structured outputs

    Describe the output as a schema, let the provider enforce it, validate it with Pydantic AI or the AI SDK, and handle failures.

    TutorialBeginner30 min

  • Document AI

    Turning PDFs, scans and Office files into clean text and validated structured data.

    SkillIntermediate

  • Document parsing

    Converting PDFs, Office files, scans and web pages into clean text with structure, such as headings and tables, before indexing.

    Glossary