How it works

Function calling is a mechanism that allows a model to indicate that an application function should be called to obtain information or perform an action. The application describes the available functions and the expected parameters. The model chooses if one of them is appropriate and can produce the arguments in structured format.

The call does not necessarily mean that the model executed the function. In general, the software that integrates the model receives the indication, validates the arguments and decides if it is authorized to execute the operation. Then, it returns the result to the model so it can respond to the user or continue the flow.

A common cycle has these steps:

  1. The application sends the conversation and the description of the available functions.
  2. The model responds with text or indicates a function and its arguments.
  3. The application validates the data and applies the permission rules.
  4. If allowed, the code executes the function and returns the result.
  5. The model uses that result to compose the final response.

Names, formats and features vary between APIs. The integrator must validate types, required fields, limits and authorization in the code itself. A structured output helps interpret the intent, but does not prove that the action is safe or correct.

Practical example

Consider an online store where a person asks: “What is the delivery time for my order?”. The application can provide a function called consultar_entrega, with parameters such as order identifier. The model identifies that it needs to consult that information and prepares the structured call.

The server should not execute the request just because the model wrote an identifier. It needs to confirm the person's identity, verify if they can access that order and check if the parameter has the expected format. Only then does it query the logistics system and return the found deadline.

With the result in hand, the model can explain the forecast in natural language. If the function fails, the application must return a controlled error and avoid the response inventing a deadline. This way, the conversational interface is connected to a real system without transferring to the model the final authority over permissions and effects.

What it's for

Function calling is used to integrate language models with APIs, databases and functions of the product itself. It can support information queries, administrative operations or automations, as long as each action has validations and adequate controls.

It is especially useful when the model needs to interact with updated data or trigger capabilities it does not have by itself. For example, checking the status of an order requires access to the company's system; the model formulates the request, while the trusted code performs the authorized query.

For operations that change data, such as canceling a reservation, prefer explicit confirmation steps and log what was requested and executed. Define minimum permissions, handle errors and prevent repeated or out of context calls. The function design is part of the product security.

Difference between function calling and tool calling

The terms are often used to describe similar patterns: the model requests that a tool or function be used, and the application coordinates the execution. Some platforms use “function calling” to emphasize functions with structured parameters; “tool calling” can also cover other tools. The terminology depends on the API, so consult the documentation of the provider used.