Function calling and tool calling in LLMs: how it works and how providers differ

Build agents
HoneyHive Engineering

Function calling lets an LLM return a structured request for your code to run. The model never executes the function. How OpenAI, Claude and Gemini differ.

Function calling (also called tool calling or tool use) is a model feature where you describe functions to the LLM and it replies with a structured request to call one, instead of plain text. The model never runs anything for functions you define. Your code runs the call and sends the result back, and the model writes the answer.

The loop

OpenAI’s guide describes five steps: send a request with the tools the model could call, receive a tool call, run the function in your application, send a second request with the output, and receive a final response or further tool calls. Because the last step can be another tool call, this is the loop that most AI agents are built on, as in the ReAct pattern.

your app                          model
   | -- prompt + tool definitions --> |
   | <-- tool call (name, args) ----- |
   | run the function                 |
   | -- tool result (same call id) -> |
   | <-- answer or another call ----- |

The pieces are the same across providers. A tool definition has a name, a description and a JSON Schema for the arguments. OpenAI’s function definition uses name, description, parameters and strict, and Claude’s tool definition uses name, description and input_schema. Each call carries an id, and the result must quote it: OpenAI uses a call_id, Claude a tool_use_id and Gemini a call_id on a function_result step.

Where the function runs

The main difference between tools is who executes them. Claude’s docs separate client tools, which run in your application, from server tools such as web_search, web_fetch and code_execution, which run on Anthropic’s infrastructure so you see only the results. For client tools Claude returns stop_reason: "tool_use", your code runs the operation and sends back a tool_result.

Gemini’s docs say the model doesn’t execute the function itself. A function call is a request your code can refuse. Anything you run on the model’s say-so needs the same checks as any other untrusted input; see prompt injection and human-in-the-loop approval.

Controlling when a tool is called

All three providers let you choose between letting the model decide, forcing a call and forbidding calls.

Setting OpenAI Claude Gemini
Model decides (default) auto: zero, one or several functions auto auto
Must call some tool required any any
Must call one named tool Forced function tool allowed_tools with mode: any and one tool
No calls none none none
Limit to a subset allowed_tools Not listed allowed_tools
Schema-validated calls strict strict: true validated

Three details matter in practice.

  • Forcing is not available everywhere. Claude’s docs say any and tool fail on some models and settings, including manual extended thinking and several newer models as of November 2026. The suggested replacement is auto with strict tool use.
  • Forcing removes the preamble. With any or tool, Claude’s API prefills the assistant message, so the model will not write an explanation before the call.
  • Prompting still steers auto. Claude’s docs say the tool boundary is steerable through the system prompt: a line such as “Use the tools to investigate before responding” increases tool use.

Parallel and chained calls

A model can ask for several independent calls in one turn. OpenAI’s guide says it may call multiple functions per turn and that parallel_tool_calls: false limits it to zero or one. Claude has disable_parallel_tool_use on tool_choice. Gemini’s docs describe parallel calling for independent functions and compositional calling, where later calls depend on earlier results, such as looking up a location before fetching its weather.

Each result goes back with its own call id, so run independent calls together and return every result in the next request.

Writing tool definitions

The description is the part the model reads to decide. Claude’s docs call detailed descriptions by far the most important factor in tool performance and ask for at least three or four sentences covering what the tool does, when to use it and when not to, what each parameter means and any limits. The same page makes four more recommendations:

  • Consolidate related operations into fewer tools, for example one tool with an action parameter rather than create_pr, review_pr and merge_pr.
  • Prefix names with the service, such as github_list_prs.
  • Return only high-signal fields from the tool, with stable identifiers.
  • Add input_examples for tools with nested or format-sensitive inputs.

Cost matters too. OpenAI says definitions count against the context limit and are billed as input tokens, and Claude counts the tools parameter, tool_use and tool_result blocks as tokens and adds a tool-use system prompt automatically. A long tool list also eats into the context window.

What still goes wrong

  • Wrong tool or invented arguments. Claude’s docs say that when a required parameter is missing, Sonnet might infer a reasonable value instead of asking, and that this is not guaranteed either way. Strict mode fixes the shape of the arguments, not whether the value is the one the user meant. The same distinction applies to structured output.
  • Too many tools. OpenAI’s soft limit is under 20 functions at the start of a turn. Every definition also adds input tokens, which is what a tool search tool is meant to reduce. When a task chains many calls, programmatic tool calling keeps the intermediate results out of the context.
  • Unmatched ids. Each result must quote the id of the call it answers, which is how the provider pairs them. Keep the original model steps in the history you resend, as Gemini’s docs say stateless mode requires.
  • Text around the call. Claude often writes text before a call. The docs say to treat it like any other assistant text and not parse it.
  • Unsafe execution. The call is the model’s output, so validate and authorize it before running it.

Function calling vs MCP

They sit at different layers. Function calling is how a model asks for a call; the Model Context Protocol standardizes how tools are described, discovered and run by a server. A host app usually fetches MCP tool definitions and passes them to the model through function calling. See MCP vs API for the comparison.

Where this comes from

Schick and colleagues introduced Toolformer in February 2023, a model trained to decide which APIs to call, when, with what arguments and how to use the results. Provider function calling APIs now make this a standard interface instead of a training method, and the Berkeley Function Calling Leaderboard measures it, moving from single-turn AST checks to multi-turn interactions in its third version and agentic evaluation in its fourth.

Tracing tool calls with HoneyHive

Tool failures show up in the trajectory, not only in the final answer. HoneyHive’s tracing captures LLM requests, tool calls and agent handoffs using OpenTelemetry, and the tree view nests model and tool events by parent and child, so you can click a tool span to see the inputs and outputs it actually had. For scoring, see agent evaluation metrics and agent tracing.

FAQ

Are function calling and tool calling the same thing?

In practice, yes. Anthropic's docs say tool use is also called function calling. The one distinction worth keeping is where the code runs: your application, or the provider (server tools such as web search).

Does the model run the function?

For functions you define, no. Google's docs say the model doesn't execute the function itself; your code extracts the name and arguments and runs it. Claude's server tools are the exception, because Anthropic runs them.

Does strict mode make tool calls correct?

It makes them match the schema, not be right. OpenAI recommends always enabling strict mode, which guarantees the shape of the arguments. The model can still pick the wrong tool or a wrong value.

How many tools can I give a model?

OpenAI suggests fewer than 20 functions at the start of a turn, and calls that a soft suggestion. Every definition also costs input tokens, so consolidate related operations into fewer tools.

How do I test function calling?

Check the right tool was called with valid arguments, then check the final answer. The Berkeley Function Calling Leaderboard shows how such tests grew from single-turn checks to multi-turn and agentic evaluation.

Share