← Back to API Guides

JSON Output

Constrain model output to valid JSON format for structured data extraction and API integrations.

Usage

Set response_format to {"type": "json_object"} to constrain the output to valid JSON. You should also instruct the model in the system/user prompt to output JSON.
{
  "model": "deepseek-v4-pro",
  "messages": [
    {"role": "system", "content": "Output in JSON format."},
    {"role": "user", "content": "List 3 programming languages with their creators."}
  ],
  "response_format": {"type": "json_object"}
}