Function Calling (Tool Use)

Definition. A model capability in which the model, instead of answering in prose, emits a structured request to invoke a named function with typed arguments. The application executes the function and returns the result as a new message, and the model continues. It converts an LLM from a text generator into a controller that can read databases, call APIs, send messages and write records, while the application retains authority over what actually executes.

How it works. Declare each tool with a name, a description and a JSON Schema for its parameters. Send the declarations with the request. When the model returns a tool call, validate the arguments against the schema, check authorisation, execute, and return the result with the matching call identifier. Loop until the model produces a final answer or a step limit is reached. Keep tool descriptions precise: the model selects tools by reading them, so vague descriptions cause wrong-tool selection.

Example. A finance assistant exposes three tools: get_invoice(id), list_overdue(days) and send_reminder(invoice_id, template). A user asks which customers are more than 30 days late. The model calls list_overdue with days=30, receives twelve records, and summarises them. When the user says remind them all, the model proposes twelve send_reminder calls. The application intercepts, shows a confirmation list, and only executes after approval, because send_reminder is marked as requiring human confirmation.

Use case. Function calling is the foundation of every assistant that must act rather than talk: booking systems, CRM updates, ticket triage, data lookup, report generation and multi-step agents. It is also the cleanest way to force structured output, because a single tool with a strict schema is effectively a typed return value.

Warnings. Never execute a tool call without validating arguments and checking that the user is authorised for that specific resource. Treat the model as an untrusted client. Destructive or irreversible tools must require explicit confirmation, and every tool call must be logged with its arguments and result for audit.

Limitations. Models can call the wrong tool, invent arguments, or loop. Parallel tool calls complicate ordering and error handling. Schemas cannot express every constraint, so business validation must still happen in code. And tool definitions consume context, so a large tool catalogue degrades selection accuracy.

Pros and cons
ProsCons
Lets a model request structured actions through application tools.Incorrect tools, arguments, and execution order still need handling.
← Browse all glossary terms