Skip to main content
Set output_schema to return a validated Pydantic object instead of free-form text.

Code

structured_output.py

Usage

1

Set up your virtual environment

2

Set your environment variables

3

Authenticate your CLI session

You don’t need to authenticate your CLI every time.
4

Install dependencies

5

Run Agent

Save the code above as structured_output.py, then run: