# Function Calling (Tool Calling)

> Source: https://netray.co/glossary/function-calling
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: Glossary

## Short answer

Function calling, also called tool calling, is a capability where an LLM outputs a structured request to run a named function with specific arguments, such as get_order_status(order_id). Your software executes it and returns the result to the model.

## Aliases

- tool calling
- tool use
- LLM tool use

## Category

on-prem-ai

## Full Definition

A language model alone can only produce text. Function calling gives it hands: you describe a set of tools, each with a name, a purpose and a JSON schema for its parameters, and the model decides when a tool is needed and emits a structured call. Your application validates the arguments, runs the real code, and feeds the output back so the model can compose the final answer.

In an ERP setting the tools are thin wrappers over existing interfaces: a SyteLine IDO load collection, a NetSuite RESTlet, an Infor ION API call, or a stored procedure. A tool such as get_open_po_lines(vendor, due_before) wraps the query, enforces the user's ERP permissions, and returns clean JSON. The model never sees credentials or raw database access.

Function calling is the mechanism underneath AI agents. An agent is a loop in which the model repeatedly picks a tool, reads the result and decides the next step. The Model Context Protocol standardises how tools are described and exposed, so the same tool set works across different models and clients.

The design discipline matters more than the model. Narrow tools with strict parameter schemas, read-only by default, with write tools gated behind approval, are safer and more accurate than one broad tool that accepts free-form commands.

## Why It Matters

- It is how an LLM reaches live ERP data and actions instead of guessing from training data.
- Strict schemas let you validate every call before it touches the ERP.
- Small, well-named tools are easier to audit, permission and test than free-form access.
- Open-weight models served with vLLM or Ollama support tool calling, so it works fully on-prem.

## In Practice

A buyer asks, "What is late from Acme Castings?" The model calls get_open_po_lines with vendor set to ACME and due_before set to today. The wrapper queries the purchase order line table with the buyer's site filter, returns 7 lines as JSON, and the model summarises them with PO numbers and days late. If the buyer then asks to expedite, a separate write tool creates a draft action that waits for approval.

## Faq

### Does function calling run code inside the model?

**Answer:** No. The model only emits a structured request. Your application decides whether to run it, executes the real code, and returns the result.

### Is function calling the same as MCP?

**Answer:** They are related but different. Function calling is a model capability, while the Model Context Protocol is a standard way to describe and serve tools to any compatible model or client.

### Do open-weight models support it?

**Answer:** Many do, including recent Llama, Qwen, Mistral and gpt-oss class models, and servers like vLLM expose a tool-calling API. Reliability varies by model, so test on your own tools.

### How do I keep tool calls safe?

**Answer:** Validate arguments against the schema, run tools with the end user's ERP permissions, keep tools read-only by default, log every call, and require human approval for writes.

## Search terms

function calling, tool calling llm, llm tool use erp, openai function calling alternative, tool calling open source models, ai agent tools, llm api integration, structured output tools

---
Talk to an engineer: https://netray.co/contact?intent=erp_ai | Machine catalog: https://netray.co/agent/catalog.json
