BuildSpark AI

Map · Foundations · 07 · Structured Outputs

Concept card · Foundations

Structured Outputs

Structured outputs ask the model for a reply that follows a schema, such as named fields, so code can read it.

Asking for a reply that follows a shape, such as fields you name, so code can read it.

Last checked 2026-10-17 Free card 4 min

Ask about Structured Outputs

What changed

Oct 17: First card. The picture shows a reply that matches a schema and JSON that is missing a field. Sources are the OpenAI, Anthropic, and Gemini structured output guides.

1 What it is

A schema names the fields and the types you expect, for example a name and a status. Structured outputs tell the API to keep the reply inside that shape. A sentence can hold the same facts and still be hard for code to read.

A picture, not a live validator. The schema asks for two fields: name, a string, and status, one of open or done.

{
  "name": string,
  "status": "open" or "done"
}
{
  "name": "Ada",
  "status": "done"
}

Both fields the schema names are present. Code can read name and status.

2 Why it matters

Cost

The schema does not remove the tokens in the prompt. It can save a later turn whose only job was to fix the shape.

Quality

Code can read a field by name. Prose has to be parsed, and a small wording change can break that parse.

Risk

A schema constrains the shape, not the truth of the values. A field can be present and still be unsupported by the source.

3 How to apply · try today

Take one reply you parse by hand. Write down the fields you actually read, and request those fields with the provider's schema option.

Common mistake

Treating the words "return JSON" in a prompt, or a mode that only checks that the text is JSON, as the same thing as a schema the API enforces.

Self-check

Code needs a name and a status. What should you send?

Questions

What are structured outputs?
Structured outputs ask the model for a reply that follows a schema, such as named fields, so code can read it.
Is "return JSON" the same as a schema?
No. A JSON check can pass on text that is valid JSON and still missing the fields you need. A schema names those fields.
Does a schema make the values true?
No. A field can be present and still say something the source does not support.