Function Calling
A capability that allows AI models to invoke external functions, APIs, and tools by generating structured requests, enabling them to take actions and access real-time information.
Function calling is a capability that allows AI language models to interact with external tools, APIs, and systems by generating structured requests that your application can execute. Instead of the model just producing text, it can effectively "call" functions β looking up data, performing calculations, sending emails, or querying databases.
How function calling works
- Definition: You define the functions available to the model β their names, descriptions, and parameter schemas (typically in JSON format).
- Recognition: When the user's request requires a function call, the model generates a structured JSON object specifying which function to call and what parameters to pass.
- Execution: Your application receives this structured request, calls the actual function, and returns the result to the model.
- Integration: The model incorporates the function result into its response to the user.
The model does not actually execute the function β it generates the call specification. Your application handles execution, maintaining security and control.
A practical example
User: "What is the weather in London right now?"
Without function calling: The model can only say "I do not have access to real-time weather data."
With function calling: The model generates a call to a weather API: {"function": "get_weather", "parameters": {"city": "London"}}. Your application executes the API call, returns the result (15Β°C, partly cloudy), and the model responds: "It is currently 15Β°C and partly cloudy in London."
Why function calling is transformative
Function calling bridges the gap between AI as a text generator and AI as an action taker:
- Real-time data: Models can access current information rather than relying on stale training data.
- Computation: Instead of attempting mental arithmetic (where models often err), they can call a calculator.
- System integration: Models can interact with CRMs, databases, calendars, and other business systems.
- Multi-step workflows: Models can chain multiple function calls to complete complex tasks β search for information, process it, then take action.
Provider implementations
All major AI providers support function calling:
- OpenAI: "Function calling" and "tools" API
- Anthropic (Claude): "Tool use" API
- Google (Gemini): "Function calling" API
While the terminology differs, the underlying mechanism is similar across providers.
Security considerations
Function calling introduces security considerations:
- Validation: Always validate function call parameters before execution. Do not trust model-generated parameters blindly.
- Permission scoping: Limit which functions the model can call based on the user's permissions.
- Confirmation for destructive actions: Require human confirmation before executing actions that modify data or have irreversible consequences.
- Rate limiting: Prevent the model from making excessive function calls that could overwhelm external services.
Function calling versus MCP
Function calling requires each application to define its own function integrations. MCP (Model Context Protocol) standardises these integrations, allowing any compatible model to use any compatible tool. Function calling is the underlying mechanism; MCP is the standard that makes it interoperable.
Why This Matters
Function calling is what transforms AI from a conversational tool into an operational one. Understanding this capability helps you identify opportunities to integrate AI into existing business systems and workflows, moving from "AI that talks" to "AI that does."
Related Terms
Continue learning in Practitioner
This topic is covered in our lesson: Building Your First AI Workflow
Training your team on AI? Enigmatica offers structured enterprise training built on this curriculum. Explore enterprise AI training β