Skip over navigation

Function Calling

A capability of modern LLMs that allows the model to identify when a task requires external data or actions, generate a structured call to a defined function or API with the correct parameters, and incorporate the returned result into its response.

Created Sep 10, 2026
AI infrastructure

What It Is

Without function calling, an LLM is a closed system. It can only work with the information in its prompt. Function calling opens that boundary: the model can call external tools (query a database, check live inventory, create a record, calculate a price) and use the results in its response, all within a single conversational turn.

The mechanism works like this: the developer defines a set of available functions with their names, parameters, and descriptions. When the model determines that answering a query requires one of these functions, it outputs a structured function call rather than a direct answer. The application executes the function, passes the result back to the model, and the model incorporates it into its response.

The model does not execute the function itself; it only generates the call specification. The execution happens in the application layer, which means the developer controls access, validates parameters, handles errors, and enforces permissions before anything touches a live system.

In B2B Commerce Context

Function calling is what turns an LLM from a text generator into an active participant in a commerce workflow. Without it, an AI assistant responding to “What is the current price of product X for my account?” can only offer a general answer based on training data. With function calling, it queries the pricing API with the customer’s account ID and the product code and returns the exact contracted price.

The most valuable functions to expose

In a B2B commerce deployment, the most valuable functions to expose are: pricing lookup (given customer ID and product ID, return contract price), inventory check (given SKU and warehouse, return available quantity), order status (given order ID, return current status and estimated delivery), product substitution (given SKU, return compatible alternatives), and account data (given account ID, return credit limit, payment terms, and outstanding balance).

Function calling integrates naturally with OroCommerce’s API layer. The commerce platform’s APIs become the function library that AI agents call into. This means AI capabilities built on function calling inherit the platform’s existing access controls, audit logging, and business logic; they do not bypass them.

When You Need It

  • Your AI assistant needs to answer questions about live data: current pricing, real-time inventory, order status.
  • You want the AI to take actions within controlled boundaries: place a draft order, create a support ticket, update an account record.
  • You are building an agentic workflow that requires the AI to make decisions based on what it finds in your systems rather than what it was trained on.
  • You want to ground AI responses in authoritative data sources rather than letting the model reason from general knowledge.

Define the function set carefully. Exposing a “place order” function without confirmation logic means the AI can create real orders. Expose a “draft order” function instead, and require a separate confirmation step before the draft becomes a real transaction.

What It Is Not

  • Function calling is not the same as giving the model internet access. Web browsing is a specific tool that some models have. Function calling is a structured mechanism for calling specific, developer-defined functions. The scope is controlled by what functions the developer chooses to expose.
  • It is not the same as RAG. RAG retrieves documents for the model to read and reason over. Function calling executes code and returns structured data. Both can be used together (RAG to find relevant documents, function calling to fetch live data) but they serve different purposes.
  • It is not secure by default. Exposing a function to an LLM means that function can be called whenever the model decides it is relevant. A poorly scoped prompt can lead to unexpected function calls. Apply the same security thinking to exposed functions as you would to any API endpoint: authentication, authorization, input validation, and rate limiting.

Comparison

Function type What it does B2B commerce example
Read (lookup) Retrieves a specific record Get contract price for customer X, product Y
Read (search) Returns a set of matching records Find all in-stock substitutes for SKU Z
Write (create) Creates a new record Create a draft quote for review
Write  (update) Modifies an existing record Update delivery address on order
Trigger (action) Initiates a workflow Submit quote for approval

See also

Ready to see it in action?

Book a demo of OroCommerce

See how agentic workflows fit into complex B2B commerce, with a walkthrough tailored to your stack.

Book a demo

Share

Back to top