response_format parameter: a permissive JSON mode that guarantees valid JSON, and a strict schema mode that validates against a JSON Schema you supply.
JSON Mode
Setresponse_format to {"type": "json_object"} to instruct the model to always respond with a valid JSON object. You are responsible for describing the expected shape in your system or user prompt — JSON mode only guarantees syntactic validity, not a particular structure.
Python
JSON Schema Mode
Setresponse_format to {"type": "json_schema", "json_schema": {...}} to enforce a precise structure. The json_schema object requires a name, an optional strict flag, and a schema that follows the JSON Schema specification. When strict: true, the model is constrained to produce output that exactly matches the schema with no extra properties.
Python
"additionalProperties": False alongside "strict": True gives the strongest guarantee: the output will contain exactly the fields you declared and nothing else.
Choosing Between the Two Modes
- JSON mode
- JSON Schema mode
Best for: exploratory extraction, prompts where the schema may vary, or models that do not support strict JSON schema.
- Guarantees syntactically valid JSON
- Schema is described in natural language in the prompt
- Supported by a wider range of models
Not all models support strict JSON schema mode. Retrieve model metadata from
GET /v1/models/<MODEL_ID> and check the supported_parameters array for "response_format" before using json_schema in production. Models that do not support it will fall back to best-effort JSON or return an error, depending on the model.