What is structured output?

Structured output makes a language model return JSON that your code can parse instead of free text. JSON mode returns a syntactically valid JSON object, and JSON schema goes further by making the response match a schema you define, with its required fields and types.

Concepts

Why structured output matters

Applications often need a model's answer as data: fields extracted from an invoice, a label for a support ticket, the steps of a plan, a record to save. Asking for JSON in the prompt works most of the time, but free text can arrive with an explanation before the JSON, a code fence around it, a missing field or a number written as a string. Each of those breaks a parser.

Structured output constrains the generation itself. The response is valid JSON, and with a schema it also has the exact shape you asked for.

JSON mode and JSON schema

There are two levels, both set with response_format:

  • JSON mode. {"type": "json_object"} makes the model return a valid JSON object. You describe the fields you want in the prompt, and the shape is not enforced.
  • JSON schema. {"type": "json_schema", "json_schema": {...}} takes a name, a schema and strict, and makes the output conform to that JSON Schema: required fields present, types correct, and no extra keys when you set additionalProperties to false.

Use JSON schema when the model supports it and your code depends on exact fields. Mark every field your code reads as required, use enum for fixed choices, keep nesting shallow, and add a short description to any field whose meaning is not obvious from its name.

For an invoice extractor, a schema might require vendor as a string, total as a number, currency as an enum of the codes you accept, and line_items as an array of objects with description and amount. With strict set to true, each response carries those fields with those types, so your code reads the same keys every time. With JSON mode, put a short example object in the prompt instead, so the model has a shape to follow.

Support by model and endpoint

Support is set per model. The structured_output field on GET /v1/models/{model} reads json_schema when the model supports schemas and json_object when it supports JSON mode only, and the models on this page show which level each one has. Sending a format the model does not support returns 400.

The same feature works on each text endpoint, in that endpoint's own shape:

  • /v1/chat/completions and /v1/completions: response_format.
  • /v1/responses: text.format.
  • /v1/messages: output_config.format, or a response_format next to the rest of the request.

In the Playground, chat models that support it have an Off, JSON mode and JSON schema control, with a box for your schema. The compatibility guide has complete request examples.

Practical guidance

  • Validate anyway. Parse and check every response in code. A response cut off by the output limit, reported as finish_reason length, is incomplete JSON, so set max_tokens high enough for the largest object you expect.
  • Check reasoning models. On some models, a request with response_format answers without reasoning unless it also sets enable_thinking.
  • Models without support. Ask for JSON in the prompt, include an example of the shape, and validate the result.
  • Choose the right feature. Use structured output when the JSON is the final answer. Use function calling when the model should choose an action for your code to run.

Browse text models to compare which support each level.

Structured output support by model

62 models. Each model's page has its rate card, parameters and code.

ModelStructured outputContext window
DeepSeek V4 Pro DeepSeekJSON Schema1M tokens
DeepSeek V4 Pro 0813 DeepSeekJSON Schema1M tokens
Fugu Max Sakana AIJSON Schema1M tokens
Fugu Ultra v1.1 Sakana AIJSON Schema1M tokens
Fugu Ultra v2.0 Sakana AIJSON Schema1M tokens
Gemma 4 26B-A4B GoogleJSON Schema256K tokens
Kimi K2.6 Moonshot AIJSON Schema256K tokens
Kimi K2.7 Code Moonshot AIJSON Schema256K tokens
Show all 62 models
ModelStructured outputContext window
Kimi K2.7 Code Highspeed Moonshot AIJSON Schema256K tokens
Kimi K3 Moonshot AIJSON Schema1M tokens
Kimi K3.1 Pro Moonshot AIJSON Schema1M tokens
MiMo V2.6 Flash XiaomiJSON Schema1M tokens
MiMo V2.6 Pro XiaomiJSON Schema1M tokens
MiMo V2.6 Pro UltraSpeed XiaomiJSON Schema1M tokens
Mistral Small 3.1 Mistral AIJSON Schema89.6K tokens
Muse Glimmer 30B Meta AIJSON Schema128K tokens
Muse Spark 1.1 Meta AIJSON Schema1M tokens
Muse Spark 1.2 Meta AIJSON Schema1M tokens
Muse Spark 1.3 Meta AIJSON Schema1M tokens
Qwen3.5 4B Alibaba CloudJSON Schema256K tokens
Qwen3.5 9B Alibaba CloudJSON Schema256K tokens
Qwen3.5 Omni Plus Alibaba CloudJSON Schema192K tokens
Qwen3.6 35B A3B Alibaba CloudJSON Schema128K tokens
Qwen3.7 Flash Alibaba CloudJSON Schema983.6K tokens
Qwen3.7 Max Alibaba CloudJSON Schema983.6K tokens
Qwen3.7 Plus Alibaba CloudJSON Schema983.6K tokens
Qwen3.8 27B Alibaba CloudJSON Schema256K tokens
Qwen3.8 Flash Alibaba CloudJSON Schema983.6K tokens
Qwen3.8 Max Alibaba CloudJSON Schema983.6K tokens
Qwen3.8 Max 0902 Alibaba CloudJSON Schema983.6K tokens
Qwen3.8 Omni Flash Alibaba CloudJSON Schema1.01M tokens
Qwen4 Max Alibaba CloudJSON Schema983.6K tokens
Seed 2.0 Lite ByteDanceJSON Schema229.1K tokens
Seed 2.0 Mini ByteDanceJSON Schema229.2K tokens
Seed 2.0 Pro ByteDanceJSON Schema229.1K tokens
Seed 2.1 Turbo ByteDanceJSON Schema229.1K tokens
Step 5 Preview StepFunJSON Schema1.02M tokens
DeepSeek V4 Flash 0731 DeepSeekJSON Mode1M tokens
DeepSeek V4.1 Flash 1017 DeepSeekJSON Mode1M tokens
Fugu Ultra v1.0 Sakana AIJSON Mode1M tokens
GLM 4.5 Flash Z.aiJSON Mode128K tokens
GLM 4.6V Flash Z.aiJSON Mode128K tokens
GLM 4.6V FlashX Z.aiJSON Mode128K tokens
GLM 4.7 Flash Z.aiJSON Mode202.8K tokens
GLM 4.7 FlashX Z.aiJSON Mode202.8K tokens
GLM 5.1 Z.aiJSON Mode202.7K tokens
GLM 5.2 Z.aiJSON Mode1M tokens
GLM 5.3 Z.aiJSON Mode1M tokens
GLM 5.3 Flash Z.aiJSON Mode1M tokens
Mistral Small 4 Mistral AIJSON Mode256K tokens
Qwen3.5 122B-A10B Alibaba CloudJSON Mode258K tokens
Qwen3.5 27B Alibaba CloudJSON Mode258K tokens
Qwen3.5 35B-A3B Alibaba CloudJSON Mode258K tokens
Qwen3.5 397B-A17B Alibaba CloudJSON Mode258K tokens
Qwen3.5 Flash Alibaba CloudJSON Mode995.9K tokens
Qwen3.5 Plus Alibaba CloudJSON Mode983.6K tokens
Qwen3.6 27B Alibaba CloudJSON Mode224K tokens
Qwen3.6 Flash Alibaba CloudJSON Mode983.6K tokens
Qwen3.6 Plus Alibaba CloudJSON Mode983.6K tokens
Step 3.7 Flash StepFunJSON Mode256K tokens
StepAudio 2.5 Chat StepFunJSON Mode256K tokens
StepAudio 3 Chat StepFunJSON Mode256K tokens

Frequently asked questions

What is the difference between JSON mode and JSON schema?

JSON mode returns a valid JSON object but leaves its shape to your prompt. JSON schema makes the response match a schema you supply, including required fields and types.

Which models support structured output?

Support is per model. Each model's structured_output field reads json_schema for schema support or json_object for JSON mode only, and a request for an unsupported format returns a 400 error.

Do I still need to validate the JSON?

Yes. A response can be cut off by the output limit, and your application may have rules that a schema cannot express, so parse and validate every response.

Can I use structured output with the Responses or Messages endpoints?

Yes. The Responses endpoint uses text.format, and the Messages endpoint accepts output_config.format or a response_format field.

Ready to use better endpoints?

Check out our pricing or reach out if you want your own model deployed on our stack.