100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
AI Fundamentals

Function Calling

IntermediateConcept2.9K learners

Function calling is a large language model capability that lets a model produce structured, machine-readable requests to invoke external functions or APIs with specific arguments, enabling it to take actions or retrieve real-time…

Definition

Function calling is a large language model capability that lets a model produce structured, machine-readable requests to invoke external functions or APIs with specific arguments, enabling it to take actions or retrieve real-time information beyond its own training data.

Overview

On its own, a language model can only generate text based on patterns learned during training, with no ability to query a live database, call an API, or perform precise calculations it wasn't trained to do reliably. Function calling addresses this by letting a developer describe a set of available functions — their names, purposes, and expected parameters, typically as a JSON schema — as part of a request to the model. When the model determines that calling one of these functions would help answer the user's request, it outputs a structured object specifying which function to call and with what arguments, rather than free-form text; the calling application then executes that function and can feed the result back to the model to incorporate into its final response. This pattern underlies most modern "tool use" and agentic AI systems: a coding assistant calling a function to read a file, a customer support bot calling a function to look up an order status, or a research agent calling a function to run a web search all rely on function calling as the mechanism connecting the model's language understanding to real-world actions and data. Because the model's job is limited to deciding when and how to call a function — not to executing it — function calling keeps a clear boundary between the model's reasoning and the application's actual capabilities and permissions, which developers control by choosing which functions to expose. Major model providers, including Anthropic, OpenAI, and Google, support function calling (sometimes called "tool use") through their APIs with broadly similar mechanics, and it forms the technical foundation that protocols like Model Context Protocol build on to standardize how tools are described and discovered across applications. Function calling is also closely related to structured outputs, since both rely on getting a model to produce reliably parseable, schema-conforming responses rather than freeform prose.

Key Concepts

  • Lets a model request calls to developer-defined external functions or APIs
  • Model outputs structured, machine-readable calls rather than free-form text
  • Developer defines available functions via a schema describing name, purpose, and parameters
  • Calling application executes the function and can return results to the model
  • Underpins most modern agentic and tool-using AI systems
  • Keeps a clear separation between model reasoning and actual system capabilities
  • Supported with broadly similar mechanics across Anthropic, OpenAI, and Google APIs
  • Forms the technical foundation that protocols like MCP build on

Use Cases

Letting an AI assistant query live data, such as weather, stock prices, or order status
Building agents that can search the web, read files, or call internal company APIs
Performing precise calculations or database queries a model can't do reliably itself
Powering coding assistants that read, edit, and run code via defined tool functions
Enabling multi-step agentic workflows that chain several tool calls together
Integrating LLMs with existing business systems like CRMs or ticketing platforms

Frequently Asked Questions

From the Blog