# Function calling

> Function calling is a capability that lets a language model request that the application run a defined tool, such as a database lookup, an API call or a calculation, by returning the tool's name and structured arguments instead of plain text.

Also called: tool calling, tool use, tools API, function call, tool invocation. Category: Models and training. Source: https://aibuildindex.com/glossary/function-calling

## In the index

- AI agents: median $3,600, middle half $600 to $11,720, 4,476 priced briefs (https://aibuildindex.com/skills/ai-agents)
- Custom AI agent: median $3,850, middle half $600 to $10,000, 2,831 priced briefs (https://aibuildindex.com/cost/custom-ai-agent)
- AI API integration: median $2,500, middle half $500 to $6,400, 1,993 priced briefs (https://aibuildindex.com/cost/ai-api-integration)

On its own, a language model can only produce text. Function calling, also called tool use, is how it reaches beyond that. The builder describes a set of tools to the model, such as "look up an order by number" or "book a meeting slot", and the model can respond by asking for one to be run with specific inputs. The application runs it and returns the result, and the model carries on. This is the mechanism underneath most [AI agents](https://aibuildindex.com/glossary/ai-agent) and assistants that act on real systems.

## How it works

Each tool is described with a name, a plain-language explanation of what it does and a schema for its inputs. A typical exchange runs:

1. The user asks, "Where is order 4471?"
2. The model, seeing an order-lookup tool, replies with a tool call: the tool name and the order number as an argument.
3. The application validates the request, queries the order system and sends the result back to the model.
4. The model writes the answer for the user, using the real order status.

Key points for buyers:

- **The model never runs anything itself.** The application decides whether to execute a call, which is where permissions and safety checks belong.
- **Descriptions matter.** The model chooses tools based on how they are described, so clear names and explanations reduce wrong calls.
- **Calls can chain.** Agents may call several tools in sequence, using each result to decide the next step, as in an [agentic workflow](https://aibuildindex.com/glossary/agentic-workflow).

Provider APIs differ in detail but follow this pattern. The [Model Context Protocol](https://aibuildindex.com/glossary/model-context-protocol) standardises how tools are offered to AI applications so the same tools can be reused across them.

## What it means for cost

Function calling turns an AI build into an integration project. Each tool needs a working connection to an existing system, input checks, sensible error messages, permission rules and tests, which is ordinary [API integration](https://aibuildindex.com/glossary/api-integration) work plus testing of how the model chooses tools. The number of tools and how many of them change data are good predictors of build size.

Running costs rise too, because each tool round trip is another model request, and tool descriptions are sent with every call. Ask a builder which tools are read-only, which actions need user confirmation, and how wrong or failed calls are caught and logged.

## Common questions

### Can the model call any function it wants?

No. It can only request the tools the builder has described, and the application decides whether to run each request. Good builds check every call against the user's permissions before executing it.

### What happens if the model calls the wrong tool?

The application should validate inputs and return a clear error, which lets the model correct itself. For actions with real consequences, such as payments or deletions, builds usually ask the user to confirm first.

### Is function calling the same as an AI agent?

Function calling is a building block. An agent is a system that uses it repeatedly, deciding which tools to call and in what order to reach a goal.

## Related terms

- [AI agent](https://aibuildindex.com/glossary/ai-agent): An AI agent is software built around a language model that can plan steps, call tools such as APIs, databases or a browser, look at the results and keep going until it completes a task, rather than only replying to a single message.
- [Structured output](https://aibuildindex.com/glossary/structured-output): Structured output is a way of making an AI model return its answer in a fixed, machine-readable format, typically JSON matching a defined schema, so that other software can use the result without guessing at free text.
- [Model Context Protocol (MCP)](https://aibuildindex.com/glossary/model-context-protocol): The Model Context Protocol is an open standard that lets AI assistants and agents connect to external tools and data sources, such as files, databases and business apps, through a common interface instead of a custom integration for each one.
- [API integration](https://aibuildindex.com/glossary/api-integration): API integration is the work of connecting two or more software systems through their APIs so that data and actions flow between them automatically, for example syncing orders to accounting or sending CRM records to an AI model.
- [Agentic workflow](https://aibuildindex.com/glossary/agentic-workflow): An agentic workflow is an automated process in which a language model makes some of the decisions, such as choosing the next step, calling a tool or judging whether output is good enough, inside a structure that the builder defines in advance.
