Function calling
On this pageDefinition
Why it matters
This is the step from a chatbot that talks to an assistant that acts. Without it, a model can describe how to check an order. With it, the model checks the order, using the real data rather than a guess, which also reduces made-up answers. It also moves part of the reliability problem onto the functions. The model chooses which one to call and what to pass in, so clear descriptions and checks on your side decide whether it behaves.
How to apply it
- Describe each function narrowly: what it does, what it needs and what it returns.
- Validate every input before running it. A value is not safe because a model produced it.
- Keep functions small and single-purpose. A function that does too much gives the model more ways to misuse it.
- Start with read-only functions, and add write access later.
- Log every call and its inputs, so a wrong action can be traced.
- Add human approval before anything hard to reverse, such as sending money or deleting a record.
What it is
A language model on its own only produces text. Function calling lets it ask for something to be done. The developer describes a set of functions, each with a name, a purpose and the inputs it needs. When the model decides one is useful, it replies with the function name and the values to pass in. The surrounding software runs the function and hands the result back, and the model carries on with that result in front of it.
The model never runs anything itself. Your code does, and your code decides whether to allow it. Different AI providers use different names for the same idea, mostly tool use or function calling.