The chat completions API supports structured response formats, enabling you to receive consistent, predictable outputs in JSON format. This is useful for parsing responses programmatically.

Overview

There are two primary approaches for structured responses:
  1. JSON Mode: Basic JSON formatting without schema validation
  2. JSON Schema Mode: Structured responses with strict schema validation and Pydantic integration

JSON Mode

JSON Schema Mode