Quick answer

Function calling (also called tool calling) is the mechanism that lets an AI model trigger real code — checking the weather, searching a database, sending an email — instead of only generating text describing what it would do. You give the model a list of available functions with descriptions of what each does and what inputs it needs; the model decides when to use one and outputs a structured request; your code actually runs it and feeds the result back. Function calling is the plumbing; an "AI agent" is what you get when you wire many function calls together with a loop that lets the model decide what to call next based on what happened last.

Before function calling existed, an AI could only ever produce text — useful for writing, but useless for actually checking today's stock price, booking a meeting, or querying a live database. Function calling is the bridge that turns a language model into something that can act on the real world, mediated by code you control.

How it works, step by step

  • You describe available functions to the model (name, purpose, expected inputs) in the request
  • The model decides, based on the conversation, whether calling one would help — and if so, which one and with what arguments
  • The model outputs a structured request (not free text) specifying the function name and arguments
  • Your application code actually executes that function — the model never runs code itself
  • The result is fed back to the model, which uses it to write its final answer

Function calling vs. an AI agent

A single function call is one action. An AI agent is what happens when you put that inside a loop: call a function, look at the result, decide the next step, call another function, repeat — often dozens of times — until the model decides the task is done. Function calling is the building block; agentic behaviour is what emerges from chaining many calls together with the model steering each next step.

The model never executes anything itself — it only requests an action. Your code stays in control of what actually happens, which is exactly where guardrails and permission limits get enforced.

Why it matters

Function calling (often standardised now via protocols like MCP) is the reason AI products in 2026 can check your calendar, query your company's internal systems, or control a browser — capabilities that simply did not exist when models could only output text.

Bottom line

Function calling is the unglamorous mechanical piece underneath almost every AI agent you've heard of. Understanding it demystifies a lot of "how does the AI actually do that" — the answer, almost always, is that it asked your code to do it and read back the result.