This example shows the basic tool-calling design pattern for agents.
While this leverages the OpenAI API, the lessons are the same whether you use different tool-calling APIs (E.G. Anthropic), or general structured outputs (E.G. with instructor).
Rather than explain the code here, we direct you to the blog post