AI glossary

What is Function calling?

Also called Tool calling, Tool use ·

Function calling (also called tool calling or tool use) is the ability of a language model to return a structured request to run a function you defined, with arguments in JSON, so your code can execute it and pass the result back.

How it works

You send the model a list of tools alongside the conversation. Each tool has a name, a plain-language description of what it does and when to use it, and a JSON Schema for its parameters. The model never runs anything itself. When it decides a tool would help, it stops generating normal text and returns a tool call: the tool name plus arguments that match the schema.

Your application then:

  1. Validates the arguments.
  2. Runs the real function (an API call, a database query, a calculation).
  3. Sends the result back to the model as a tool result message.
  4. Lets the model continue, either answering the user or calling another tool.

That loop of "model proposes, code executes, model reads the result" is the core of every AI agent.

Why it matters

Function calling turns a model that can only write text into one that can look things up and take actions. It also makes outputs reliable to parse: instead of scraping a date out of a paragraph, you get {"date": "2026-10-18"} in a known shape.

A few practical points matter more than the model choice:

  • Descriptions are prompts. A vague description leads to the wrong tool or wrong arguments.
  • Validate everything. Models can produce arguments that are well-formed but wrong, so check them before any write action.
  • Keep the tool list short. Dozens of overlapping tools confuse models and cost tokens on every request.

The Model Context Protocol builds on the same idea: an MCP server publishes tools with names, descriptions and schemas, and the host turns them into function definitions for the model.

Example

A support assistant is given a tool get_order_status(order_id: string). A customer writes "where is order 48213?". The model returns a call to get_order_status with {"order_id": "48213"}. The application queries the order system, gets "shipped, arriving Tuesday", sends that back, and the model replies to the customer in natural language with the real status.

Sources

  1. Function calling, OpenAI
  2. Tool use with Claude, Anthropic

Back to the AI glossary