Function Calling
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
Frequently Asked Questions
From the Blog
Function Calling and Tool Use in LLMs
Function calling lets a language model request real actions like API calls or database lookups, turning a text generator into a system that gets things done.
Read More AI & TechnologyWhat Are Function Calling and Tool Use in LLMs?
Function calling lets an LLM request that your code run a defined function, returning structured arguments so the model can fetch data or take actions reliably.
Read More AI & TechnologyWhat Is a Loss Function in Machine Learning
A loss function is the formula that measures how wrong a model's predictions are, giving training a single number to minimize so the model can improve.
Read More AI & TechnologyHow to Build a Chatbot With an LLM API
Build a chatbot by calling an LLM API with a system prompt and message history, streaming responses, managing context, and adding tools for real capabilities.
Read More