Module 5 of 11

Structured Outputs & Tool Use

Lessons

About This Module

Free-form text is easy for people to read and hard for code to use. To build a real product, your application needs answers in a shape it can rely on, and it often needs the model to do something instead of just talking. This module covers both: structured outputs and tool use.

It starts with getting reliable JSON from a model by describing the shape you want with a schema, then validating the result with a library such as Pydantic. It then moves to function calling, where the model decides when to call a function you wrote and with which arguments, and your code runs it and returns the result.

Watch the lessons in order, then continue on to Retrieval & RAG.

Lessons

4 videos
01

Pydantic Is All You Need (Jason Liu)

A talk on turning model output into typed objects: Pydantic models as the contract, OpenAI function calling, the Instructor library, and validation with retries.

02

Get LLM Output as a Python Object with LangChain and Pydantic

Defining a JSON schema with Pydantic and using an output parser so the model returns data that matches it.

03

How to Connect an LLM to Python Functions (Tool Calling Tutorial)

A practical walkthrough of tool calling in Python: describing a function to the model and letting it decide when to use it.

04

OpenAI Agents SDK Tutorial: Function Tool Calls Made Easy in Python

Building AI agents that call Python functions dynamically using the function tool decorator.