Phase 0: LLM Fast Track · 55 min · OpenAI SDK · Anthropic SDK · Pydantic
Structured Outputs & Function Calling
An agent that can only generate text is a chatbot. An agent that can call functions is a product.
Hiring signal: Function calling is asked in nearly every AI engineer technical screen — the full loop, error handling, and parallel calls.
What you will learn
- Define tools using JSON Schema and call them reliably with OpenAI and Anthropic APIs
- Handle the full function-calling loop: detect call → execute → return result → continue
- Use Pydantic to generate tool schemas automatically from Python classes
The Problem
An agent can answer "What's the weather like in Paris?" with a plausible-sounding response. But it's making that up — it has no idea what the weather is right now. Function calling bridges language models and the real world. With it, the model can detect when it needs real data, ask your code to fetch it, incorporate the result, and give you a grounded answer.
Function calling is the bridge between "I'll look that up" and an actual database query. It's what makes agents useful rather than merely convincing.
The most important misconception to clear up
The model does NOT execute code. It emits a structured JSON object saying "call function X with arguments Y." Your code detects this, runs the function, and feeds the result back. The model is an orchestrator, not an executor.
What Function Calling Actually Is
Here's the sequence that happens every time a model uses a tool:
The model never touches get_weather. It just declares its intent. Your loop handles execution and feeds the result back so the model can incorporate it into its final response.
Unlock the full lesson
You've read the first 2 sections. The rest of this lesson covers Defining Tools with JSON Schema, The Function-Calling Loop, Build It, What to Practice — plus a hands-on lab, quiz, and project artifact.
Create a free account to unlock Phase 0 and Phase 1 of every course — no credit card.
Browse all courses · View pricing · DeVenture Academy