AI Models & Companies · AI Developer Tools and APIs
What is function calling or tool use in an AI API
Function calling lets a developer describe specific functions an AI model can request to use — like checking a database or calling another service — with the model deciding when to invoke one and the developer's own code actually executing it and returning the result.
Key takeaways
- Function calling lets a developer define specific actions the model can request, described with a name and expected inputs.
- The model itself doesn't execute the function directly — it requests that a specific function be called, and the developer's own code performs the actual execution.
- This is the mechanism underlying most AI agents' ability to take real actions rather than just generate text.
- The model decides when a function call is appropriate based on the conversation, the same prediction-based process used to generate any other output.
What Function Calling Actually Enables
Function calling lets a developer describe specific available actions — checking a database, looking up current weather, calling another internal service — to an AI model, giving it a structured way to request that one of those actions happen as part of responding to a conversation.
Who Actually Executes the Function
It’s important to understand that the model itself doesn’t execute anything directly — when it decides a function call is appropriate, it outputs a structured request specifying which function and what inputs, and the developer’s own code is what actually runs that function and returns a result back to the model.
Why This Is the Foundation of Agent Behavior
This mechanism is the underlying foundation of most AI agents’ ability to take real actions rather than only generate text — an agent ‘using a tool’ is, under the hood, generally this same function-calling pattern: the model requesting an action, and surrounding code carrying it out.
How the Model Decides When to Use It
The model decides when calling a function is appropriate the same fundamental way it generates any other output — predicting, based on the conversation and the available function descriptions, that requesting a specific function is the most likely useful next step, not through separate fixed logic distinct from how it generates text.
Bottom Line
Function calling gives a model a structured way to request a specific action be taken, with the developer’s own code responsible for actually executing it — this is the core mechanism that underlies most AI agents’ ability to interact with the world beyond generating text.
Go deeper
Related questions
- What Is the Difference Between Using an AI Chat App and Calling Its API Directly?
- Why Do AI APIs Sometimes Return Different Output Than the Same Prompt in a Chat App?
- What Is an AI API and How Do Developers Use It?
- What Is a System Prompt in the Context of an API Integration?
- How Do Developers Handle an AI API Going Down or Being Slow?
- What Does 'Rate Limiting' Mean for an AI API?
Sources
- [1]OpenAI API documentation — OpenAI
- [2]Anthropic API documentation — Anthropic
Written by Editorial Team
Last updated August 7, 2026
Get one well-sourced answer a week
No spam. Unsubscribe anytime.