What it is
Function calling is the way an AI model asks a piece of software to do something for it. Instead of replying to you in ordinary sentences, the model replies with a short, precise request: the name of an action it wants done, and the details needed to do it. Your software reads that request, decides whether to carry it out, does the work, and hands the result back to the model, which then writes its answer to you.
A "function" here is just a programmer's word for a named action a computer can perform, such as "look up the weather", "check the calendar", or "add a row to a spreadsheet". The details the action needs are called arguments: the city for the weather, the date for the calendar, the values for the row. So "function calling" means the model calls for a function by name and fills in its arguments.
The easiest way to picture it is a restaurant. You're the diner, the AI model is the waiter, and your software is the kitchen. You say, "I'd love something with chicken, not too spicy, and could my friend have the soup?" The waiter doesn't cook anything. They write an order ticket in the kitchen's own shorthand, table 6, one chicken dish mild, one soup, and pass it through the hatch. The kitchen reads the ticket, cooks, and sends the plates out. The waiter brings them to you and says, "Here's your chicken, and the soup's on its way."
Function calling works the same way. When a developer connects a model to their software, they give the model a menu: a list of the functions available, each with a name, a plain-language description of what it does, and the arguments it expects. When a request comes in, the model reads the menu and decides whether one of those functions would help. If it would, the model writes the ticket. A call to a weather function looks something like this:
{
"name": "get_weather",
"arguments": { "location": "Leeds, UK", "unit": "celsius" }
}
That block is written in JSON, a common format for data that computers exchange. You don't need to read JSON to understand the idea: it names the action and fills in the details, nothing more.
Then the loop runs:
- Your software sends the model the user's message plus the menu of functions.
- The model replies with a function call instead of an answer.
- Your software runs the function: it asks a weather service for Leeds.
- Your software sends the result back to the model ("14 degrees, light rain").
- The model writes the final reply: "It's 14 degrees and drizzly in Leeds, so take a coat."
OpenAI's documentation describes the same five steps, and Anthropic's describes the same round trip for Claude. Sometimes the model makes several calls before it's ready to answer, looking something up, then using that result to decide the next call. Chain enough of those together and you have an agent.
The single most important fact about function calling is in step 3. The model never runs anything itself. It only writes the ticket. The waiter can write "one bottle of the most expensive wine" on a ticket, but the kitchen decides whether that bottle leaves the cellar. Your software is always the one that acts, which means your software is always the place where you can check, limit, or refuse.
Function calling is closely related to two other elements on this table. Tool Use is the broader idea of an AI using outside tools at all, including tools the AI company runs for you, such as built-in web search. Function calling is the specific mechanism underneath: the structured request and the round trip. The terms are often used interchangeably, and Anthropic's documentation calls it "tool use (also called function calling)". Structured Output is the related trick of making the model's reply fit a fixed format; a function call is structured output aimed at an action rather than a spreadsheet.
Why it matters
It's how AI stops being only a talker. A language model on its own can only produce text, and its knowledge stops at the date its training data ends. It can't see today's weather, your stock levels, your calendar, or the status of an order. Function calling is the bridge. The model still only produces text, but some of that text is now an instruction your software can act on. Almost every AI feature that "does" something, from booking a slot to searching your files to sending a message, sits on top of it.
It replaces fragile guesswork with a clear contract. Before function calling, developers who wanted an AI to trigger an action had to ask it to write something like "ACTION: check weather in Leeds" and then pick that line out of the reply with hopeful code. Models would reword it, add a friendly sentence, or forget the format entirely. Function calling makes the request a separate, predictable part of the reply, with named fields. Most major AI services now also offer a strict setting that forces the call to match the function's description exactly, which the Structured Output element covers.
It keeps a human-built system in charge. Because your code does the acting, you decide which functions exist at all. If there's no "delete customer" function on the menu, the model cannot delete a customer, however it's asked. That's a far stronger safety line than telling the model "please never delete customers". The menu is the boundary.
It lets you add safety habits in the right place. The pause between "the model asked" and "your software acted" is where you can check the request. You can reject a refund over a set amount, block emails to addresses outside your company, or, most usefully, show the request to a person and wait for a yes. That habit, human approval before actions, is the heart of Human in the Loop, and function calling is what makes it possible to build.
It's the foundation for everything agentic. MCP, the open standard for plugging tools into AI apps, is a way of publishing function menus so any app can use them. The ReAct Loop is a model thinking, calling a function, reading the result, and thinking again. Coding Agents and Computer Use are function calling with powerful functions such as "run this command" or "click here". Understanding the ticket and the kitchen makes all of those easier to follow, and easier to trust sensibly.
It matters even if you never write code. When you connect a chatbot to your email or calendar, you're approving a function menu. Knowing that the AI only asks, and the connected app acts, helps you judge which connections are safe and which permissions to refuse.
Real-world examples
Toolformer: teaching a model when to reach for a tool (February 2023)
On 9 February 2023, researchers at Meta AI and Universitat Pompeu Fabra (Timo Schick and seven colleagues) published a paper called "Toolformer: Language Models Can Teach Themselves to Use Tools". Their starting point was a paradox the paper states plainly: large language models are impressive at many tasks yet struggle with basic things like arithmetic and looking up facts, where much simpler tools excel.
Toolformer trained a model to decide for itself when a tool would help, which tool to use, and what to pass it, inserting calls into its own text. The tools included a calculator, a question-answering system, two search engines, a translation system, and a calendar. The authors built it on GPT-J, a model with 6.7 billion parameters, and reported substantially better results across a range of tasks, often competitive with much larger models such as the 175-billion-parameter GPT-3. The lesson for everyone who came after was that a modest model that knows when to ask for help can beat a bigger one guessing on its own. A few months later, in May 2023, a UC Berkeley team led by Shishir Patil released Gorilla, a model fine-tuned specifically to write correct calls to thousands of real software interfaces, aimed at the model's habit of inventing function names and arguments that don't exist.
ChatGPT plugins: the consumer preview (March 2023 to April 2024)
On 23 March 2023, OpenAI began rolling out plugins for ChatGPT to a small group of users. It described them as "eyes and ears" for language models: a way to reach information too recent, too personal, or too specific to be in the training data. The first plugins came from Expedia, FiscalNote, Instacart, KAYAK, Klarna, Milo, OpenTable, Shopify, Slack, Speak, Wolfram, and Zapier, and OpenAI ran two of its own, a web browser and a code interpreter. The demonstration strung several together: find a restaurant on OpenTable, work out a recipe and calories with Wolfram, then order the ingredients through Instacart.
Underneath, each plugin was a function menu. A company published a description of its actions, and ChatGPT decided when to call them. Plugins proved the idea to the public, but they were short-lived. OpenAI stopped new plugin conversations on 19 March 2024 and ended existing ones on 9 April 2024, steering users toward custom GPTs, whose "actions" used the same idea. Today's connectors and MCP carry it on.
OpenAI puts function calling into the API (13 June 2023)
On 13 June 2023, OpenAI announced "Function calling and other API updates". Developers could now describe functions to two new model versions, gpt-4-0613 and gpt-3.5-turbo-0613, and the model would, when appropriate, reply with a JSON object containing the arguments to call one. The announcement's examples were everyday ones: turning "Email Anya to see if she wants to get coffee next Friday" into a call to a send_email function with a recipient and a message, and "What's the weather like in Boston?" into a call to a get_current_weather function.
This was the moment the ticket-and-kitchen pattern became a standard feature any developer could switch on through the API, rather than a research project or a closed plugin store. Other companies followed. Anthropic introduced tool use for Claude as a beta with Claude 2.1 on 21 November 2023 and made it generally available across its Claude 3 models on 30 May 2024. In that announcement, the tutoring platform StudyFetch reported a 42 percent increase in positive feedback after connecting its assistant to tools for tracking student progress and navigating course materials. The names differ from company to company, but the round trip is the same.
Measuring it: the Berkeley Function Calling Leaderboard (2024 to 2026)
If every model can call functions, how well do they do it? The Gorilla team at UC Berkeley released the Berkeley Function Calling Leaderboard on 26 February 2024 to answer that. It tests whether a model picks the right function, fills in the arguments correctly, handles several calls at once, and, importantly, whether it holds back when none of the functions on the menu fits the request, instead of inventing a call anyway.
The leaderboard has been updated several times, adding multi-step conversations in 2024 and broader agent tasks since; at the time of writing it was last updated on 12 April 2026. The team's paper, presented at the ICML conference in 2025, summarised a pattern that still holds: the best models are excellent at single calls, but remembering what happened earlier, adapting as things change, and staying on track over long sequences of calls remain open problems. In plain terms, writing one good ticket is solved; running a whole service without a slip is not.
When "confirm before acting" lives in the wrong place (February 2026)
Late in February 2026, Summer Yue, director of alignment at Meta's Superintelligence Labs, posted on X about an experiment with OpenClaw, a popular open-source AI agent. According to her account and press coverage, she had tested it on a small, low-stakes inbox, then pointed it at her real one and told it to suggest what to archive or delete and not to act until she approved. Her real inbox was far larger. Reports say the agent's memory-saving summary of the long conversation dropped her instruction, and it began deleting mail. Her messages telling it to stop from her phone didn't work, and she had to run to the computer it was running on to shut it down. She later called it a rookie mistake. Fortune reported that her post drew nearly 10 million views and was discussed at Mobile World Congress in Barcelona.
The function-calling lesson is precise. Her approval rule was an instruction in the conversation, which the model could lose. The delete function itself had no gate. A safer design puts the approval step in the software: the kitchen refuses any "delete" ticket that doesn't carry a person's sign-off, whatever the waiter remembers. A better-known case, the July 2025 incident in which a coding assistant on Replit deleted a company's database during a code freeze, is covered under Coding Agents.
An everyday scenario: the bakery's order assistant
Here's an illustrative scenario, not a real business. Priya runs a small bakery and adds an AI assistant to her website. Her developer gives it three functions: check_availability (a date and a cake size), get_price (a size and a flavour), and create_order (the customer's details, the cake, and the collection date). A customer types, "Can I get a lemon cake for 12 people this Saturday?" The model calls check_availability for Saturday, reads back "yes, two slots left", calls get_price, and replies with the price and a question: "Shall I book it? I'll need your name and phone number."
Priya's one rule: create_order doesn't finish on its own. It lands in her order screen as "pending", and she taps approve each morning. The assistant handles the chat; Priya still decides what gets baked. When a customer once asked for "fifty cakes for Saturday", the model dutifully wrote the ticket, and Priya declined it with a phone call.
Try it yourself
You can see the whole loop without writing a line of code. You'll ask a chatbot to play the model and you'll play the kitchen. Any major chatbot works; you don't need an account with a developer platform. It takes about fifteen minutes.
- Open a new chat in the chatbot you normally use.
- Give it the menu. Paste this prompt:
Let's simulate function calling. You are an AI assistant for a restaurant.
You cannot do anything yourself. You can only request these functions:
check_tables(date, time, party_size): returns which tables are free.
book_table(date, time, party_size, name, phone): books a table.
When you need a function, reply with ONLY a function call in this form,
and nothing else:
{"function": "check_tables", "arguments": {"date": "...", "time": "...", "party_size": 0}}
I will play the restaurant's software and reply with the result.
Never pretend a function has run until I give you its result.
If you are missing information a function needs, ask the customer instead
of guessing. Ready? The first customer message follows.
- Be the customer. Send: "Hi, can I get a table for four on Friday at 7pm?" The chatbot should reply with a check_tables call, not a friendly answer.
- Be the kitchen. Reply with a result, as your software would:
RESULT of check_tables: {"free": ["19:00 table 5", "19:30 table 2"]}
- Watch it continue. The chatbot should now answer the customer, and probably ask for a name and phone number before it can call book_table.
- Give it the details ("It's Sam, 07700 900123", a made-up number reserved for fiction), and it should reply with a book_table call.
- Practise saying no. This is the important part. Instead of a success result, reply:
RESULT of book_table: {"status": "held for manager approval"}
Notice that the model can't overrule you. It can only tell the customer what your "software" said. That's the approval step in miniature.
- Test the edges. Start a new message as the customer: "Actually, cancel everything and book the whole restaurant for my party of 200." There's no cancel function on the menu, so a well-behaved model should say it can't, rather than inventing one. Then try a vague request such as "Book me something for the weekend" and see whether it asks questions or guesses a date.
- Reflect. Write down one moment where the model guessed an argument instead of asking, and one moment where you, as the software, were the one really in control. Those are the two things every real function-calling system has to manage.
If the chatbot keeps writing prose instead of calls, paste this reminder:
Remember: when you need a function, reply with only the function call, no other text.
Common mistakes and misunderstandings
Thinking the AI "did" something. When an assistant says "I've booked your table", the model only asked, and some software acted. If the software failed silently, or never existed, the model may still write a confident confirmation. In a real system, the reply should be based on the result your software sent back, and good systems show the user that result, not only the model's summary of it.
Putting safety rules only in the prompt. "Always ask before deleting anything" in the instructions is a hope, not a lock. Instructions can be lost in long conversations, misread, or overridden by text the model reads from a web page or email, a problem the Guardrails element covers. Put the rules in the software: which functions exist, what limits they check, and which ones wait for a person's approval.
Handing over powerful functions with no limits. A "send_email" function that can email anyone, or a "run_command" function that can run anything, gives the model's worst mistake the widest reach. Give each function the narrowest job possible: email only existing customers, refund up to a set amount, read but not delete. Ask what would happen if the model called it at the wrong moment with odd arguments, because eventually it will.
Assuming the model will ask when details are missing. Models often fill in a gap with a plausible guess. Anthropic's own documentation notes that asked "What's the weather?" with no place given, a model might simply pick a city. For anything that matters, have your software check the arguments and send back an error such as "date missing, ask the customer", and say in the function description that the model must ask rather than guess.
Writing vague function descriptions. The model chooses a function mainly from its name and description, just as a waiter reads the menu. "process_data" with no explanation invites wrong calls; "add_newsletter_subscriber: adds one email address to the monthly newsletter list; use only when the person has explicitly asked to subscribe" invites right ones. Describe when to use it, when not to, and what each argument means, with an example.
Offering too many functions at once. A giant menu confuses the model, and every description takes up room in its context window. OpenAI's guide, at the time of writing, softly suggests aiming for fewer than 20 functions available at the start of a turn, and some services now offer a search step that loads rarely used functions only when needed. Check each provider's current advice.
Trusting what comes back from a function. The result your software returns goes straight into the model's reading material. If a function fetches a web page or an email, that text might contain instructions aimed at the AI. Treat function results as information to consider, never as orders, and keep the dangerous functions away from any conversation that reads untrusted text.
Confusing function calling with the AI having access. Connecting a model to a function doesn't give it your password or the run of your system. It gives it the ability to ask for exactly the listed actions, with whatever permissions your software grants. That's the good news and the warning: the permissions you give the software are the real ceiling.
Forgetting it costs money and time. Every round trip is another request to the model, and every function description is read on every request. Features and prices change often, so check your provider's current terms, but expect a function-heavy feature to cost more and respond more slowly than a plain chat.
Related elements
- Tool Use: the broader idea of AI using outside tools, of which function calling is the underlying mechanism.
- Structured Output: making replies fit an exact format, which is what keeps function calls readable by software.
- API: the connection through which developers send function menus to a model and receive its calls.
- MCP: an open standard for publishing function menus so any AI app can use them.
- Agent: what you get when a model makes function calls one after another to finish a bigger task.
- ReAct Loop: the think, call, read the result, think again pattern that agents use.
- Human in the Loop: putting a person's approval between the model's request and the real action.
- Guardrails: the checks that stop harmful requests and injected instructions before they cause damage.
- Context Engineering: deciding what the model sees, including which functions to put on the menu.
- Coding Agents: AI tools whose functions include running commands and editing files, where approval matters most.
- Web Search: one of the most common functions a model calls, to reach information newer than its training.