August 5, 2024
OpenAI Structured Outputs
OpenAI have introduced Structured Outputs functionality to their API.
This feature allows the model to more reliably adhere to user defined JSON schemas for use cases like information extraction, data validation, and more.
We’ve extended our /chat
(in v4) and prompt/call
(in v5) endpoints to support this feature. There are two ways to trigger Structured Outputs in the API:
- Tool Calling: When defining a tool as part of your Prompt definition, you can now include a
strict=true
flag. The model will then output JSON data that adheres to the toolparameters
schema definition.
- Response Format: We have expanded the
response_format
with optionjson_schema
and a request parameter to also include an optionaljson_schema
field where you can pass in the schema you wish the model to adhere to.
This new response formant functionality is only supported by the latest OpenAPI model snapshots gpt-4o-2024-08-06
and gpt-4o-mini-2024-07-18
.
We will also be exposing this functionality in our Editor UI soon too!