P

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

Tool UseAPIAI AgentJSON Schema

FAQ

Does the model actually execute the functions?
No, the model only generates the function call as structured JSON. It is the developer's application that actually executes the function, then returns the result to the model so it can formulate its response. The model acts as a decision-maker, not an executor.
What is the difference between Function Calling and Tool Use?
Both terms essentially refer to the same mechanism. OpenAI historically uses 'function calling' while Anthropic prefers 'tool use'. The nuance is that 'tool use' sometimes encompasses a broader spectrum of tools (web search, code execution, etc.), but the underlying technical principle remains the same: the model generates a structured call that an external system executes.
Do you need to know how to code to use Function Calling?
Function Calling is primarily a feature for developers integrating LLMs via API. However, many no-code platforms (like OpenAI's custom GPTs or Make/Zapier workflows) allow configuring function calls without writing code, making this capability accessible to a wider audience.

See also

How to use this prompt

  1. Copy the prompt with the button above.
  2. Paste it into ChatGPT, Claude or your favorite AI assistant.
  3. 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

Get new prompts every week

Join our newsletter.

Function Calling: Definition and Examples | Prompt Guide