Function Calling: Definition and Examples
Function Calling is a capability of language models (LLMs) that allows them to identify when to call an external function and generate the structured arguments needed to execute it.
Full definition
Function Calling is a mechanism that allows language models to interact with external systems by generating structured function calls. Rather than simply producing text, the model can decide that a concrete action is necessary—such as querying a database, consulting a weather API, or performing a calculation—and produce a JSON object precisely describing the function to call and its parameters.
Concretely, the developer defines a set of available functions (with their name, description, and parameter schema) in the request sent to the model. When the user asks a question that requires one of these functions, the model does not respond directly: it returns a structured function call that the application can execute. The execution result is then returned to the model, which formulates a final response in natural language.
This approach solves a fundamental limitation of LLMs: their inability to access real-time data or perform actions in the real world. Thanks to Function Calling, a chatbot can book a flight, an assistant can check your calendar, or an agent can modify a file. The model acts as an intelligent router that understands the user's intention and translates it into concrete actions.
Function Calling is at the heart of the autonomous AI agent trend. It is the fundamental building block that transforms a simple text generator into a system capable of acting, observing results, and iterating. Major providers (OpenAI, Anthropic, Google) all offer this feature, each with its own implementation (tool use at Anthropic, function calling at OpenAI, etc.).
Etymology
The term combines 'function' (in the computing sense of an executable code block) and 'calling' (the action of triggering that function). It originates from classical programming vocabulary where a 'function call' refers to invoking a routine. Its adoption in the AI context dates from June 2023 when OpenAI introduced this capability in the GPT API, making the concept accessible to the general public.
Concrete examples
E-commerce assistant consulting real-time stock
Is the Nike Air Max 90 available in size 43?
Technical support agent creating a ticket automatically
My printer stopped working after the update, can you open a ticket with IT?
Personal assistant managing a calendar via API
Reschedule my meeting from 2pm to 3:30pm and notify the participants by email.
Practical usage
In prompt engineering, Function Calling is leveraged by defining clear and precise function descriptions in the schema provided to the model. The quality of the descriptions and parameter names directly influences the model's ability to choose the correct function and generate the right arguments. It is recommended to limit the number of exposed functions to only those strictly necessary and to provide examples in the descriptions to guide the model.
Related concepts
FAQ
Does the model actually execute the functions?
What is the difference between Function Calling and Tool Use?
Do you need to know how to code to use Function Calling?
See also
How to use this prompt
- Copy the prompt with the button above.
- Paste it into ChatGPT, Claude or your favorite AI assistant.
- Replace the bracketed variables with your details, then refine the result.
About Prompt Guide
Prompt Guide is a free library of 2500+ ready-to-use prompts for ChatGPT, Claude and other AIs, with guides to learn prompting and tools to build and optimize your own prompts.
More definitions
Function Grounding: Definition and Examples
Function Grounding is a technique that anchors an AI model's responses in executable functions or tools, allowing it to interact with systems
GDPR AI: Definition and Examples
GDPR AI refers to the application of the General Data Protection Regulation to artificial intelligence systems, governing the collection, processing, and use of personal data by AI algorithms and models.
Gemini Gem: Definition and Creation (Google)
Understand Google's Gemini Gems: preconfigured Gemini assistants. Creation, Google Workspace integration, comparison with Custom GPT and Claude Skills.
Gemini Pro: Definition and Examples
Gemini Pro is a multimodal language model developed by Google DeepMind, designed to handle complex tasks of reasoning, text generation,
Grounding: Definition and Examples
Grounding (anchoring) is a technique that involves providing the AI model with factual data, documents, or concrete context so that its responses
Grouped Query Attention: Definition and Examples
Attention mechanism that groups multiple query heads to share the same keys and values, thereby reducing memory and computational cost during inference.
Get new prompts every week
Join our newsletter.