Function Calling

Definition: Function calling is a structured interaction in which a model identifies a predefined function and returns arguments for application code to validate and execute.
Also known as: Function call

What is function calling?

Function calling is a structured interaction in which a language model identifies a predefined function and supplies arguments for it. The application receives that structured output, validates it, runs the corresponding code if permitted, and returns the result.

Despite the name, the model usually does not directly execute the function. It generates a request that software can turn into an execution.

How function calling works

The application first provides the model with function information, usually including a name, description, and input schema. When the user asks a relevant question, the model can return a function call instead of a normal text answer.

For example, a function might be defined as getorderstatus with a required order_id. The model returns the function name and a structured order ID. Application code checks the value, authenticates the request, queries the order system, and sends the result back to the model.

The model can then explain the status or decide whether another function is required.

Function calling versus API calling

A function is a callable unit inside or behind an application. An API is an interface through which software systems communicate. A function may wrap an API request, database query, calculation, or local operation.

The model does not need to know the implementation. It only needs a clear function definition and valid schema. The application owns credentials, network behavior, retries, and error handling.

Function calling versus tool calling

The terms are often used closely, but tool calling is broader. A tool can represent a function, remote service, browser, code executor, or human interaction. Function calling emphasizes structured requests to predefined functions.

Neither term means the model has unrestricted authority. The execution layer must enforce permissions.

Common problems

Generated arguments may be syntactically valid but semantically wrong. An order ID can have the correct type while referring to another user’s order. A function may also produce an error, time out, or complete only part of the requested work.

Builders should validate data types and business rules, protect credentials, return explicit error structures, and make write operations safe to retry. Sensitive functions may require confirmation before execution.

Why it matters

Function calling creates a clean boundary between flexible language understanding and deterministic application code. The model decides what capability may help; software performs the controlled operation. See [Tool Use in AI Agents](/tool-use-in-ai-agents/) for how this pattern fits into the broader agent action loop.

Learn More

Tool Use in AI Agents
Continue with the full AIRundown guide →