Function Calling
A capability that lets a language model request execution of predefined functions or tools by outputting structured arguments, enabling AI to take real actions.
What Is Function Calling?
Function calling (also called tool use) is the mechanism by which a language model connects to the outside world. The developer describes a set of available functions — their names, descriptions, and parameter schemas — and the model, when appropriate, responds not with prose but with a structured request to call one of those functions with specific arguments. The application executes the function, returns the result to the model, and the model continues, now informed by real data.
For example, given a function get_weather(city), if a user asks "What is the weather in Tokyo?", the model outputs a structured call like {"name": "get_weather", "arguments": {"city": "Tokyo"}}. The application runs the actual weather API and feeds the result back. This bridges the gap between the model's frozen training knowledge and live, dynamic, or private data — and it is the core building block of AI agents.
Why It Matters
Function calling transforms a language model from a text generator into an action-taking system. It is the foundation of agentic AI, retrieval pipelines, and any application where the model must fetch live data, perform calculations, or trigger operations in other software. Without it, models can only describe actions; with it, they can reliably orchestrate real tools through a structured, parseable interface.
Real-World Examples
Live Data Lookup
A travel assistant calls a flights API through function calling to return real prices instead of guessing from training data.
Database Query
A support bot calls a get_order_status(order_id) function to fetch a customer's real order details and answer accurately.
Common Use Cases
AI Agents
Give agents a toolbox of functions — search, code execution, API calls — that they invoke autonomously to complete tasks.
Live Data Access
Connect models to real-time information like prices, inventory, or weather that is not in training data.
Structured Workflows
Reliably extract structured arguments and trigger downstream business logic from natural language.
Frequently Asked Questions
What is function calling in LLMs?
Function calling is a feature where a model, instead of replying in plain text, outputs a structured request to run a developer-defined function with specific arguments. The application executes the function and returns the result, letting the model use real tools and live data.
What is the difference between function calling and MCP?
Function calling is a model-level feature for requesting a single tool execution. MCP (Model Context Protocol) is a transport-layer standard that defines how an AI host discovers and connects to external tool providers. MCP can sit on top of function calling to make tools reusable across many models and apps.
How does function calling work step by step?
You define functions with names, descriptions, and parameter schemas. The model decides when to call one and outputs structured arguments. Your code runs the function, returns the output to the model, and the model uses that result to produce its final answer or call another function.
Is function calling the same as tool use?
The terms are largely interchangeable. 'Function calling' is OpenAI's original name; 'tool use' is the more general term, used by Anthropic and others. Both describe a model requesting execution of external capabilities through structured output.
What models support function calling?
All major frontier models support it, including OpenAI GPT-4o, Anthropic Claude, Google Gemini, and many open-weight models like Llama 3 and Qwen. The exact request format varies slightly between providers.
Can a model call multiple functions at once?
Yes. Modern models support parallel function calling — issuing several tool calls in a single turn — and multi-step sequences where the result of one call informs the next. This chaining is what makes agentic behaviour possible.