Python + AI: Structured outputs

Microsoft Reactor β€’ October 15, 2025
Video Thumbnail
Microsoft Reactor Logo

Microsoft Reactor

@microsoftreactor

About

Welcome to Microsoft’s Reactor YouTube Community. Whether you’re building your career or the next great idea, Microsoft Reactor connects you with the devs and startups that share your goals. Learn new skills, meet new peers, and find career mentorship. Attend expert panels and dive into what inspires you with the latest tech. Virtual events are running around the clock so join us anytime, anywhere! We want this to be a safe, welcoming community, so these are our house rules. If you violate them, we will delete your comments and may report violations: 1. Avoid explicit and inflammatory language 2. No swearing or hate speech 3. Do not post repetitively or spam our comment section 4. Do not post personal information, such as email, physical address, personal phone number, credit card information, or your site password Please report posts that violate community guidelines using the spam button or YouTube’s Reporting and Enforcement Center. Be nice to each other and try to be helpful.

Video Description

In our fifth stream of the Python + AI series, we'll discover how to get LLMs to output structured responses that adhere to a schema. In Python, all we need to do is define a @dataclass or a Pydantic BaseModel, and we get validated output that meets our needs perfectly. We'll focus on the structured outputs mode available in OpenAI models, but you can use similar techniques with other model providers. Our examples will demonstrate the many ways you can use structured responses, like entity extraction, classification, and agentic workflows. If you'd like to follow along with the live examples, make sure you've got a GitHub account. πŸ“Œ This session is a part of a series. Learn more here: https://aka.ms/PythonAI/2 Explore the slides and episode resources: https://aka.ms/pythonai/resources Check out the demos: https://aka.ms/python-openai-demos Chapters: 00:08 – Welcome & Housekeeping 01:01 – Series Overview & Session Agenda 01:56 – What Are Structured Outputs? 04:05 – Calling LLMs with OpenAI API 06:00 – Defining Schemas with JSON Schema 07:56 – Using Pydantic for Schema Definition 10:00 – Validating Structured Outputs with Pydantic 13:35 – Enhancing Schema with Field Descriptions 19:04 – Using Enums for Controlled Output 22:48 – Nesting Models for Complex Structures 27:03 – Use Cases for Structured Outputs 28:50 – GitHub Issue Extraction Demo 33:46 – Webpage Scraping with BeautifulSoup 35:03 – Handling JavaScript Pages with Playwright 39:41 – Extracting Data from PDFs 45:19 – Processing Word Documents with Markdown 50:12 – Image-Based Table Extraction 55:04 – Evaluation & Accuracy Tips 59:39 – Balancing Flexibility vs. Structure 1:01:37 – Final Thoughts & Resources #MicrosoftReactor #learnconnectbuild [eventID:26296]

You May Also Like