Today we launched Structured Outputs in the API — model outputs now reliably adhere to developer-supplied JSON Schemas. This feature was one of our most highly requested for the API, as managing responses that don’t match your schemas has been a challenge ever since we released function calling.
You can use Structured Outputs in two ways:
- When you use function calling, supply strict: true within your function definition to ensure that the model’s output will match your exact schema.
- You can now supply a json_schema as a response_format option, along with a full definition of your schema. Set strict: true to ensure that model outputs will reliably match your schema.
Read more about enabling Structured Outputs in the guide.
Structured Outputs with function calling is supported on all models that support function calling, including our gpt-4o, gpt-4o-mini gpt-4-turbo, gpt-4, and gpt-3.5-turbo models.
Structured Outputs with the new response_format param is supported on gpt-4o-mini and our new model: gpt-4o-2024-08-06, released today.
By switching to the new gpt-4o-2024-08-06, developers save 50% on inputs ($2.50/1M input tokens) and 33% on outputs ($10.00/1M output tokens) compared to gpt-4o-2024-05-13.
We’re excited to see what you build with Structured Outputs, happy hacking!