API reference

Structured outputs

Request a JSON object or a JSON schema on routes that support response_format.

Check supported_parameters and the selected route before using response_format. Support can differ between providers of the same model. On 2026-10-26 qwen/qwen3.8-flash and qwen/qwen3.8-max listed both response_format and structured_outputs; deepseek/deepseek-v4-pro listed neither.

JSON object

json
{"response_format":{"type":"json_object"}}

Tell the model what JSON to produce in your prompt. Parse and validate the result in your application; a text response, refusal or interrupted stream is not valid structured output.

JSON schema

json
{"response_format":{"type":"json_schema","json_schema":{"name":"answer","strict":true,"schema":{"type":"object","properties":{"answer":{"type":"string"}},"required":["answer"],"additionalProperties":false}}}}

Send this field beside a complete Chat request. Supported schema keywords and strict controls depend on the route; unsupported settings may return 400 unsupported_parameter. Responses uses text.format; Messages translates its supported JSON output configuration. Those protocols do not accept every Chat control unchanged.

Structured output constrains the answer's shape. Validate its values in your application, as you would any input.