Function Calling

Function Calling is an API mechanism in which a language model, given a set of developer-declared function schemas, returns a structured JSON object naming one of those functions and supplying arguments that conform to its typed parameter…

Function Calling is an API mechanism in which a language model, given a set of developer-declared function schemas, returns a structured JSON object naming one of those functions and supplying arguments that conform to its typed parameter definitions, rather than emitting free-form prose for the application to parse. The schema is typically JSON Schema: each function has a name, a description, and a typed parameter object with required fields. The model does not execute anything; it emits the intended call, and your code decides whether and how to run it. First shipped by OpenAI in June 2023 and now supported by Anthropic, Google, and most open-weights providers, function calling replaced brittle regex parsing of model text with a validated, machine-readable interface. A single response can request one call, several parallel calls, or none at all when no function fits the user's request.

How it works

You send the model the conversation plus a list of function definitions in the request. The model, guided by constrained decoding or fine-tuning, produces output the API tags as a tool/function call: a name plus a JSON arguments blob matching the declared types. Your application parses that blob, executes the real function, and appends the result to the conversation as a new message. The model then reads that result and either answers the user or requests another call, repeating until the task resolves.

Why it matters for AI engineers

Function calling is the load-bearing primitive for agents, so its reliability sets a ceiling on everything built above it. Typed schemas cut parsing failures and let you validate arguments before executing side effects, but they do not eliminate risk: a model can still hallucinate plausible-but-wrong arguments or be steered by injected instructions into calling a dangerous function, so treat every call as untrusted input and gate destructive actions. Each declared function consumes context tokens and adds latency, so large tool catalogs raise cost and degrade selection accuracy—prune aggressively or route.

Function Calling vs. alternatives

Concept What the model returns Scope
Function Calling JSON call matching a function schema The API-level request-a-function primitive
Tool Use Same JSON call, framed as invoking a tool Broader concept; function calling is its mechanism
Structured Output JSON matching a schema as the final answer Formatting a response, not requesting an action

Related terms

Go deeper

Definitions are the start. Ask the Research Desk for a cited, multi-source brief on Function Calling — real sources, verified claims, delivered in minutes.

Ask the Research Desk →