Skip to the page
Tecyfy

What is function calling in AI?

The developer's name for tool use. The model replies with the name of a function and its arguments in a fixed format, and your code runs it.

intermediate · Also called Tool Calling

Tool useTool UseGiving a model a list of things it can ask to have done, such as search the web or read a file. The model asks; the program around it does the work and hands back the result. is the idea: a model asks for something to be done. Function calling is how a developer builds it. The 2 names are used for the same thing, and OpenAI's documentation now calls it tool calling too.

What the developer writes

For each function, the developer gives the model a name, a description in plain words and a schema: a strict list of the inputs, their types and which ones are required. For a refund tool that might be an order number (text, required) and an amount (a number, required).

The description matters more than people expect. It is the only thing the model reads to decide when to use the function, so "Refunds an order. Use only after the customer has confirmed" does real work.

The round trip

OpenAI describes the flow in 5 steps, and Claude's works the same way.

  1. Your code sends the conversation plus the list of functions.
  2. The model replies with a function call instead of text: the name, and the arguments filled in.
  3. Your code checks the call and runs the real function.
  4. Your code sends the result back to the model.
  5. The model writes its answer, or asks for another call.

The model never touches your systems. It produces a small block of structured text, and your code decides whether to act on it.

Making the arguments reliable

A model writes arguments the way it writes everything else, by prediction, so it can occasionally leave out a field or give the wrong type. OpenAI offers a strict mode for this. With strict turned on, the arguments follow the schema reliably instead of on a best-effort basis.

Strict mode guarantees the shape, not the sense. A perfectly formed refund call can still name the wrong order.

What to take from it

If you build with a model, treat every function call as a request, not a command. Check the arguments, limit what each function can reach, and put a person in front of anything you cannot undo. If you only use AI apps, this is what is happening when a chatbot "books", "searches" or "files" something for you: it wrote a request, and someone's code carried it out.

Sources

Where each fact comes from

  1. 1Function calling
  2. 2How tool use works
  3. 3Define tools