Zubnet AIApprendreWiki › Function Calling
Using AI

Function Calling

Tool Calling, Tool Use API
Une façon structurée pour les modèles d'IA de demander l'exécution de fonctions externes pendant une conversation. Tu définis des fonctions avec des noms, des descriptions et des schémas de paramètres. Quand le modèle détermine qu'une fonction aiderait à répondre à une requête, il produit un appel de fonction structuré (avec des arguments) au lieu de texte. Ton code exécute la fonction et retourne le résultat pour que le modèle l'incorpore.

Pourquoi c'est important

Le function calling est ce qui transforme un chatbot en agent. Sans lui, un modèle ne peut que générer du texte. Avec lui, un modèle peut chercher dans des bases de données, appeler des API, lancer des calculs, prendre des rendez-vous, envoyer des emails — n'importe quoi que tu peux exposer comme fonction. C'est le mécanisme derrière chaque assistant IA qui fait vraiment des choses plutôt que juste en parler.

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.

Concepts liés

← Tous les termes
← Foundation Model GAN →