encyclopedia

Function Calling (Tool Use)

Published Updated

Reviewed by Coy Robison, Founder, on

Function calling bridges language generation and software execution. When an LLM determines it needs real data (such as a customer record or open calendar slots) or needs to take an action, it emits a structured call to a function the developer has described, instead of guessing. The application runs the function and returns the result, and the model continues with that result in context. It is the technical foundation of most production AI agents, and because it lets a model act, it is also where permissions and validation matter most.

CategorySystems
Reading time7 min read

Definition

A capability that allows LLMs to invoke structured external tools or APIs mid-conversation, enabling reliable real-world actions and grounded data retrieval.

Need this applied?

We help teams go from definitions to deployed workflows—safely and fast.

Developers describe each tool with a name, a description and a parameter schema written in JSON Schema, a declarative language for the structure of JSON data. The loop has five steps: send the request with the tool definitions, receive a tool call from the model, run the function in your application, send the output back, and receive either a final answer or further tool calls.

  • • Tool schemas describe what each function does and which parameters it accepts.
  • • The model decides when, and whether, a tool is needed.
  • • Results return to the model as context for its next step.

Schema adherence and strict mode

OpenAIAnthropic

By default, a model’s tool arguments are a best effort. OpenAI’s strict mode makes function calls reliably adhere to the schema, provided every object sets additionalProperties to false and marks its fields as required; Anthropic offers a strict option on tool definitions for the same purpose. Strict mode governs the shape of the arguments, not whether the values are sensible.

Parallel and sequential tool calls

OpenAIAnthropic

Models can request several independent tool calls in one turn, or chain dependent calls, using each result to decide the next action. The loop can continue for as many calls as the task needs, which is what turns a chat model into an agent; developers can disable parallel calls when order matters.

Missing information and guessed arguments

Anthropic

When a request lacks a required parameter, some models ask for it, while others infer a plausible value; Anthropic’s documentation shows a model filling in a city the user never named. Applications should validate arguments before acting and return a clear error, or ask the user, when something is missing.

Limiting what tools can do

OWASP

A model that can call functions can call them wrongly, whether through a hallucination or a prompt injection. OWASP’s “excessive agency” guidance is to offer only the tools a task needs, give them the minimum permissions on downstream systems, require human approval for high-impact actions, and enforce authorization in those downstream systems rather than relying on the model.

Research showed early that language models could learn to use external tools through simple APIs: Toolformer (2023) taught a model to call a calculator, a question-answering system, search engines, a translator and a calendar with only a handful of demonstrations per API. Vendor APIs then standardized the pattern as function calling.

FAQ

Is function calling the same as RAG?

They are related but distinct. RAG retrieves documents before generation. Function calling is more general: the model can request any operation you expose, such as a database query, a calendar lookup or a booking, at any point in the conversation, and the model decides when a tool is needed.

Does the model run the function itself?

For tools you define, no. The model returns a structured request, and your application runs the code and sends back the result. Some providers also offer server-side tools, such as web search, that run on their own infrastructure.

How do I prevent the model from calling functions incorrectly?

Write clear tool descriptions and parameter schemas, enable strict schema adherence, validate every argument before execution, and add a human approval step for high-stakes actions such as payments or deletions.

What is the difference between function calling and an AI agent?

Function calling is the mechanism: one structured request to run one operation. An agent is a loop built on it, in which the model plans, calls tools, reads the results and decides what to do next until the task is done.

Email this summary + checklist

Get a copy of “Function Calling (Tool Use)” and an AI readiness checklist in your inbox.