When ChatGPT checks today’s weather or Claude writes and runs a snippet of Python to answer a math question, the model isn’t doing that itself. It’s using function calling — also called tool use — a way for an AI model to ask an application to run a specific action, then use the result to finish its answer.
How Function Calling Works
A large language model only produces text; it can’t reach the internet, query a database, or run code on its own. Function calling gives it a structured way to ask for help. A developer building an app first describes the available functions to the model: a name, a plain-language description of what each one does, and the parameters it needs — for example, a get_weather function that takes a location.
When a user’s request needs one of those functions, the model doesn’t answer directly. Instead, it returns a structured request naming the function and the arguments to use, such as get_weather(location="Tbilisi"). The application, not the model, then actually runs that function, fetches the real data, and sends the result back into the conversation. Only then does the model write its final answer, now grounded in real information instead of a guess. For a multi-step task, this request-run-respond loop can repeat several times before the model gives its final reply.
Why AI Companies Built This
Language models are trained on a fixed snapshot of text, so left alone they can only work from what they memorized during training — they can hallucinate a stock price, miscount, or simply not know something that happened after their knowledge cutoff. Function calling closes that gap by connecting the model to a live API, a calculator, a company database, or any other system a developer wires up, without the user ever leaving the chat.
It’s also the basic building block behind AI agents. A single function call answers one question; an agent is a model that keeps calling functions — search, then read a file, then send a message — one after another, deciding each next step itself, to carry out a task with many parts. Our explainer on what AI agents actually do goes into how that loop gets put to work.
Where You Already Encounter It
Tool use runs quietly behind many everyday AI features: a chatbot that searches the web mid-answer and cites its sources is calling a search function; one that writes and executes code to plot a chart is calling a code-execution tool; a coding assistant that edits a file on your behalf is calling a file-editing tool. Each provider ships its own set of built-in tools this way.
As the number of tools an AI app needs has grown, the industry has also standardized how they’re described and connected, most notably through the Model Context Protocol — a common format that lets one “tool server” work with many different AI apps instead of every developer writing custom integration code for every model.
Client-Side vs. Server-Side Tools
Not every tool runs in the same place. With client-side tools, the developer’s own application executes the function — this is the case for a custom get_weather call or an internal database lookup — which means sensitive logic and credentials never leave the developer’s servers. With server-side tools, the AI provider runs the action directly on its own infrastructure, such as a built-in web search or code sandbox, and simply returns the result — simpler to set up, but it gives the developer less control over exactly how the action runs.
Limits and Risks
Function calling doesn’t guarantee correctness. A model can still pick the wrong tool, invent a plausible-looking but wrong argument, or call a tool when it didn’t need to. Because the model only decides what to call, not whether it’s safe to run, well-built applications validate arguments before executing a function and require a human to approve any action that can’t be undone, such as sending money or deleting data.
Getting Started
Function calling is a developer feature rather than something you toggle in a chat window, so using it means building against an AI provider’s API. OpenAI’s function calling guide is a widely used starting point that walks through defining a function schema and handling the model’s response step by step; Anthropic and Google publish equivalent guides for Claude and Gemini.