AI systemsfunction callingtool usetools

Tool calling

Definition

Tool calling (function calling) is a model API feature in which the model, given tool names and JSON schemas, responds with a structured call such as a tool name plus arguments instead of text, and the caller runs it and passes back the result.

In practice

Tool calling turns a model from a text generator into the planner of an agent: it can search, query APIs or change data through code you control. The model only proposes the call; the runtime validates the arguments against the schema, checks permissions, executes it with credentials scoped to the user and task, and returns the output for the next turn. MCP standardises how tools are discovered and invoked.

Arguments are untrusted input, however well-formed they look, and tool results can carry prompt injection back into the model. Tools that change state must be idempotent, because agents retry and runners can crash mid-step. Many tools with vague descriptions confuse models, so a small, well-described set usually works better.

Example

The model returns {"name": "get_order", "arguments": {"orderId": "A-1042"}}; the runtime checks the order belongs to the signed-in user, calls the orders API and sends back the JSON result.