Function calling (tool use)
Function calling is an API feature in which a language model proposes a call to a described function, with parameters, and the application runs that call.
The model only proposes the call; the application has to run it.
On its own, a language model can't look anything up in a database or send an email. Function calling closes that gap in a controlled way. The application tells the model which functions exist, such as “check delivery status” with an order number as its parameter. If one of them fits the request, the model replies with a machine-readable call instead of text: the function name plus values for its parameters. The application runs it and hands the result back.
The name depends on the vendor. OpenAI says function calling and also tool calling, Anthropic says tool use, and Google's Gemini documentation uses function calling for the same mechanism. OpenAI introduced it on June 13, 2023, for the gpt-4-0613 and gpt-3.5-turbo-0613 models. Shortly before, the research model Toolformer had shown that language models can learn when to call which API and with which arguments.
Function calling is where an AI system starts to change things in company systems. Which functions a model may propose, which permissions the application uses to run them and where a person has to sign off are decisions about access and liability.
Chapter 1 of 6
How a call works.
OpenAI's documentation lays out five steps, and other major vendors follow the same pattern. First, the application sends the request to the model along with the list of available functions. The model replies with a call: a function name and parameters. Next, the application runs its own code, for example a query against the inventory system. It then sends the result back to the model in a second request. Finally, the model writes the answer or proposes more calls.
The model decides on each turn whether it needs a function. The application can override that: force a call, limit the choice to certain functions or switch calls off entirely. Newer models can also propose several calls at once.
Built-in vendor tools such as Anthropic's web search are the exception. They run on the vendor's infrastructure. Even there, the model itself executes nothing.
Chapter 2 of 6
The description drives the choice.
Each function is passed with a name, a plain-language description and a schema for its parameters. The schema, written in the JSON Schema standard, sets the fields, their types and which ones are required. The model makes its choice from this description. OpenAI suggests a test: could an intern use the function correctly with nothing but this description?
Vendors advise keeping the number of functions per request small. OpenAI gives fewer than 20 as a rough guide, Google 10 to 20. Functions that are rarely needed can be loaded on demand.
Strict mode at OpenAI and Anthropic makes sure a call matches the schema. It says nothing about whether the values are right. Anthropic notes that a model may ask for a missing required value, but it may also guess a plausible one. Values the application already knows, such as the logged-in user's customer number, are better filled in by the application itself.
Chapter 3 of 6
The application handles permissions and approvals.
The OWASP Top 10 for LLM Applications 2025 lists “excessive agency” and names its causes: functions that can do more than needed, access with broader permissions than needed and high-impact actions without human review.
The fixes live in the application. Each function does one narrowly defined job instead of, say, accepting any database command. It runs with the logged-in user's permissions instead of a master key, and the target system checks authorization itself. Read-only queries can usually run without asking. Write actions such as payments, deletions, emails to outside parties or changes to master data need a person to approve them.
The Model Context Protocol specification requires servers to validate inputs and rate-limit calls. Applications should ask for confirmation on sensitive operations and log tool use. A log with function name, parameters, result and approval shows later what the system did and why.
Chapter 4 of 6
Tools raise the stakes of prompt injection.
OWASP describes indirect prompt injection: content from websites or files changes the model's behavior in unintended ways. If an incoming email contains a hidden instruction, the model may propose a call that nobody wanted. Without tools, the worst case is a wrong answer. With tools, it can be a bank transfer or an email that sends confidential data outside the company.
OpenAI flagged this at launch in June 2023: text from a tool's output can push the model into unintended actions. Its advice at the time was to connect only trusted tools and to ask users for confirmation before actions with real-world impact.
The application therefore treats outside content as data. A cap on calls per request stops endless loops, and approval before write actions limits the damage if a manipulation slips through.
Chapter 5 of 6
Function calling, MCP and agents sit on different layers.
Function calling is the model's ability to propose a call. The Model Context Protocol (MCP) covers something else: how an application discovers tools on a server and calls them. An MCP server lists its tools with name, description and parameter schema, and it runs them when told to. That way a tool can be built once and used in several AI applications. Which tool is needed is still the model's decision.
An AI agent uses function calling in a loop. It pursues a goal over many steps, evaluates each result and picks the next call. Orchestration defines how steps, models and checks fit together.
Retrieval-augmented generation (RAG) pulls relevant passages into the context before the model answers. That search can also be offered as a function.
Chapter 6 of 6
Where the term stops working
Function calling only describes the mechanism by which a model proposes a structured call and gets a result back. How tools are provided is handled by standards such as the Model Context Protocol; a system that chains many calls toward a goal is an AI agent. A call that matches the schema can still contain the wrong function or wrong values.
Frequently asked questions
What is function calling?
Function calling is a method in which a language model outputs a structured call to a function, with parameters, instead of a text reply. The application runs the call and returns the result to the model, which then writes the answer.
Is function calling the same as tool calling?
Yes, both terms describe the same mechanism. OpenAI uses both names, Anthropic calls it tool use and Google calls it function calling.
Does the language model run the function itself?
No. The model only proposes the call; the application has to run it, or, for built-in tools, the vendor's infrastructure. Permissions, checks and approvals therefore belong in the application.
What is the difference between function calling and MCP?
Function calling is the model's ability to propose a call. MCP is an open protocol that applications use to list and call tools on servers. MCP standardizes the connection, function calling covers the model's choice, and in practice the two work together.
What is the difference between function calling and RAG?
RAG brings knowledge from documents into the model's context, while function calling triggers queries or actions in other systems. Live data such as a delivery status calls for function calling, content from manuals for RAG. If document search is offered as a function, the model decides when to search.
What are the security risks of function calling?
The risk is calls nobody wanted, caused by model errors or by manipulated content (prompt injection). Narrow functions, the logged-in user's permissions, approval before write actions and a complete log limit the damage.
How much does function calling cost?
Function calling has no separate price; you pay for the tokens processed. Function definitions count as input on every request, and every call needs another round trip to the model. Short descriptions, few functions and prompt caching for definitions that don't change keep costs down.
Sources
- OpenAI: Function calling, API documentation, as of November 2026
- OpenAI: Function calling and other API updates, June 13, 2023
- Anthropic: Tool use with Claude, documentation, as of November 2026
- Google: Function calling with the Gemini API, documentation, as of November 2026
- Model Context Protocol: Specification 2026-07-28, Server Features, Tools
- OWASP GenAI Security Project: LLM06:2025 Excessive Agency, OWASP Top 10 for LLM Applications 2025
- OWASP GenAI Security Project: LLM01:2025 Prompt Injection, OWASP Top 10 for LLM Applications 2025
- Schick et al.: Toolformer: Language Models Can Teach Themselves to Use Tools, arXiv:2302.04761, February 2023