Function Calling
Also known as: Function Call, Tool Calling API
Definition
An API feature that allows LLMs to output structured function invocations rather than (or in addition to) natural language. The model is given function definitions (name, parameters, descriptions), and when appropriate, outputs a function call with arguments. The application executes the function and can feed results back to the model. This is the technical mechanism enabling tool use.
What this is NOT
- Not the functions themselves (function calling is the interface for invoking them)
- Not agent behavior (function calling is a mechanism; agents use it)
- Not prompt engineering (function calling is API-level, not prompt-level)
Alternative Interpretations
Different communities use this term differently:
openai
The `functions` or `tools` parameter in the Chat Completions API that lets developers define callable functions. The model outputs a `function_call` or `tool_calls` object with the function name and JSON arguments.
Sources: OpenAI Function Calling documentation
anthropic
The `tools` parameter in the Messages API. Anthropic calls this "tool use" rather than "function calling," but the mechanism is similar—define tools, model outputs tool invocations.
Sources: Anthropic Tool Use documentation
Examples
- OpenAI API with tools parameter defining a get_weather function
- Claude outputting a tool_use block to call a search function
- Model outputting parallel tool calls to fetch multiple pieces of data
- Function call with complex nested JSON arguments
Counterexamples
Things that might seem like Function Calling but are not:
- Prompting a model to output JSON and parsing it manually
- A hardcoded API call not decided by the model
- Model describing what function should be called in natural language
Relations
- requires tool-use (Function calling enables tool use)
- requires tool-definition (Functions must be defined for the model)
- produces tool-result (Function executions produce results)
- overlapsWith structured-output (Function calls are a form of structured output)
Implementations
Tools and frameworks that implement this concept:
- Claude 3 primary
- Gemini primary
- Google Gemini secondary
- GPT-4 primary
- GPT-4 Turbo primary
- GPT-4o primary
- Instructor secondary
- Mistral AI secondary
- Mistral Large primary
- OpenAI primary