Indexly
AI & LLMsUpdated May 6, 2026

Function calling / tool use

Definition

Function calling, also called tool use, is an AI capability that lets a model invoke external functions, APIs, and services to accomplish tasks beyond text generation. The developer describes available tools and their inputs; the model decides when to call one, emits structured arguments, receives the result, and uses it to continue. This connects language models to live data, code execution, and real-world actions.

How it works

With function calling, you give the model a set of tool definitions — each with a name, a description, and a schema for its inputs. When a request would benefit from a tool, the model returns a structured call naming the function and its arguments instead of plain text.

Your application runs that function — querying a database, hitting an API, executing code — and returns the result to the model. The model then incorporates the result into its response or decides to call another tool. This request-act-observe cycle can repeat across many steps.

Key properties make tool use reliable:

  • Structured arguments — the model emits validated, schema-shaped inputs, not free text to be parsed.

  • Model-decided invocation — the model chooses whether and which tool to call based on the request.

  • Composability — multiple tools can be chained, which is the foundation of agentic workflows.

Because the model only proposes calls and your code executes them, you retain control over what actions are actually permitted.

Why it matters

A language model on its own is limited to what it learned during training and what is in its prompt. Function calling breaks that boundary: the model can fetch current data, perform precise calculations, search the web, and take actions in external systems. This turns a text generator into a system that can do things.

Tool use is the core mechanism behind AI agents. Planning, browsing, and multi-step task completion all run on top of function calling, and frameworks plus standards like the Model Context Protocol standardize how tools are exposed to models.

It also supports grounding. By calling a search or retrieval tool, a model can anchor answers in live, citable sources rather than relying only on parametric memory — directly improving accuracy and the quality of citations in AI search.

Frequently asked questions

What is the difference between function calling and tool use?

The terms are largely interchangeable. Both describe a model invoking external functions, APIs, or services with structured arguments to accomplish a task. "Tool use" is the broader phrasing; "function calling" emphasizes the structured-call mechanism providers expose.

Does the model actually run the function?

No. The model proposes a call with a name and structured arguments, but your application executes the function and returns the result. This keeps execution and permissions under your control while letting the model decide when a tool is needed.

How does function calling relate to AI agents?

Function calling is the foundation of agents. Planning, browsing, code execution, and multi-step task completion are all built by chaining tool calls, with the model observing each result and deciding what to do next.

How does tool use improve answer accuracy?

By calling search, retrieval, or calculation tools, a model can pull current, factual data instead of relying on memory alone. This grounds responses in citable sources and reduces hallucinations, which matters directly for being accurately cited in AI search.

Agentic workflows

Agentic workflows are AI architectures in which a model autonomously plans, calls tools, browses the web, executes code, and completes multi-step tasks with limited human input. Rather than producing a single answer, the system loops — observing results, revising its plan, and acting again — marking the shift from AI chat to AI work that carries out goals on a user's behalf.

AI agent

An AI agent is a software system that uses a large language model (typically GPT-4o, Claude 3.5 / 4 Sonnet, Gemini 2.5, or open-source equivalents) to plan, decide, and act over multiple steps to complete a goal — calling tools, retrieving data, and producing outputs without step-by-step human supervision. Agents are the working surface of agentic AI in 2026.

AI agent frameworks

AI agent frameworks are software libraries and platforms for building autonomous agents that plan, call tools, maintain memory, and complete multi-step tasks with language models. They provide the scaffolding — control loops, tool integrations, state management, and orchestration — so developers can assemble agents without rebuilding the agentic plumbing for every project. Examples include LangChain, LangGraph, CrewAI, and the OpenAI Agents SDK.

Model Context Protocol (MCP)

The Model Context Protocol (MCP) is an open standard, introduced by Anthropic, that defines a universal way for AI models to connect with external tools, data sources, and services. Instead of building custom integrations for each app, developers expose capabilities through MCP servers that any MCP-compatible client can use — standardizing how agents access context and take actions, much like a common port for AI connectivity.

Retrieval-augmented generation (RAG)

Retrieval-augmented generation (RAG) is an AI architecture that gives a large language model real-time access to external documents at query time — retrieving relevant passages from a vector database or search index and inserting them into the model's context before it generates a response. RAG is the foundation of modern AI search and the most effective technique for reducing hallucination.

AI grounding

AI grounding is the practice of anchoring an LLM's response in retrieved, citable sources at inference time — instead of letting the model rely solely on its training memory. Grounding is what separates a hallucination-prone chatbot from a search-grade AI assistant like Perplexity, Google AI Overviews, Bing Chat, or retrieval-augmented ChatGPT.