
What is Function Calling?
Function calling (also called tool use) is a capability that allows language models to request the execution of external functions or tools. Instead of generating a text answer, the model outputs a structured function call with specific parameters, which the application executes and returns results for the model to incorporate into its response.
Why It Matters
Function calling transforms LLMs from text generators into action-takers. It enables models to search the web, query databases, send emails, control smart devices, and interact with any API β grounding their responses in real data and enabling real-world actions. This is the fundamental building block of AI agents and the bridge between language understanding and practical capability.
How It Works
- Tool registration β the developer describes available functions (name, description, parameters with types) when making an API call
- Model reasoning β the model decides whether to answer directly or call a function based on the user's request
- Function call output β the model returns a structured call (function name + arguments as JSON)
- Execution β the application executes the function and returns the result to the model
- Response synthesis β the model incorporates the function result into a natural language response
- Multi-turn β the model can chain multiple function calls to accomplish complex tasks