---
title: "Tool calling explained: OpenAI, Anthropic, Gemini, and MCP formats"
type: "deep dive"
url: "https://aifordevs.org/articles/tool-calling"
markdown: "https://aifordevs.org/articles/tool-calling.md"
publisher: "AI for Devs"
license: "https://aifordevs.org/reuse"
attribution: "Credit AI for Devs and link to https://aifordevs.org/articles/tool-calling"
description: "Tool calling across OpenAI, Anthropic, and Gemini: the request loop, field-by-field format differences, tool_choice, parallel calls, MCP, and gateways."
author: "AI for Devs"
published: "2026-11-24"
level: "Intermediate"
topics: ["apis", "agents"]
---

# Tool calling explained: OpenAI, Anthropic, Gemini, and MCP formats

Tool calling across OpenAI, Anthropic, and Gemini: the request loop, field-by-field format differences, tool_choice, parallel calls, MCP, and gateways.

> **TL;DR**
>
> - Tool calling is a four-step loop: you send tool schemas, the model returns a call, your code runs it, and you send the result back. The model never executes your function.
> - OpenAI returns arguments as a JSON string, while Anthropic and Gemini return an object, and each API matches results to calls with a different id field.
> - tool_choice and parallel-call controls differ by name and placement, and as of November 23, 2026, Claude Opus 5.5 and Sonnet 5.5 reject forced tool use with a 400 error.
> - MCP standardizes the tool side (`tools/list`, `tools/call`), not the model side, so a client still converts between MCP and each provider's tool calling format.
> - Bifrost, an open-source AI gateway, translates OpenAI-format tool calls for Anthropic and Gemini, but drops `strict` for both and `parallel_tool_calls` for Gemini.

Tool calling is the mechanism that lets a language model ask your code to run a function. You send the model a list of tool definitions, the model replies with a structured request naming a tool and its arguments, and your application runs it and sends the result back. OpenAI, Anthropic, and Google all implement this loop, and they disagree on field names, argument encoding, result placement, and the controls that force or limit calls. Those differences are what break an agent when it moves between providers.

This article lines up the three formats field by field from each provider's current docs, then covers `tool_choice`, parallel calls, where MCP fits, and how a gateway such as [Bifrost](https://www.getmaxim.ai), an [open-source AI gateway](https://github.com/maximhq/bifrost), normalizes tool calls across providers. The loop control around these calls, such as turn limits and error handling, is covered in [what is an AI agent](https://aifordevs.org/articles/what-is-an-ai-agent).

## What is tool calling

[Tool calling](https://aifordevs.org/glossary#tool-calling) is a model returning a structured request to run a function you defined, instead of plain text. The request names the function and carries arguments that match a JSON Schema you supplied. Your code runs the function, and the next request carries the result so the model can answer or ask for another call.

Google's [function calling guide](https://aistudio.google.com/docs/function-calling) states the boundary plainly: the model does not execute the function itself. It predicts which function to call and with which arguments. Every API follows the same four steps:

1. You send the conversation plus a `tools` array. Each tool has a name, a description, and a JSON Schema for its parameters.
2. The model returns one or more calls, each with an id, a tool name, and arguments.
3. Your code validates the arguments and runs the function.
4. You send the output back, tagged with the call's id, and call the model again.

**Figure 1.** The four steps never change. Notice that only steps 2 and 4 carry provider-specific names, and that OpenAI is the one API that sends arguments as a string you must parse.

Two costs come with every tool. The description decides whether the model picks the tool at all: Anthropic's [tool definition guide](https://platform.claude.com/docs/en/agents-and-tools/tool-use/define-tools) calls detailed descriptions "by far the most important factor in tool performance." And tool names, descriptions, and schemas are billed as input tokens on each request, so fifty verbose tools take room in the [context window](https://aifordevs.org/glossary#context-window) before the user has typed anything.

## OpenAI function calling format

OpenAI's Responses API defines a tool as a flat object with `type: "function"`, a `name`, a `description`, a JSON Schema `parameters` object, and a `strict` flag. A call comes back as a `function_call` item in the response `output`, and you return the result as a `function_call_output` item with the same `call_id`.

```json title="OpenAI Responses API tool"
{
  "type": "function",
  "name": "get_weather",
  "description": "Get the current weather for a city. Returns temperature in Celsius and a short condition.",
  "parameters": {
    "type": "object",
    "properties": { "city": { "type": "string" } },
    "required": ["city"],
    "additionalProperties": false
  },
  "strict": true
}
```

The `arguments` field of a `function_call` is a JSON-encoded string, so your code parses it before use. The [Chat Completions reference](https://developers.openai.com/api/reference/resources/chat/subresources/completions/methods/create) warns that the model does not always generate valid JSON there, which is a reason to parse inside a try block and send a parse failure back as the tool result.

Strict mode is where the two OpenAI APIs differ most, as of November 23, 2026:

- In the Responses API, an omitted `strict` makes the API try to normalize the schema into strict mode, and it falls back to non-strict when it cannot. Set `strict: false` to opt out.
- In Chat Completions, requests stay non-strict by default.
- A strict schema needs `additionalProperties: false` on every object and every property listed in `required`. An optional field becomes a nullable type such as `["string", "null"]`.

Chat Completions, which most OpenAI-compatible servers copy, nests the same data differently. The call arrives in `message.tool_calls` with an `id` and a `function` object holding `name` and string `arguments`, the turn ends with `finish_reason: "tool_calls"`, and you reply with a `role: "tool"` message carrying `tool_call_id`.

## Anthropic tool use format

Anthropic calls the feature tool use, and its schema field is `input_schema` rather than `parameters`. When Claude calls a tool, the response has `stop_reason: "tool_use"` and one or more `tool_use` content blocks, each with an `id`, a `name`, and an `input` object that is already parsed JSON.

```json title="Anthropic tool_use block in the assistant turn"
{
  "type": "tool_use",
  "id": "toolu_01A09q90qw90lq917835lq9",
  "name": "get_weather",
  "input": { "location": "San Francisco, CA" }
}
```

You send the output in the next user message as a `tool_result` block whose `tool_use_id` matches the call. Results travel inside a user turn because the Messages API has only user and assistant roles. A failed tool returns a `tool_result` with `is_error: true` and a short explanation, which the model reads as input for its next attempt.

Tool names must match `^[a-zA-Z0-9_-]{1,128}$`, so a dotted name that is valid in MCP needs renaming before Claude sees it. A definition can also carry `input_examples`, an array of sample inputs that each cost about 100 to 200 input tokens, and `strict: true` for schema-valid inputs. Anthropic-hosted server tools, such as web search and code execution, run on Anthropic's side and need no handler in your code.

## Gemini function calling format

Google's current function calling docs use the Interactions API. A tool is a flat object with `type: "function"`, a `name`, a `description`, and a `parameters` schema, close in shape to OpenAI's Responses API. A call returns as a `function_call` step with an `id`, the `name`, and `arguments` as an object, and you answer with a `function_result` step that references it through `call_id`.

The `result` field of a `function_result` is a list of content blocks, and Gemini 3 and later models accept image, document, audio, and video blocks there. Tool declarations are not stored with an interaction, so the guide says to resend the same `tools` array on every request, including requests that continue from `previous_interaction_id`.

Many production integrations still call `generateContent`, which uses different names again: tools go in `functionDeclarations`, a call arrives as a `functionCall` part with an `args` map, and the answer is a function response part. That is the format most gateways target for Gemini, including Bifrost's converter described below.

## Where the three formats differ

The differences that break portable code are small, specific, and easy to list. Seven fields account for most of them, and each one turns into an `if provider ==` branch in an agent loop that talks to providers directly.

| Field | OpenAI (Responses / Chat) | Anthropic Messages | Gemini (Interactions) |
| --- | --- | --- | --- |
| Schema key | `parameters` | `input_schema` | `parameters` |
| Arguments | JSON string you parse | `input` object | `arguments` object |
| Call signal | `function_call` item / `finish_reason: "tool_calls"` | `stop_reason: "tool_use"` | `function_call` step |
| Result | `function_call_output` / `role: "tool"` | `tool_result` block in a user turn | `function_result` step |
| Result id field | `call_id` / `tool_call_id` | `tool_use_id` | `call_id` |
| Error flag on a result | None, the text carries it | `is_error: true` | No field shown in the guide |
| Schema enforcement | `strict` | `strict` | `validated` tool choice mode |

Streaming multiplies the branches, because each provider streams partial tool arguments in its own event format. A unified layer, whether a library or a gateway, earns its place at this point. The sibling article on a [unified AI API](https://aifordevs.org/articles/unified-ai-api) covers the broader case beyond tools.

## tool_choice and parallel tool calls across providers

All three APIs default to `auto`, where the model decides whether to call a tool. They differ on how to force a call, how to name one tool, and where the switch for parallel calls lives. One model-specific restriction matters more than the naming: some current Claude models refuse forced tool use outright.

| Control | OpenAI | Anthropic | Gemini |
| --- | --- | --- | --- |
| Model decides | `"auto"` (default) | `{"type": "auto"}` (default) | `auto` (default) |
| Must call a tool | `"required"` | `{"type": "any"}` | `any` |
| One named tool | `{"type": "function", "name": "..."}` | `{"type": "tool", "name": "..."}` | `allowed_tools` with mode `any` |
| No tools | `"none"` | `{"type": "none"}` | `none` |
| Limit to a subset | `allowed_tools` | Not a tool_choice mode | `allowed_tools` |
| Turn off parallel calls | `parallel_tool_calls: false` | `disable_parallel_tool_use: true` inside `tool_choice` | No switch in the guide |

As of November 23, 2026, Anthropic's [define tools page](https://platform.claude.com/docs/en/agents-and-tools/tool-use/define-tools) lists Claude Opus 5.5, Sonnet 5.5, Fable 5.2, Mythos 5.2, Fable 5.1, and Mythos 5.1 as returning a 400 error for `any` and `tool`. Manual extended thinking also blocks both modes. The suggested replacement is `auto` plus strict tool use, or [structured outputs](https://aifordevs.org/glossary#structured-outputs) when the goal is a fixed JSON shape. Code that forces a tool to extract data will fail on these models even though the same request works on OpenAI.

Parallel calls need care on the result side. Anthropic's [parallel tool use page](https://platform.claude.com/docs/en/agents-and-tools/tool-use/parallel-tool-use) requires one `tool_result` per `tool_use`, all in the next user message, placed before any text. Splitting results across messages "teaches" Claude to stop calling tools in parallel. If an earlier call fails and you skip the rest, return a `tool_result` with `is_error: true` for each skipped call anyway.

OpenAI's guide adds one limit of its own: on GPT-5 and later models, built-in tools cannot be part of a parallel batch of function calls.

## How MCP standardizes tools

The Model Context Protocol standardizes the other side of tool calling: how a tool is described and invoked, regardless of which model asks for it. An [MCP server](https://aifordevs.org/glossary#mcp-server) answers `tools/list` with tool definitions and `tools/call` with results, so a tool written once works with every MCP client. The [overview of MCP](https://aifordevs.org/articles/what-is-mcp) covers hosts, transports, and authorization.

MCP does not replace provider tool calling. The model still emits an OpenAI, Anthropic, or Gemini call, and the MCP client sits behind it. For each call, the client converts in both directions:

- **Definition, server to model.** The MCP `inputSchema` becomes `parameters` for OpenAI and Gemini, or `input_schema` for Anthropic. The `name` and `description` copy across, and the client renames any tool whose name breaks a provider's rules.
- **Call, model to server.** The model's arguments become the `arguments` object of `tools/call`, which means parsing OpenAI's string first.
- **Result, server to model.** The MCP `content` array becomes the provider's result format, and `isError: true` maps to Anthropic's `is_error` or to plain text for the others.

The [tools page of revision 2026-07-28](https://modelcontextprotocol.io/specification/2026-07-28/server/tools) sets three rules that matter at this boundary. Tool names are unique only within one server, so a client that aggregates servers should prefix names with a server identifier. Servers should return tools in a deterministic order, which keeps the tool block stable for [prompt caching](https://aifordevs.org/glossary#prompt-caching). Input validation failures come back as tool execution errors with `isError: true`, which the client should pass to the model so it can correct its arguments.

The spec also says a human should always be able to deny a tool invocation, and that clients should confirm sensitive operations and log tool usage for audit. Building a server that asks for confirmation is the subject of [build an MCP server](https://aifordevs.org/articles/build-an-mcp-server).

## How a gateway normalizes tool calls across providers

An [AI gateway](https://aifordevs.org/glossary#ai-gateway) normalizes tool calling by accepting one request format from your code, translating it into each provider's native format, and translating the response back. The agent loop is written once against one shape, and the provider changes with the model name.

[Bifrost](https://www.getmaxim.ai/llm-gateway) takes this approach for 10,000+ models across 25+ providers, with about 11 microseconds of overhead per request at 5,000 requests per second in the Bifrost team's [published benchmarks](https://www.getmaxim.ai/resources/benchmarks). All providers return responses in an [OpenAI-compatible format](https://docs.getbifrost.ai/providers/supported-providers/overview), and the [tool calling quickstart](https://docs.getbifrost.ai/quickstart/gateway/tool-calling) sends OpenAI-style tool schemas to `/v1/chat/completions` with a provider-prefixed model such as `anthropic/<model>`.

The conversion guides document what changes underneath. The [Anthropic guide](https://docs.getbifrost.ai/providers/supported-providers/anthropic) maps `function.parameters` to `input_schema`, `"required"` to `any`, and `parallel_tool_calls: false` to `disable_parallel_tool_use`. It merges consecutive `role: "tool"` messages into one user message of `tool_result` blocks, which also satisfies Anthropic's parallel-result rule. The [Gemini guide](https://docs.getbifrost.ai/providers/supported-providers/gemini) targets `generateContent`, mapping a named tool to `ANY` with `allowedFunctionNames`.

**Figure 2.** Most fields map cleanly. The hatched cells are the ones to plan around: strict mode is dropped for both providers and parallel_tool_calls is dropped for Gemini, all without an error.

Translation has limits, and the guides state them. As of November 23, 2026, `function.strict` is silently dropped for Anthropic and Gemini, so schema enforcement that OpenAI would apply does not happen on those providers. `parallel_tool_calls` is ignored for Gemini. Validate arguments against the schema in your own code before you execute anything, whatever the provider.

A gateway also gives governance a single place to live. Bifrost applies [governance](https://www.getmaxim.ai/resources/governance) and security controls, such as virtual keys, budgets, [guardrails](https://docs.getbifrost.ai/enterprise/guardrails), and audit logs, to every model and tool call that passes through it. [Bifrost Edge](https://www.getmaxim.ai/edge) extends the same governance and security to AI traffic on employee machines, and [enforces MCP server allow and deny decisions](https://docs.getbifrost.ai/edge/mcp-governance) on each device, so a tool call from a desktop app follows the same rules as one from a service.

## Running MCP tools through Bifrost

Used as an [MCP gateway](https://www.getmaxim.ai/mcp-gateway), Bifrost connects to MCP servers over STDIO, HTTP, or SSE, discovers their tools, and adds them to inference requests for any provider it routes to. By default it does not execute the resulting tool calls. They come back to your application, which approves each one and sends it to an execute endpoint.

**Figure 3.** The default path keeps a person or a policy in your app between the model's call and the tool running. Agent Mode moves only the tools on its auto-execute list inside the gateway.

The [tool execution flow](https://docs.getbifrost.ai/mcp/tool-execution) has four steps. The chat response carries `tool_calls` with `finish_reason: "tool_calls"`. Your code reviews them and posts each approved call, in the same shape as the tool call object, to `POST /v1/mcp/tool/execute`. The default response is a `role: "tool"` message with the matching `tool_call_id`, and `?format=responses` returns a `function_call_output` item instead. Tool names carry the MCP client name as a prefix, such as `filesystem_list_directory`, so two servers with a `search` tool do not collide.

[Agent Mode](https://docs.getbifrost.ai/mcp/agent-mode) adds auto-execution for tools on a `tools_to_auto_execute` list, which must be a subset of `tools_to_execute`. Auto-executable tools run in parallel inside the gateway, up to `max_agent_depth` iterations (default 10), and any other tool calls return to your application for approval. A sensible split is read-only tools on the auto list and writes behind review.

[Tool filtering](https://docs.getbifrost.ai/mcp/filtering) decides which tools a model sees at all. The available set is the intersection of the client's `tools_to_execute`, the request's `x-bf-mcp-include-tools` header, and the virtual key's `mcp_configs`, and a header can narrow the key's allow-list but never widen it. When an agent needs hundreds of tools, [Code Mode](https://docs.getbifrost.ai/mcp/code-mode) exposes four generic tools and has the model write Python that runs in a sandboxed Starlark interpreter. In the Bifrost team's test with 508 tools across 16 servers, input tokens fell 92.8 percent and all 65 tasks still passed.

The [MCP gateway resource page](https://www.getmaxim.ai/resources/mcp-gateway) covers the gateway side in more depth, and the [MCP gateway comparison](https://aifordevs.org/articles/best-mcp-gateways) ranks the options.

## Choosing an approach for portable tool calling

Call a provider's API directly when the agent uses one provider and needs its newest tool features first, such as Anthropic's server tools or Gemini's multimodal function results. Every field is available, and every format quirk belongs to your code.

Put a gateway in front when the same agent routes across two or more providers, needs failover between them, or needs one place to govern which tools each team can call. Bifrost is the gateway to evaluate first for that case, because one self-hosted service handles the OpenAI-compatible translation, MCP tool execution, and per-key tool access. Check its conversion guide for each field the agent depends on before switching providers.

Whichever path you pick, these habits keep tool calling portable:

1. Write tool descriptions of three or four sentences that say what the tool returns and when not to use it.
2. Keep tool names short and limited to letters, digits, underscores, and hyphens, so they pass every provider's naming rules.
3. Parse and validate arguments in your own code, even with strict mode on, since a gateway or provider may drop it.
4. Return errors as tool results the model can read, and never skip a result for a call the model made.
5. Do not rely on forced tool choice for extraction; use structured outputs where the model supports them.
6. Keep the active tool set small, around 10 to 20 tools, and filter per request.
7. Write shared tools as MCP servers, so any client, gateway, or [agent loop](https://aifordevs.org/glossary#agent-loop) can use them.

## Questions

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

They name the same feature. OpenAI and Google call it function calling, Anthropic calls it tool use, and tool calling has become the generic term. In each API the model returns a structured request to run a function you defined, with arguments that match a JSON Schema, and your code sends back the result. Tool calling also covers provider-hosted tools such as web search.

### Does the LLM execute the tool itself?

No, not for tools you define. The model only predicts which function to call and with which arguments. Your application runs the function and returns the output in the next request. The exception is provider-hosted tools, such as Anthropic's server tools for web search and code execution, which run on the provider's infrastructure and return results without a handler in your code.

### What does tool_choice do?

tool_choice controls whether the model may, must, or must not call a tool. All three APIs default to auto, where the model decides. OpenAI uses required to force at least one call, Anthropic and Gemini use any, and each has a form that forces one named tool. As of November 23, 2026, Claude Opus 5.5 and Sonnet 5.5 reject forced tool choice with a 400 error.

### Can a model call several tools at once?

Yes. OpenAI, Anthropic, and Gemini can all return several independent tool calls in one response, and your code can run them concurrently. OpenAI turns this off with parallel_tool_calls set to false, and Anthropic with disable_parallel_tool_use inside tool_choice. Anthropic also requires every result to come back in a single user message, or the model learns to stop calling tools in parallel.

### Is MCP the same as tool calling?

No. Tool calling is the model API feature that returns a structured call. MCP is a protocol for how tools are listed and invoked, through tools/list and tools/call, so a tool written once works with any MCP client. The model still emits a call in its provider's format, and an MCP client or gateway turns that call into a tools/call request.

### Why does tool calling code break when switching from OpenAI to Claude?

The shapes differ. Claude expects input_schema instead of parameters, returns arguments as an input object instead of a JSON string, signals a call with stop_reason tool_use, and expects results as tool_result blocks inside a user message. An adapter in your own code fixes this, or a gateway that translates OpenAI-format requests into each provider's native format.

### How many tools should you give a model?

Fewer than most teams start with. Google's Gemini guide recommends keeping the active set to 10 to 20 tools, because selection accuracy falls as the list grows, and every tool definition is billed as input tokens on each request. Filter tools per request, consolidate related operations into one tool, or use a code-execution pattern when an agent needs hundreds of tools.

## Sources

1. [OpenAI docs, Function calling (read November 23, 2026)](https://developers.openai.com/api/docs/guides/function-calling)
2. [OpenAI API reference, Create chat completion (read November 23, 2026)](https://developers.openai.com/api/reference/resources/chat/subresources/completions/methods/create)
3. [Anthropic docs, Define tools (read November 23, 2026)](https://platform.claude.com/docs/en/agents-and-tools/tool-use/define-tools)
4. [Anthropic docs, Parallel tool use (read November 23, 2026)](https://platform.claude.com/docs/en/agents-and-tools/tool-use/parallel-tool-use)
5. [Google AI Studio docs, Function calling with the Gemini API (read November 23, 2026)](https://aistudio.google.com/docs/function-calling)
6. [Model Context Protocol, Tools, revision 2026-07-28 (read November 23, 2026)](https://modelcontextprotocol.io/specification/2026-07-28/server/tools)
7. [Bifrost docs, Anthropic conversion guide (read November 23, 2026)](https://docs.getbifrost.ai/providers/supported-providers/anthropic)
8. [Bifrost docs, Google Gemini conversion guide (read November 23, 2026)](https://docs.getbifrost.ai/providers/supported-providers/gemini)
9. [Bifrost docs, Supported providers overview (read November 23, 2026)](https://docs.getbifrost.ai/providers/supported-providers/overview)
10. [Bifrost docs, Tool calling quickstart (read November 23, 2026)](https://docs.getbifrost.ai/quickstart/gateway/tool-calling)
11. [Bifrost docs, MCP overview (read November 23, 2026)](https://docs.getbifrost.ai/mcp/overview)
12. [Bifrost docs, Tool execution (read November 23, 2026)](https://docs.getbifrost.ai/mcp/tool-execution)
13. [Bifrost docs, Agent Mode (read November 23, 2026)](https://docs.getbifrost.ai/mcp/agent-mode)
14. [Bifrost docs, Tool filtering (read November 23, 2026)](https://docs.getbifrost.ai/mcp/filtering)
15. [Bifrost docs, Code Mode (read November 23, 2026)](https://docs.getbifrost.ai/mcp/code-mode)
16. [Bifrost docs, Govern MCP servers with Edge (read November 23, 2026)](https://docs.getbifrost.ai/edge/mcp-governance)
17. [Bifrost reference page for AI systems (last updated September 2026)](https://www.getmaxim.ai/llm-info)

## Cite this deep dive

AI for Devs. "Tool calling explained: OpenAI, Anthropic, Gemini, and MCP formats." Published November 24, 2026. https://aifordevs.org/articles/tool-calling

- Page: https://aifordevs.org/articles/tool-calling
- Markdown: https://aifordevs.org/articles/tool-calling.md
- Reuse: Quote or summarize with a link to this page. Terms: https://aifordevs.org/reuse
- Publisher: AI for Devs
- Published: 2026-11-24
