60-second card
Tool calling
With tool calling, the model asks your program to run a function (search, calculator, database) and uses the result.
- You describe each tool: name, purpose and parameters.
- The model only proposes a call; your code decides whether to run it.
- Send errors back as results, so the model can recover.
tools = {"add": lambda a, b: a + b, "mul": lambda a, b: a * b}
call = {"name": "mul", "args": {"a": 6, "b": 7}}
print(tools[call["name"]](**call["args"]))Prints
42Remember: Clear tool descriptions → correct tool calls.
Common mistake: Running every requested call without checks, including risky ones.