Structured Outputs is an OpenAI API feature that ensures responses and tool calls adhere to a defined JSON schema. This makes building with our models more reliable, bridging the gap between unpredictable model outputs and deterministic workflows.
This repository contains a collection of sample apps showcasing the use of Structured Outputs.
Each app demonstrates practical ways to leverage this feature to build applications with NextJS.
-
Set Up the OpenAI API:
- If you're new to the OpenAI API, sign up for an account.
- Follow the Quickstart to retrieve your API key.
-
Clone the Repository:
git clone https://github.com/openai/structured-outputs-samples.git
-
Try a sample App:
- Navigate to the sample app you want to try (
cd /<app_folder>
) - Refer to the README of the app to run it locally.
- Navigate to the sample app you want to try (
-
Make it your own
Explore the code, update it, and use it in your own projects or as a starting point!
There are three sample apps in this repository:
This app is a simple example of how to use Structured Outputs in model responses to display information in a structured format.
This app focuses on generating UI components on the fly with Structured Outputs.
This app is a more complex example that combines multi-turn conversations, tool calling and generative UI. You can use this as a starting point to build an assistant with reliable workflows.
-
To learn more about Structured Outputs, refer to the Structured Outputs documentation.
-
To learn about Function Calling, refer to the Function Calling documentation.
-
Try the Introduction to Structured Outputs cookbook to get hands-on and run code snippets in Python.
You are welcome to open issues or submit PRs to improve this app, however, please note that we may not review all suggestions.
This project is licensed under the MIT License. See the LICENSE file for details.