Function calling

Definition
The mechanism that lets an AI model trigger real code, look something up, send something, update a record, rather than only produce text.

Why it matters

This is the step from a chatbot that talks to an assistant that acts. Without it, a model can describe how to check an order. With it, the model checks the order, using the real data rather than a guess, which also reduces made-up answers. It also moves part of the reliability problem onto the functions. The model chooses which one to call and what to pass in, so clear descriptions and checks on your side decide whether it behaves.

How to apply it

  • Describe each function narrowly: what it does, what it needs and what it returns.
  • Validate every input before running it. A value is not safe because a model produced it.
  • Keep functions small and single-purpose. A function that does too much gives the model more ways to misuse it.
  • Start with read-only functions, and add write access later.
  • Log every call and its inputs, so a wrong action can be traced.
  • Add human approval before anything hard to reverse, such as sending money or deleting a record.

What it is

A language model on its own only produces text. Function calling lets it ask for something to be done. The developer describes a set of functions, each with a name, a purpose and the inputs it needs. When the model decides one is useful, it replies with the function name and the values to pass in. The surrounding software runs the function and hands the result back, and the model carries on with that result in front of it.

The model never runs anything itself. Your code does, and your code decides whether to allow it. Different AI providers use different names for the same idea, mostly tool use or function calling.

Worked example

A support assistant has two functions. One looks up an order by its number. The other drafts a refund but does not send it. A customer asks where their parcel is. The model calls the lookup with the order number from the message, receives the real delivery status and answers from it. A person reviews each drafted refund before anything is paid.

  1. Article

    MCP server

    A standard way of offering functions and data to an AI agent.

  2. Article

    Guardrails

    The checks that stop a function call doing harm unattended.

  3. Article

    Autonomous agent

    An agent that chains several calls together to reach a goal.

  4. Article

    Hallucination

    What a real lookup helps to prevent.