Give the Model a Tool

defining a tool schema

Part of: Tool-Using Agent

A plain chatbot can only talk. Ask it "what's 847 times 293?" and it does the arithmetic in its head, sometimes wrong. Ask it "what's the weather in Tokyo right now?" and it has no way to know, because it was trained on old text, not a live feed. Tool use (also called function calling) fixes both problems. You hand the model a menu of functions it is allowed to ask for. When it needs one, it tells you which one and with what arguments, and you run the real function. The model never runs code itself. What we're building By lesson 8 you'll have an agent with three tools: a calculator for real arithmetic, a weather lookup, and a search tool for facts. The model picks the right tool for each question, you run it in Python, and the model folds the real result into its final answer. A tool is a JSON schema, not code You never send the model your Python function. You send a description of it: a name, a plain-English description of what it does, and an input schema describing the arguments as JSON Schema. You pass a list of these in the tools parameter of the API call: The model reads the schema like a menu. name is how it refers to the tool. description is the only thing that tells it whe

Challenge: Tool Schema Checker