Zubnet AIAprenderWiki › Function Calling
Using AI

Function Calling

Tool Calling, Tool Use API
Una forma estructurada para los modelos de IA de solicitar la ejecución de funciones externas durante una conversación. Defines funciones con nombres, descripciones y esquemas de parámetros. Cuando el modelo determina que una función ayudaría a responder una consulta, produce una llamada a función estructurada (con argumentos) en vez de texto. Tu código ejecuta la función y devuelve el resultado para que el modelo lo incorpore.

Por qué importa

El function calling es lo que convierte un chatbot en un agente. Sin él, un modelo solo puede generar texto. Con él, un modelo puede buscar en bases de datos, llamar APIs, correr cálculos, agendar citas, enviar correos — cualquier cosa que puedas exponer como función. Es el mecanismo detrás de cada asistente de IA que realmente hace cosas en lugar de solo hablar de ellas.

Deep Dive

The API flow: (1) you send your prompt plus function definitions (JSON schemas describing each function's name, description, and parameters), (2) the model decides whether to call a function and which one, (3) it outputs a structured function call with specific arguments, (4) your code executes the function and returns the result, (5) the model incorporates the result into its response. Some models can call multiple functions in sequence or in parallel.

Function Calling vs. MCP

Function calling is the model-level primitive: the model outputs structured tool calls. MCP (Model Context Protocol) is a higher-level protocol that standardizes how tools are discovered, described, and connected. Think of function calling as the instruction set and MCP as the operating system — MCP uses function calling underneath but adds tool discovery, authentication, and standardization across providers.

Reliability

Function calling is more reliable than asking a model to output function calls as text (which requires parsing and is error-prone). Providers implement function calling by constraining the model's output to valid function calls matching your schema — similar to structured output. But the model can still choose wrong functions, hallucinate parameter values, or call functions when it shouldn't. Robust applications include validation, error handling, and human-in-the-loop confirmation for high-stakes operations.

Conceptos relacionados

← Todos los términos
← Foundation Model GAN →