Function calling
In one sentence Function calling lets an LLM request that your code run a specific function with specific arguments, connecting language to real actions and live data.
Updated
Function calling lets a model respond not with prose but with a structured request — "run this function, with these arguments" — which your code then executes.
A hotel concierge does not personally cook your dinner or drive the taxi. His skill is dispatch: understanding "something light, vegetarian, before my 9pm train" and placing exactly the right call to the kitchen. Function calling makes the model a concierge. You describe your available services; it converts messy human requests into precise orders for them.
The developer declares the tools — name, purpose, parameters, as JSON schemas. When a user's request needs one, the model emits a structured call instead of an answer. Your code runs the real function and returns the result, and the model weaves it into a reply:
user : "Is the 6:30 Rajdhani to Delhi running late?"
model: call get_train_status(train="12951", date="today")
code : runs it → {"delay_minutes": 45}
model: "The 12951 Rajdhani is running about 45 minutes late today."The model never executes anything — it only asks. Your code is the boundary where validation, permissions and confirmation live, which is where the safety of the whole pattern is decided.
This is the mechanism that turns text prediction into software: live data, database queries, sending messages, controlling devices. Run it in a loop — call, observe result, decide next call — and you have an agent. Standardising how tools are described and discovered across applications is the job of MCP.
Where to go next
- Full lesson: Function calling
- Related terms: agent, structured-output, mcp, system-prompt