# What is function calling in LLMs: how models ask your code to act

> The model returns a function name and JSON arguments, your app runs it, and the result goes back. How OpenAI, Claude and Gemini do it, and where it came from.

URL: https://claudegpt.si/news/what-is-function-calling-llm  
Published: 2026-11-27T14:57:24.799Z  
Author: ClaudeGPT Si Newsroom  
Section: Research  
Topics: AI agents, Language models, OpenAI, Claude, Gemini, MCP  
Publisher: ClaudeGPT Si

## Key takeaways

- Function calling lets a model return a function name and JSON arguments; your application runs the function and sends the result back.
- Function calling and tool calling are the same feature, and OpenAI, Anthropic and Google all describe inputs with JSON Schema.
- OpenAI launched function calling on June 13, 2023, after research such as Meta's Toolformer and Berkeley's Gorilla showed models could learn to call APIs.

Function calling, also called tool calling, is how a large language model asks your code to do something for it. You describe a few functions to the model, each with a name, a description and a JSON schema for its inputs. When a request needs one, the model replies with the function's name and the arguments as JSON, your application runs the function, and you send the result back so the model can finish its answer.

The model never runs anything itself. Google's [Gemini function calling docs](https://aistudio.google.com/docs/function-calling) say it plainly: "The model doesn't execute the function itself." What it gains is a machine-readable way to say "call this, with these values," which is what lets a chatbot check an order, query a database or drive a coding agent.

## How function calling works, step by step

OpenAI's [function calling guide](https://developers.openai.com/api/docs/guides/function-calling) breaks the loop into five steps:

1. Send a request to the model with the tools it may call.
2. Receive a tool call from the model.
3. Run the matching code in your application, using the call's arguments.
4. Send a second request that contains the tool's output.
5. Receive the final answer, or more tool calls.

Google and Anthropic describe the same loop. The last step makes agents possible: the model can keep calling tools until the task is done.

A function definition is short. Here is the weather example that [Anthropic's tool use docs](https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview) use:

```json
{
  "name": "get_weather",
  "description": "Get the current weather for a given location.",
  "input_schema": {
    "type": "object",
    "properties": {
      "location": {
        "type": "string",
        "description": "City and state, e.g. San Francisco, CA"
      }
    },
    "required": ["location"]
  }
}
```

Ask Claude "What's the weather in San Francisco?" with that tool attached, and it returns a `tool_use` block calling `get_weather` with `{"location": "San Francisco, CA"}`. Your code fetches the weather, sends it back in a `tool_result` block with the same ID, and Claude writes the answer.

The description matters most: a vague one gets a tool called at the wrong time, or not at all.

## Function calling vs tool calling: the same thing

The two names describe one feature. OpenAI launched it as "function calling" on [June 13, 2023](https://openai.com/index/function-calling-and-other-api-updates/), when developers could describe functions to `gpt-4-0613` and `gpt-3.5-turbo-0613` and the model would reply with a JSON object of arguments for them. Anthropic's docs call the feature tool use and say it is also called function calling. OpenAI's current guide uses function and tool interchangeably.

"Tool" has become the broader word because not every tool is a function you write. The providers now offer three kinds:

- **Your own functions.** You write the schema and run the code. This is classic function calling.
- **Tools the provider runs.** Web search, code execution and connections to MCP servers run on the provider's servers. Anthropic calls these server tools; OpenAI calls them built-in tools.
- **Freeform tools.** OpenAI's custom tools take plain text instead of JSON, optionally constrained by a Lark or regex grammar.

## How OpenAI, Claude and Gemini compare

All three use JSON Schema for inputs and allow several calls per turn. The table is based on each company's documentation as of November 27, 2026.

| | OpenAI | Claude (Anthropic) | Gemini (Google) |
| --- | --- | --- | --- |
| What the docs call it | Function calling, tools | Tool use | Function calling |
| Input schema field | `parameters` | `input_schema` | `parameters` |
| How results are matched | `call_id` | `tool_use_id` | Function response sent back to the model |
| Control over calling | `auto`, `required`, a named function, `allowed_tools`, `none` | `auto`, `any`, a named tool, `none` | `auto`, `any`, `none`, `validated` |
| Schema-exact arguments | `strict: true` | `strict: true` | `validated` mode |
| Several calls at once | Yes, can be turned off with `parallel_tool_calls` | Yes, can be turned off with `disable_parallel_tool_use` | Yes, parallel and chained ("compositional") calls |
| Tools the provider runs | Web search, code execution, MCP servers | Web search, web fetch, code execution, tool search, MCP connector | Google Search, combinable with your functions |

Without strict mode, the model follows your schema only on a best-effort basis. With it, the arguments match the schema.

## Where function calling came from

The idea is older than the API feature. In February 2023, Meta AI Research published [Toolformer](https://arxiv.org/abs/2302.04761), a paper by Timo Schick and seven co-authors. They fine-tuned GPT-J, a 6.7-billion-parameter model, to insert API calls into its own text: a calculator, a question-answering system, two search engines, a translator and a calendar. The model learned this from a few examples per API, and a call was kept for training only when its result made the following text easier to predict. The authors note that it could not chain one tool into another.

In May 2023, UC Berkeley researchers released [Gorilla](https://arxiv.org/abs/2305.15334), a LLaMA-based model fine-tuned to write API calls for Hugging Face, TorchHub and TensorHub. The authors report that it beat GPT-4 at those calls and invented fewer nonexistent APIs.

OpenAI's June 2023 release turned the idea into a product: calls came back as structured JSON in a separate field, which is the design OpenAI, Anthropic and Google all use today.

## How good models are at it

The Gorilla team went on to build the [Berkeley Function Calling Leaderboard](https://gorilla.cs.berkeley.edu/leaderboard.html), or BFCL, a public test of how well models call tools. It checks calls by parsing them into a syntax tree, which scales to thousands of functions. Its [ICML 2025 paper](https://proceedings.mlr.press/v267/patil25a.html) covers serial and parallel calls, several programming languages, and whether a model knows when not to call a tool. The current version, V4, adds agentic tests such as web search.

The paper finds that leading models handle single-turn calls well, while "memory, dynamic decision-making, and long-horizon reasoning remain open challenges." Picking the right function once is close to solved. A long chain of calls is not.

## Function calling vs MCP

Function calling is how the model emits a call. The [Model Context Protocol](https://modelcontextprotocol.io/specification/2025-06-18/server/tools) is a standard for where tools come from. An MCP server lists its tools in a `tools/list` response, each with a name, a description and an `inputSchema`, which is the same shape as a function definition. The client hands those to the model, and when the model calls one, the client forwards it as a `tools/call` request.

So MCP doesn't replace function calling. It lets one server's tools work with any app that speaks the protocol. An [explainer on MCP](https://claudegpt.si/news/what-is-mcp-model-context-protocol) covers the protocol, and [MCP elicitation](https://claudegpt.si/news/mcp-elicitation-explained) shows how a server can stop mid-call to ask the user for missing details. The same loop also powers [agentic RAG](https://claudegpt.si/news/agentic-rag-explained), where search is one of the tools the model chooses when to call.

## What it costs and what goes wrong

Tool definitions are not free. OpenAI's guide says they use up context and are billed as input tokens. Anthropic adds a hidden system prompt whenever tools are present: 286 tokens for Claude Opus 5.5 with automatic tool choice, on top of your schemas. Google's docs suggest that once you pass roughly 20 to 30 tools, you should load them on demand with a tool search step instead of sending them all.

A few failure modes come up again and again:

- **Guessed arguments.** Anthropic warns that when a required value is missing, Claude Sonnet may fill in a plausible value on its own, while Claude Opus is more likely to ask.
- **Wrong or missed calls.** Usually a description problem, or a system prompt that never tells the model to use its tools.
- **Unsafe actions.** The MCP spec says a person should always be able to deny a tool call, and that apps should show the user a tool's inputs before running it. That applies to any function that sends, buys or deletes something.

For a first build, start with one or two functions, turn on strict mode and log every call the model makes.

## Frequently asked questions

### What is the difference between function calling and tool calling?

There is none in practice. OpenAI launched the feature as function calling, Anthropic's docs call it tool use, also called function calling, and tool has become the broader word that also covers tools the provider runs, such as web search.

### What is the difference between function calling and MCP?

Function calling is how the model emits a structured call. MCP is a standard for servers to list tools, each with a name, description and input schema, and to run them, so one server's tools work with any MCP client and model.

### Does the model run the function itself?

No. The model only returns the function name and arguments. Your application runs the code and sends the result back, except for tools the provider runs on its own servers, such as web search.

### Which LLM is best at function calling?

The Berkeley Function Calling Leaderboard (BFCL) is a public benchmark that ranks models on tool calls. Its authors find leading models handle single calls well, while memory and long multi-step tasks remain hard.

## Sources

- [Function calling](https://developers.openai.com/api/docs/guides/function-calling), OpenAI
- [Tool use with Claude](https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview), Anthropic
- [Function calling with the Gemini API](https://aistudio.google.com/docs/function-calling), Google
- [Function calling and other API updates](https://openai.com/index/function-calling-and-other-api-updates/), OpenAI
- [Toolformer: Language Models Can Teach Themselves to Use Tools](https://arxiv.org/abs/2302.04761), arXiv
- [Gorilla: Large Language Model Connected with Massive APIs](https://arxiv.org/abs/2305.15334), arXiv
- [The Berkeley Function Calling Leaderboard (BFCL): From Tool Use to Agentic Evaluation of Large Language Models](https://proceedings.mlr.press/v267/patil25a.html), PMLR (ICML 2025)
- [Berkeley Function Calling Leaderboard](https://gorilla.cs.berkeley.edu/leaderboard.html), UC Berkeley
- [Model Context Protocol specification: Tools](https://modelcontextprotocol.io/specification/2025-06-18/server/tools), Model Context Protocol
