Function Calling

Function calling is the structured form of tool use: the model emits a machine-readable request naming a function and its arguments, written in JSON, which your code validates and executes, then feeds the return value back into the conversation.

Agents & automationtool calling
§ 01DefinitionFunction Calling

No jargon, no math

In plain words, what is it?

Tool use is the idea; function calling is the wire format. Instead of writing “I will now check the stock”, the model emits something like {tool: “get_stock”, args: {sku: “A-2210”}}. Your code parses that JSON, checks the arguments against a schema, executes the real function and puts the result back as a message. The model never executes anything itself: it writes a precise order, your system is the kitchen that cooks it. Where it breaks: models can invent argument values or pick the wrong function when two look alike, which is why schemas, enums and validation on your side are not optional.

§ 02How it worksDeclare → emit → validate → execute → continue
  1. 01

    Declare. You give the model a list of functions with names, parameters and types.

  2. 02

    Emit. Mid-answer, the model outputs a JSON call: function name plus arguments.

  3. 03

    Validate. Your code checks the call against the schema; malformed calls are rejected.

  4. 04

    Execute. A valid call runs the real function inside your system.

  5. 05

    Continue. The return value goes back as a message and the model finishes the answer.

§ 04

Want this running in your stack?

We design and ship AI systems with permissions, logs and human approval. It starts with a 30-minute scoping call.