Tool Use definition
Function calling, also called tool use, is a capability of large language models that lets them request the execution of external functions, such as an API call, a database query or a calculation, by returning a structured message with the function name and arguments. The application runs the function and sends the result back to the model.
How does function calling work?
The model never runs code or touches your systems. It only produces a structured request, and your application decides whether and how to execute it. That separation is what makes tool use controllable: validation, permissions and logging all live in ordinary application code that you own and can test.
- Define each tool with a name, a plain-language description and a JSON Schema for its parameters.
- Send the tool definitions with the user's message to the model.
- The model replies with a tool call, naming the function and supplying arguments.
- The application validates the arguments, checks permissions and runs the function.
- The result goes back to the model, which answers the user or calls another tool.
Example of function calling
A customer asks, "Where is my order 4417?" The model has a tool called get_order_status with one parameter, order_id. Instead of guessing, it returns a call to get_order_status with order_id set to 4417. The application checks the order belongs to the logged-in customer, queries the order system and returns "shipped, arriving Thursday". The model then writes a friendly reply using that real status.
The same mechanism produces structured data. Defining a tool called save_invoice with fields for supplier, date, total and tax makes the model return clean, schema-valid JSON from a messy invoice. Many providers also offer strict modes that guarantee the arguments match the schema, which removes a whole class of parsing errors.
Function calling vs MCP
Function calling is the model-level capability, supported in APIs from OpenAI, Anthropic, Google and others, and by many open models. The Model Context Protocol is a standard for packaging and connecting tools across applications. With MCP, tools defined on an MCP server are passed to the model, and the model still uses function calling to request them. One describes how a model asks; the other describes how tools are delivered.
Best practices for reliable tools
- Write descriptions for the model: say what the tool does, when to use it and when not to.
- Prefer a few focused tools over one tool with many modes.
- Validate every argument; never trust model output as safe input.
- Enforce permissions in code, based on the real user, not the model's claims.
- Ask for user confirmation before writes, payments or deletions.
- Return clear error messages so the model can recover or explain the problem.
- Keep the tool list short, since too many options lower selection accuracy.
- Log every call with its arguments and result for debugging and audit.
- Set timeouts and retry limits so a slow API cannot stall the conversation.
Common uses
Function calling powers support bots that check orders and bookings, assistants that schedule meetings, agents that query analytics databases in plain language, and workflows that file tickets or update CRM records. Nexzem builds these integrations on top of clients' existing APIs, adding validation, permission checks and audit logs so the AI feature is as accountable as any other part of the system.