Skip to main content
This example shows how to use structured outputs with AI agents to generate well-formatted movie script concepts. It shows two approaches:
  1. JSON Mode: Traditional JSON response parsing
  2. Structured Output: Enhanced structured data handling
Example prompts to try:
  • “Tokyo” - Get a high-tech thriller set in futuristic Japan
  • “Ancient Rome” - Experience an epic historical drama
  • “Manhattan” - Explore a modern romantic comedy
  • “Amazon Rainforest” - Adventure in an exotic location
  • “Mars Colony” - Science fiction in a space settlement

Code

structured_output.py

Usage

1

Create a virtual environment

Open the Terminal and create a python virtual environment.
2

Install libraries

3

Run the agent