In one line: Function Calling lets an LLM emit something other than prose — it can output a structured JSON tool call, your program actually executes it (weather, API, DB query), and the result feeds back to the model.
What it is#
You declare the available tools up front:
{
"name": "get_weather",
"description": "Look up current weather for a given city",
"parameters": {
"type": "object",
"properties": {
"city": { "type": "string", "description": "City name in Latin or local script" }
},
"required": ["city"]
}
}When the model decides to call one, instead of speaking it emits:
{
"tool_calls": [
{ "name": "get_weather", "arguments": { "city": "Beijing" } }
]
}Your program sees that JSON, actually calls get_weather("Beijing"), sends "26°C, cloudy" back to the model, and the model phrases the answer for the user.
Analogy#
Without Function Calling the model is a customer who can only talk: "could you check the weather for me?"
With Function Calling it becomes a customer who can place orders: "execute get_weather(city="Beijing")" — your program fulfils the order.
Key concepts#
How it works#
The model makes decisions, the runtime executes — this is the foundation of agents.
Practical notes#
- Describe the tool's purpose. "Get weather" is much weaker than "Look up today's weather by city to answer 'should I go out?' style questions" — model tool-selection accuracy hinges almost entirely on this.
- Lock down the parameter schema. Use
enumfor choices,requiredfor mandatory fields,patternfor formats — the model almost never fills nonsense. - Return structured errors. Don't throw — return
{ "error": "city not found" }so the model can adjust args and retry. - Run in parallel. Modern SDKs support N concurrent tool calls per turn — multiple times faster than serial.
- Don't expose too many tools. Above ~20 tools the model's pick rate falls off a cliff. Classify intent first, then route to a sub-toolkit.
Easy confusions#
Model ↔ tools are 1:1 bound.
Any MCP server is plug-and-play.
Further reading#
- MCP — the "USB-C" of Function Calling
- Skills — bundle tools into "capabilities"
- Code Interpreter — the special "tool" of "run arbitrary code"
- ReAct — the loop that repeatedly invokes tools