Skip to content

Function calling

AI glossary

Function calling

Also called: tool use, tools

Function calling, or tool use, is the pattern where a model returns a structured action, such as a function name and arguments, instead of only a paragraph. Your software runs that action and sends the result back. By 2026 this is how most serious chat products look up orders, search docs, or create tickets.

The loop

You describe each tool with a name, a short purpose, and a schema for the arguments. The model may emit a call, or it may answer in prose if no tool is needed. You execute only known tools, validate arguments, enforce auth, and return a compact result. The model then writes a user-facing reply, or it calls another tool.

Official API docs from OpenAI and Anthropic walk through this contract in detail, including parallel calls and error handling.

Design notes

Keep the tool list short and the descriptions honest. A vague tool will be overused. Log every call. And never let the model invent a tool or a URL that your runtime then fetches blindly.

A concrete example

Example The model emits a call to get_order_status with an order id, your server runs it, and the model then writes a human reply.

FAQs about Function calling

Is function calling the same as an agent?

It is the usual interface an agent uses, but a single tool call inside a chat is not yet a long-running agent. Agents add a goal, a loop, and often memory.

Should the user see the tool call?

In internal tools, showing the call often helps trust. In consumer apps, a short status (“Looking up order 1842”) is usually enough, with a full log stored for support.

What if the tool fails?

Return a clear error to the model, and cap retries. Do not let a failed lookup turn into a guessed tracking number in the user-facing text.

Can I let the model write SQL or shell commands?

Only in a tight sandbox, with a human or a policy layer on write actions. Structured tools with narrow arguments are safer than a raw shell.

Back to the full AI glossary