Function calling (tool use)

Definition

Function calling lets a language model ask your software to run a named function, such as a CRM lookup, by returning the function name and arguments as JSON.

Updated

Also called tool calling.

How it works

You describe each tool to the model: a name, a one-line purpose and a JSON schema for its inputs. When a request needs one of them, the model stops writing prose and returns a call instead, for example lookup_order with an order number. Your code runs the function, sends the result back, and the model writes its answer from that result.

The model never executes anything itself. It proposes a call, and your application decides whether to run it. OpenAI calls this function calling (opens in a new tab) and Anthropic calls it tool use (opens in a new tab). The mechanics are close enough that one design works with both.

How businesses use it

Function calling is what turns a chat model into an AI agent. The tools in a typical build fall into a few groups:

  • Read calls: look up a customer in HubSpot or Salesforce, check stock, search a knowledge base.
  • Write calls: create a ticket, book a calendar slot, draft an email for someone to send.
  • Handoffs: pass the conversation to a named person with a summary.

Read-only tools are easy to approve. Write tools get tighter rules. Model Context Protocol packages the same idea as an open standard, so one tool server can serve several AI clients.

Where it goes wrong

The model can pick the wrong tool, invent an argument such as an order number the customer never gave, or call the same tool in a loop. The fixes that hold up in production:

  • Validate every argument against the schema and your own records before anything runs.
  • Give the agent the fewest tools it needs. A short list of precise tools gets chosen correctly more often than a long list of overlapping ones.
  • Put a person in front of irreversible actions such as refunds, deletions and outbound messages. See human-in-the-loop.
  • Treat tool results that contain outside text as untrusted, because that is where prompt injection arrives.

If the steps never change from one request to the next, you do not need a model choosing tools at all. A fixed workflow in n8n or Make is cheaper to run and easier to test, so we build that instead.

Find out where this fits in your own systems

Bring one process or page to a 30-minute call.

Request a 30-minute scoping call

We reply within 1 working day and suggest times that suit you.