Skip to main content
Use the response_format parameter to make a model return JSON, either free-form JSON (json_object) or JSON that conforms to a schema you provide (json_schema). This works on the standard /v1/chat/completions endpoint.
Support for strict json_schema mode varies by model. JSON mode (json_object) is broadly supported. Discover models with GET /v1/models and test your schema against the model you intend to use.

JSON mode

Ask for any valid JSON object with {"type": "json_object"}:
Always instruct the model (in the system or user message) to produce JSON when using json_object mode. The mode guarantees valid JSON syntax, but it does not constrain the shape; you still have to tell the model what fields you want.

JSON schema mode

For a guaranteed structure, pass {"type": "json_schema", "json_schema": {...}} with a JSON Schema. The model’s output is constrained to match it.
The response content is a JSON string matching the schema:

Parsing the result

The content is always a JSON string; parse it in your language of choice:
Structured output pairs well with tool calling for building reliable agents: use schemas for data extraction and tools for actions. Setting additionalProperties: false and listing every field in required gives you the tightest, most predictable output.