Function Calling
A capability that allows LLMs to call external tools and APIs in a structured, reliable way — triggering database queries, writing ERP records, sending notifications — rather than only generating text. Function calling is the mechanism that makes AI agents operational rather than conversational.
What is Function Calling?
Function calling (also called tool use) is the ability of a language model to recognize when a task requires an action rather than a text response, and to output a structured call to an external function or API. Instead of writing "the invoice total is EUR 4,250" in plain text, the model outputs a structured instruction: post_invoice({supplier: "Acme", amount: 4250, currency: "EUR", po_ref: "PO-2024-0091"}). The calling system executes the function and returns the result to the model, which can then take the next step.
This capability transforms LLMs from text generators into operational agents. Without function calling, an LLM can describe what should happen. With function calling, it can make it happen.
How Function Calling Works
The developer defines a set of available functions with their parameters and descriptions. These are passed to the model alongside the user's request. When the model determines that a function is needed, it outputs a JSON-formatted call specifying the function name and parameter values. The application layer executes the call, captures the result, and feeds it back to the model as context for the next step.
Structured output: Function calls are machine-parseable JSON — no need to parse natural language to extract the intended action
Multi-step execution: The model can call multiple functions in sequence, using the output of one to inform the next
Error handling: If a function returns an error (record not found, validation failure), the model receives the error and can decide how to proceed
Parallel calls: Some models support calling multiple independent functions simultaneously, reducing latency in complex workflows
Function Calling in Operations
In an operational AI agent, function calling is how the AI interacts with the ERP. When processing an invoice, the agent calls a function to retrieve the matching purchase order, another to check the supplier's payment terms, another to validate the VAT number against the fiscal registry, and finally a function to post the invoice or create an exception record. Each call is logged, traceable, and reversible. The operational value is that a natural language instruction — "process this invoice" — translates into precise, auditable database operations, not just a text summary of what should be done.