Function Calling
One-Sentence Definition
Function Calling is a structured agreement between the model and the host application. When the model thinks a tool is needed, it expresses that need in a machine-readable format instead of vague natural language.
Intuitive Analogies
Analogy 1: A standardized order form
If the restaurant server is a robot, you cannot say "bring me a spicy chicken dish." You have to fill in a clear form:
{
"dish_name": "kung pao chicken",
"spice_level": "high",
"rice": "half"
}Function calling is the model learning how to fill out that form.
Analogy 2: A bank transfer form
You do not just say "please send some money to my mother." You provide fields like:
- recipient
- account
- amount
- purpose
Only once the request is structured can the system execute it precisely.
How It Works
A typical flow looks like this:
- the developer tells the model which functions exist
- the model decides whether a tool is needed
- if needed, it outputs a structured tool request
- the host application executes the function
- the result goes back to the model
- the model produces the final answer using the real result
The crucial point: the model requests the call, but the external program performs it.
Why It Is More Reliable Than Pure Chat
In pure chat mode, the model may invent a weather answer. In function calling mode, it first asks for something like:
{
"name": "get_weather",
"arguments": {
"city": "Beijing"
}
}Then the program fetches real weather data and returns it to the model.
A Simple E-Commerce Example
Possible functions might include:
search_productcheck_order_statuscreate_return_requesttransfer_to_human
If the user says:
I want to return my order. The order number is 20250301001.The model can first request an order-status check, then request return creation if the conditions are met. That is much closer to actual task handling than plain chat.
Function Calling vs Plugins vs MCP
Function Calling: how the model expresses tool requestsPlugin: a concrete capability module that can be connectedMCP: a broader protocol for standardizing tool and data integration
So function calling and MCP solve different layers.
How Regular Users Encounter It
You may not write code yourself, but you still meet this capability when you:
- add tools in a visual builder
- configure actions
- attach plugins to an agent
Many of those systems rely on function calling underneath.
What You Need to Remember
- function calling helps the model move from talking toward doing
- the model does not execute the function itself
- structured output is what makes this reliable
Sources
- OpenAI Function Calling Guide
- OpenAI Tools Guide