GlossaryFunction Calling
Function Calling
Function calling is the mechanism that lets a large language model (LLM) request a specific, structured operation in an external system instead of simply generating text.
Function calling is the mechanism that lets a large language model (LLM) request a specific, structured operation in an external system instead of simply generating text. When a model decides it needs live data or must change a record, it outputs a JSON object describing which function to run and what arguments to pass. An orchestration layer executes that function, returns the result, and the model incorporates it into its response. This is the bridge between language understanding and real-world action.
What is function calling?
In standard use, an LLM receives a prompt and returns natural-language text. Function calling adds a second output mode. Alongside its text response, the model can emit a structured request, typically a JSON object, that names a function and supplies its arguments. The model itself never executes code. It signals intent; an external runtime handles execution.
A simplified sequence:
- The developer registers one or more function definitions (name, description, parameter schema) with the model at inference time.
- The user sends a message. The model reasons over the prompt and the available functions.
- If the model determines a function would help, it returns a function-call object instead of, or alongside, plain text.
- The application executes the function against the relevant system (a database, an API, a payment processor).
- The function's return value is passed back to the model as a new message.
- The model generates its final response, now informed by real data or the confirmation that an action was taken.
The model is selecting a tool from a menu and filling in the order form. The kitchen (your application code) does the cooking.
Why function calling matters
Without function calling, an LLM can only describe what it would do. It can draft a refund policy explanation, but it cannot process the refund. It can suggest checking an order's status, but it cannot look it up. Function calling closes that gap.
Three capabilities become possible once a model can call functions:
- Data retrieval. The model queries a live system (a CRM, an order management platform, a knowledge base API) and grounds its answer in current facts rather than training-data memory.
- Write operations. The model triggers state changes: updating an address, issuing a credit, canceling a subscription, booking a meeting.
- Multi-step reasoning. The model chains several function calls in sequence, using the output of one to inform the input of the next. A customer asks to swap a shirt for a different size. The model checks inventory, confirms the variant is available, initiates the exchange, and confirms the new delivery date, all within a single conversation.
This is the technical foundation of what the industry calls "agentic AI." An AI agent is a system that perceives a goal, reasons about the steps required, and takes actions to achieve it. Function calling is how the "takes actions" part works at the model layer.
How function calling works under the hood
Function definitions
Before the model can call anything, it needs to know what is available. Function definitions are passed as part of the system prompt or API request. Each definition includes:
- Name. A short identifier like `get_order_status` or `process_refund`.
- Description. A natural-language explanation of what the function does and when it should be used. The model relies on this text to decide whether a function is relevant.
- Parameters. A JSON Schema object describing the expected inputs: their names, types, whether they are required, and any constraints.
The quality of these descriptions directly affects reliability. A vague description produces unpredictable invocations. A precise description with examples produces consistent ones.
Model decision-making
When a user message arrives, the model evaluates whether any registered function would help answer it. This decision is probabilistic, not rule-based. The model weighs the user's intent against each function's description and decides:
- No function needed. The model answers from its own knowledge.
- One function needed. The model emits a single function-call object.
- Multiple functions needed. Some implementations support parallel function calling (invoking several functions in one turn) or sequential calling (one call, then another based on the result).
The model does not "know" it is calling a function in the way a programmer does. It has learned, through training, that emitting a correctly structured JSON object in the right context leads to useful completions. The structured output format is enforced by the API layer.
Execution and return
The application receives the function-call object, validates it, executes the operation, and returns the result as a new message in the conversation. The model then generates a response that incorporates the returned data. If the function fails (an invalid order ID, a network timeout), the application returns an error message, and the model can explain the issue or ask the user for clarification.
Security lives in this execution layer. The model proposes; the application disposes. Parameter validation, authentication, rate limiting, and authorization checks all happen in application code, not in the model.
Function calling vs. tool use vs. plugins
These terms overlap, and vendors use them inconsistently.
| Term | What it typically means |
|---|---|
| Function calling | The model outputs a structured request to invoke a specific function. The original and most precise term. |
| Tool use | A broader label. Any mechanism that lets a model interact with external capabilities: functions, APIs, code interpreters, search engines. Some providers (Anthropic, for example) use "tool use" as their official API terminology for the same underlying mechanism as function calling. |
| Plugins | A packaged collection of tools with a manifest, authentication, and a hosted endpoint. OpenAI popularized the term in 2023 with ChatGPT Plugins, though the architecture underneath was function calling. |
| MCP (Model Context Protocol) | An open standard for connecting AI models to external data sources and tools through a unified protocol. MCP servers expose capabilities that an MCP client (the AI application) can discover and invoke. |
For most practical purposes, function calling and tool use describe the same mechanism at the model layer. The differences are in packaging and ecosystem conventions.
Function calling in AI agents for customer service
In customer service, function calling is what separates an AI agent that resolves problems from a chatbot that describes solutions. When a customer says "I need to return this jacket," an agent without function calling can explain the return policy. An agent with function calling can look up the order, check eligibility, generate a return label, and confirm the refund amount, all in the same conversation.
The pattern in production typically involves:
- Data connectors that give the model read access to external systems (order management, CRM, billing, inventory).
- Action functions that let the model write to those systems (issue refund, update address, cancel order, create ticket).
- Procedures or workflows that govern when and how the model should use these functions, including guardrails, approval checkpoints, and escalation rules.
Fin AI Agent uses this architecture to handle complex, multi-step queries across customer service, sales, and ecommerce. When a Shopify merchant connects their store, Fin gains access to order data, product catalogs, and store APIs through data connectors. It can then check order status, process returns, and recommend products by calling the appropriate functions as the conversation requires. Procedures combine natural-language instructions with deterministic controls, so teams define exactly when Fin should call a function, what validation it should perform, and when it should escalate to a human instead.
This is the practical difference between retrieval-augmented generation (where the model reads external data to generate a better answer) and agentic function calling (where the model reads data, reasons about it, and writes back to external systems to complete a task). Both use function calling. The distinction is whether the model is reading or acting.
Challenges and best practices
Reliability
Models do not always select the right function or fill in the correct arguments. A customer asking about "my last order" might trigger a function call with a missing order ID. Defensive design means:
- Writing function descriptions that specify required context ("Requires an order ID or the customer's email address").
- Validating every argument before execution.
- Returning clear, structured error messages so the model can recover gracefully.
Security
The model should never be the authority on whether an action is permitted. Every destructive operation (refund, cancellation, account deletion) needs server-side authorization checks. The model proposes; your code verifies the user's identity and permissions before executing.
Latency
Each function call adds a round trip: model output, execution, model re-input. Sequential chains of three or four calls can push response times past what a customer will tolerate. Parallel function calling (where available) and caching frequent lookups reduce this.
Hallucinated calls
A model may attempt to call a function that does not exist, or fabricate argument values it was not given. Strict schema validation at the execution layer catches these before they reach your systems.
Observability
In production, every function call should be logged: what was called, with what arguments, what was returned, and how the model used the result. This audit trail is essential for debugging, compliance, and continuous improvement. Fin's testing and simulations framework lets teams validate that Procedures invoke the right functions before they reach customers, and Insights surfaces patterns in how function calls perform across live conversations.
Function calling and the future of AI agents
Function calling is the primitive that turned language models from conversationalists into operators. Every capability that defines a modern AI agent, from checking a balance to booking a meeting to processing a multi-item return, depends on the model's ability to output a structured request and act on the response.
The trajectory is toward more functions, more complex chains, and more autonomy. Multi-agent systems coordinate several specialized models, each with its own function set, to handle work that spans departments. Agent orchestration manages these handoffs so a single conversation can move from sales qualification to support resolution to product recommendation without the customer noticing a seam.
As this architecture matures, the competitive advantage shifts from "can the model call functions?" (every major provider supports this) to "how reliably does the model select the right function, with the right arguments, governed by the right policies, at production scale?" That is an engineering and domain-expertise problem, not a model-size problem. It is why purpose-built AI engines, trained on domain-specific interaction data and governed by configurable procedures, outperform general-purpose models on tasks like customer service.
How Fin uses function calling to resolve customer queries
Fin AI Agent is built on the Fin AI Engine, a proprietary architecture designed specifically for customer service. Function calling is central to how Fin moves from understanding a question to resolving it.
Fin connects to external systems through data connectors and takes action through configured functions. Teams define the logic using Procedures: plain-language instructions layered with conditional steps, code snippets, and checkpoints. When a customer asks to return an item, Fin follows the Procedure, calls the relevant Shopify or Stripe API, checks eligibility against the merchant's policy, and completes the return. If the scenario requires human judgment, Fin escalates with full context attached.
This design means CX teams control which functions Fin can call, under what conditions, and with what guardrails, without writing code or depending on engineering. The Fin Flywheel (Train, Test, Deploy, Analyze) makes function-calling behavior testable before it goes live: simulations run end-to-end conversations against configured Procedures so teams can catch edge cases before customers encounter them.
Fin AI Agent averages a 76% resolution rate across more than 12,000 customers, handling complex, multi-step workflows that depend on function calling at every turn. At $0.99 per outcome, teams pay when the function-calling chain produces an actual resolution, not when a function is merely invoked.
Function calling FAQ
What is function calling in AI?
Function calling is a mechanism that lets a large language model request a specific operation in an external system by outputting a structured object (typically JSON) with a function name and arguments. The model does not execute the function itself. An application layer handles execution and returns the result.
What is the difference between function calling and tool use?
They describe the same underlying mechanism. "Function calling" is the original term used by OpenAI. "Tool use" is the broader label preferred by some providers, including Anthropic. Both refer to the model outputting a structured request that an external system executes.
Why does function calling matter for AI agents?
Without function calling, an AI agent can only generate text. With it, the agent can retrieve live data, take actions in external systems (refunds, bookings, updates), and chain multiple operations together. Function calling is the technical foundation of agentic behavior.
Is function calling the same as an API call?
Not exactly. An API call is a direct request from one system to another. Function calling is the model's structured request that an intermediary layer translates into an API call. The model never contacts the external system directly.
How do you make function calling reliable?
Write precise function descriptions, validate every argument before execution, enforce server-side authorization, return clear error messages, and test with realistic scenarios before going live. In customer service, frameworks like Procedures and Simulations formalize this testing and governance process.
