Back to glossary

Term

Structured Output / JSON Mode

Structured output is a language model's ability to deliver responses in a defined schema (typically JSON), reliable enough to be consumed directly by downstream code.

Structured Output / JSON Mode — explained in more detail

Free-text answers are hard for programs to parse. Structured output solves this by either forcing the model into schema conformance (constrained decoding against a JSON schema) or by having the model respond with tool calls whose arguments must follow a defined type. The result: the model never wraps the JSON in “Here is an example: …” but emits valid, parseable JSON directly.

Example / Practical context

A lead-capture flow extracts fields like name, company, phone, request_type from a free-form email. Without structured output you have to harden your parsing with regex; with JSON-schema mode the API hands back a type-safe object. Providers such as OpenAI and Anthropic and local engines (vLLM, llama.cpp via grammars) support this natively — either via a JSON-schema parameter or via tool use with a defined input schema.

Function calling and tool use are closely related: the model calls a function with structured arguments — mechanically the same as JSON mode, with the extra step of routing the output into an actual function. Few-shot prompting with JSON examples reaches similar results but is not enforced — the model can break out of the format at any time.

Entdecke mehr

Themenuebersicht