What it is used for
Function calling is used whenever an AI answer must come from real data or a real action, not from the model's memory. Everyday examples: an online shop assistant that checks current stock and prices before answering a buyer, a chatbot that books an appointment and records it in a calendar, or an office assistant that pulls this month's sales figures from a database before writing a summary.
Without function calling, a model can only guess from text patterns learned in training, and such guesses can be out of date or simply invented. With function calling, the answer rests on data actually fetched at that moment.
How to use it
As an ordinary user, you never write any functions; you experience them through products. A shopping assistant that can answer "only three pairs left in size 42" is almost certainly using function calling behind the scenes. What you can do is choose products whose data sources are clear, and check important actions, such as payments, before approving them.
For people building applications, the pattern is simple. You register a list of functions with explanations of what they do, the model decides which to call and fills in its data, your application runs it, the result goes back to the model, and the model answers. If the result is not enough, the model may call another function.
Practitioner level
A function is defined using a schema, a written blueprint that states the function's name, its purpose, and exactly what data must be supplied. The schema is usually written in JSON, a structured text format for exchanging data between programs. The data the model fills in is called the arguments, for example a city name for a weather function or an order number for a shipment tracking function.
The official flow in OpenAI's documentation has five steps: the application sends a request along with the list of tools, the model replies with a tool call, the application runs that function's code, the result is sent back to the model, and the model gives a final answer or calls another tool. One point beginners often miss: the model never runs the function itself. The model only asks; the application executes and is responsible for the result.
Anthropic distinguishes two places tools can run. Client tools run inside your application, while server tools run on the model provider's infrastructure, for example a web search tool. The good practices in both sets of documentation are similar: give functions very clear names and descriptions, limit how many functions are available in one turn (OpenAI suggests fewer than 20 as a soft guideline), and use restricted choices (enums) so the model cannot fill in values outside the valid set.
Expert level
Because function definitions are sent to the model with every request, they consume tokens, the small units of text behind the model's memory limit and its cost. Too many functions means higher cost and less accurate tool selection. For very large tool sets, OpenAI offers tool search, a way to load rarely used functions only when needed.
A model can also call several independent functions at once in a single turn, for example checking the weather in two cities. On the control side, developers can set the tool choice: the model may choose freely, be forced to use a specific tool, or be forbidden from using tools at all. Strict mode on a schema forces the model's arguments to match the blueprint exactly, reducing malformed data reaching the function.
Limits and risks
Function calling does not make a model always right. It can pick the wrong function, fill in wrong arguments, or misread the result that comes back. Functions with real world impact, such as moving money or deleting data, should be designed so they can be checked and undone, and should ask human approval for hard to reverse actions.
There is also a security risk: results from tools or web pages can contain hidden instruction text planted by someone else to steer the model. A well built application treats outside content as data, not as commands, and limits the functions the model may touch to only those it truly needs.
