Module 06
Function Calling and Structured Outputs
A model on its own cannot see your orders, check the weather or file a refund. Function calling lets it ask your code to do those things, and structured outputs make its answers typed data your systems can trust. You will build the tool loop by hand, handle parallel and chained calls, wrap real external APIs safely, and compare the OpenAI and Claude SDKs side by side.
By the end of this module you can
- explain function calling precisely: the model requests a call, your code decides, runs it and returns the result.
- write a tool loop by hand and with the SDK tool runner, including parallel and chained calls.
- steer tool use with tool_choice and work around models that do not support forced calls.
- wrap an external API as a safe tool adapter with validation, timeouts, small results and no secrets.
- get typed outputs with Pydantic through structured outputs or strict tools, and check them against real data.
- move code between the OpenAI and Claude SDKs and add a provider fallback for temporary failures.
Lessons
5 in this module- 01What is function calling?Explain what function calling is and is not, define a tool, and write the full request, tool_use, tool_result loop by hand and with the SDK tool runner.
- 02Multiple, parallel and forced callsHandle parallel and chained tool calls efficiently, steer tool use with tool_choice, and work around models such as claude-opus-5-5 that reject forced calls.
- 03Calling external APIs from the model loopWrap real external APIs (weather, delivery tracking) as tool adapters that validate input, use timeouts, return small clean results, keep secrets out and resist prompt injection.
- 04Typed outputs with PydanticDesign Pydantic schemas models fill in well, get typed data with messages.parse or strict tools, and validate the values against real records with business rules in code.
- 05OpenAI SDK and Claude SDK for production appsMap clients, messages, streaming, tools, structured outputs, errors, retries and timeouts between the OpenAI and Claude SDKs, and add a provider fallback for temporary failures.