Function calling is how a language model takes action. Given a schema of available functions, the model returns a structured JSON payload indicating which function to call and with what arguments. The host application reads the payload, runs the function, and feeds the result back into the conversation. The model can now do things, not just say things.

How function calling works.

  1. Declare a tool schema. The host application registers a set of functions with the model: name, description, parameter schema (typed and required-vs- optional fields).
  2. Model proposes a call. Instead of emitting prose, the model returns a structured request: “Call get_reservation with { date: "2026-05-20", party: 4 }.”
  3. Host executes. The application validates the arguments against the schema, runs the actual function against its real backend, and passes the result back.
  4. Model continues. The result is appended to the conversation, and the model either calls another tool or produces the final user-facing answer.

Why function calling matters.

It is the bridge between language models and the rest of the stack. CRM lookups, database writes, calendar bookings, calculations, search queries, all of it surfaces to the model through function calling. An agent without tool use is a conversation; an agent with tool use is a system.

Patterns and pitfalls.

  • Validate strictly. A malformed argument should fail fast, not be coerced. The model can correct on retry.
  • Keep schemas tight. Optional fields the model could interpret several ways produce inconsistent behavior. Tight types, clear required-vs-optional, short descriptions.
  • Limit tool count. More than fifteen or twenty tools in one call degrades selection. Group by role, route at higher level.
  • Log every call. Every function call is part of the AI observability trace. The argument, the result, the latency, the cost.
  • Authorize at the host. The model is not the authorization layer. Permissions check on every call.

Frequently asked.

What is function calling in LLMs?
Function calling is the API pattern where a language model returns a structured JSON payload requesting that a named function be invoked with specific arguments, so the model can interact with external systems (databases, calendars, CRMs, search) instead of only producing text. The host application executes the function and feeds the result back.
Is function calling the same as tool use?
Effectively yes in 2026 industry usage. 'Tool use' is the broader concept (any model action on the world); 'function calling' is the specific implementation pattern most providers ship. Anthropic uses 'tool use' and OpenAI uses 'function calling' for the same primitive.
How many tools should we expose to the model?
Fewer than twenty per call in most workflows. Beyond that, the model's ability to select the right tool degrades. Group tools by role and route at a higher level (a planner agent picks a sub-agent which exposes a smaller tool set) when the workflow needs more surface area.
Who handles authorization for function calls?
The host application, never the model. Every function call must be authorized at the application boundary against the actual user's permissions. Treat the model as untrusted input; the schema and the auth layer are the trust boundary.