Skip to main content
use_json_mode=True requests a generic JSON object from the provider. The output_schema still guides the prompt and parses the result, but the provider does not enforce that schema. Remove use_json_mode=True to use provider-native structured output.
json_schema_output.py

Run the Example

1

Set up your virtual environment

2

Install dependencies

3

Export your OpenAI API key

4

Run the example

Save the code above as json_schema_output.py, then run:
Full source: cookbook/03_teams/04_structured_input_output/json_schema_output.py