Skip to content

What is Function Calling (Tool Use)?

Generative AI & LLMs, explained by the engineers who build it. Definition, how it works, use cases and common questions.

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.

Tool Use: common questions

Something else on your mind? Ask a consultant and get a reply within one business day.

Is function calling the same as tool use?

Yes. OpenAI popularized the term function calling, while Anthropic and others often say tool use. Both describe the same capability: the model returns a structured request to invoke a named tool with arguments, and the application executes it and returns the result.

Can the model call functions on its own?

No. The model only outputs a request. Your code receives that request and decides whether to run it, which is where validation, permission checks and confirmations belong. This design keeps control in the application, even when an agent makes many tool calls in a row.

Which models support function calling?

Most modern commercial models support it, including the GPT, Claude and Gemini families, as do many open-weight models such as DeepSeek, Qwen, gpt-oss, Mistral and Llama variants. Reliability varies, especially for complex schemas or many tools, so test tool selection and argument accuracy on your own scenarios.

Keep exploring the generative ai & llms glossary

Need Tool Use in your product?

A solutions consultant replies within one business day with next steps, a rough estimate and a suggested team.