Function calling, also called tool use or tool calling, lets a large language model ask the application around it to run a piece of code and then use the result in its answer. It is how a model checks the weather, looks up an order, searches a database or calls an API, none of which it can do on its own.
How it works
The developer describes the available tools in the request: each one gets a name, a description of what it does, and a schema for its arguments, usually written in JSON Schema. When the model decides a tool would help, it does not run anything. It returns a structured request that names the tool and fills in the arguments, for example get_order_status with an order number. The application runs the function, sends the result back to the model, and the model writes its reply or asks for another tool.
OpenAI added function calling to its API in June 2023, and the other major model providers offer the same pattern with small differences in naming and format. The Model Context Protocol builds on it: an MCP server describes its tools in a standard way, so the same tools work across different AI applications.
Why it matters
Function calling is what turns a chatbot into an AI agent. An agent runs in a loop: the model picks a tool, reads the result and decides the next step until the task is done. It also gives developers a more dependable way to get structured data out of a model, since the arguments follow the schema, and providers with a strict mode guarantee they match it.
What to watch
The model chooses the arguments, so they are input from an untrusted source. Validate them like any form submission, check that the user is allowed to perform the action, and ask for confirmation before tools that change data, send messages or spend money. Text returned by a tool can also carry prompt injection, which makes the permissions given to each tool the most important design decision in the whole setup.