Automation and AI

Function Calling

Also called Tool calling, structured output

The mechanism letting a model request a named action, with structured values, that your own code then runs.

Quick facts: Function Calling

Category
Automation and AI
Also called
Tool calling, structured output
Level
Advanced
Affects
Integration reliability, data quality, security exposure
Where to see it
Model provider APIs, n8n and Make AI nodes, custom integrations
In this article4
  1. How function calling works
  2. Why function calling matters
  3. Where function calling goes wrong
  4. Getting it right

How function calling works

You give the model a list of actions it may request. Each one has a name, a plain description of what it does, and a description of the information it needs — an order number, an email address, a date range. When the model decides an action is called for, it does not run anything. It returns a structured request naming the action and filling in those values, and stops.

Your code receives that request, decides whether to honour it, runs the real work, and hands the result back. The model then continues writing with the answer available. Everything the model produces is still text; the difference is that this particular text is machine-readable, so software can act on it reliably instead of guessing at a sentence.

That is also why the same mechanism is used to force a tidy output. Describing a function that takes a name, a phone number and an enquiry type is a dependable way to get those three fields back from a messy message.

Why function calling matters

It is the plumbing beneath almost every useful AI feature in marketing. A chatbot that checks stock, a workflow that files an enquiry in the right CRM stage, a tool that reads a form submission and returns clean fields — all of them rest on the model asking for a named action in a predictable shape.

The design also puts you in control by default. The model can only ask for actions you defined, with values that fit the shape you specified, and it never executes anything itself. Every genuine decision about whether to act stays in your own code, which is exactly where it belongs.

Where function calling goes wrong

The most common failure is a lazy description. The model picks its action from the wording you supplied, so two similarly described functions produce confident calls to the wrong one, and a thin description produces calls with the wrong values in them.

The second is trusting the arguments. The model fills those fields from a conversation, and a conversation can contain a mistake, a misreading or a deliberate attempt to steer it. Treat every incoming call as input from outside: validate the values, check the caller is allowed to ask, and never let a supplied value widen what the action may touch.

The third is silence on failure. If your code returns nothing when a call fails, the model has no way to know, and will carry on as though it succeeded.

Getting it right

Write descriptions for a stranger, not for yourself, and say plainly when a function should not be used. Keep each one narrow and single-purpose, so its behaviour is easy to predict and easy to test. Validate every argument before acting, return clear errors the model can read and respond to, and log the call alongside its result.

Hold anything irreversible behind a person or a rule of your own. Done properly this is the quiet foundation of dependable tool use and of the workflow automation built on top of it.

Do and do not

Do

  • Describe each function as if to a stranger
  • Validate every argument before you act on it
  • Return readable errors so the model can retry

Do not

  • Define two functions with near-identical descriptions
  • Trust supplied values to decide what may be accessed
  • Let an irreversible action run without a check

Questions people ask about this

Does the model run the function itself?

No, and that is the point of the design. The model returns a structured request naming the action and the values it wants used, then stops. Your own code decides whether to honour that request, runs the work and returns the result. Every real decision about whether something happens stays on your side.

How is function calling different from tool use?

Tool use describes the overall pattern of a model reaching beyond text to fetch data or take action. Function calling is the specific mechanism that carries the request: a named action with structured arguments, returned in a shape your software can read. In practice, tool use is the idea and function calling is how it is wired.

Can function calling be used to get clean data out of messy text?

Yes, and it is one of its most practical uses. Describe an action that takes the fields you want, such as name, phone number and enquiry type, and the model will return those fields filled from a rambling message. Validate what comes back before storing it, because the model can still misread the source.

Related terms

Found this useful?

Share it, or ask an AI to summarise it

Back to the glossary

Knowing the term is the easy part

Applying it to your own site and budget is the work. Book a call and I will tell you what actually applies to you.