News

OpenAI Launches Structured Outputs to Enhance API Reliability

OpenAI has announced the introduction of Structured Outputs in its API, a new feature designed to ensure model-generated outputs conform exactly to JSON Schemas provided by developers. This innovation is expected to significantly improve the reliability and usability of AI-generated structured data in various applications.

Last year, OpenAI introduced JSON mode to help developers produce valid JSON outputs more consistently. While JSON mode improved the generation of valid JSON, it did not guarantee adherence to a specific schema. Structured Outputs addresses this limitation by constraining the models to match developer-supplied schemas and training them to better understand complex schemas.

"Generating structured data from unstructured inputs is a core use case for AI today," OpenAI says. "Developers use our API to build powerful assistants that fetch data, answer questions, extract structured data, and build multi-step workflows. Structured Outputs simplifies these processes by ensuring outputs match the necessary formats."

In evaluations of complex JSON schema adherence, the new model, GPT-4o-2024-08-06, achieved a perfect score of 100%, compared to less than 40% for the previous GPT-4-0613 model. This improvement highlights the significant strides made in ensuring model outputs meet strict format requirements.

Structured Outputs are available in two forms: through function calling by setting strict: true within function definitions, and via a new response_format parameter option. This feature is compatible with all models that support tools, including GPT-4-0613 and GPT-3.5-turbo-0613 and later models.

Additionally, OpenAI has updated its Python and Node SDKs to support Structured Outputs natively, allowing for easy integration of schemas into applications. The new feature also includes safety measures to ensure that models refuse unsafe requests, providing a refusal string value in API responses for easy detection.

"Structured Outputs is available today in the API, compatible with all models supporting function calling and the latest GPT-4o models," OpenAI confirmed. The new functionality is also compatible with vision inputs and offers cost savings for developers using the GPT-4o-2024-08-06 model.

For more information, developers are encouraged to visit OpenAI's documentation to start leveraging Structured Outputs in their applications.

About the Author

John K. Waters is the editor in chief of a number of Converge360.com sites, with a focus on high-end development, AI and future tech. He's been writing about cutting-edge technologies and culture of Silicon Valley for more than two decades, and he's written more than a dozen books. He also co-scripted the documentary film Silicon Valley: A 100 Year Renaissance, which aired on PBS.  He can be reached at jwaters@converge360.com.

Featured

Upcoming Training Events

0 AM
Live! 360 Orlando
November 17-22, 2024
TechMentor @ Microsoft HQ
August 11-15, 2025