1. Learn
  2. /
  3. Courses
  4. /
  5. Working with the OpenAI Responses API

Connected

Exercise

Consistent Outputs, Every Time!

You're developing a personalized movie recommendation system for a streaming platform. To ensure the recommendations can be properly displayed in the app's UI, you need to use structured outputs with pydantic and the OpenAI client. You'll define a schema for movie recommendations and extract the structured results.

Instructions

100 XP
  • Define a pydantic class called MovieRecommendation with title, genre, vibe, and why fields.
  • Generate a structured recommendation using the MovieRecommendation class and the prompts provided.
  • Extract the parsed recommendation from the response, then access its title and why information.