Function Calling

The ability of language models to generate structured output that invokes external functions or APIs, enabling interaction with external systems and data.

In Depth

Function calling (also called tool use) is a capability of modern language models that allows them to generate structured output requesting the execution of specific external functions, APIs, or tools rather than just producing text. The model analyzes the user request, determines which function would be helpful, generates the appropriate parameters, and the calling application executes the function and returns the results to the model for further processing.

The function calling workflow operates through a defined protocol. The developer provides the model with a set of available function definitions, including names, descriptions, and parameter schemas. When the model determines that calling a function would help fulfill the user request, it generates a structured function call with the appropriate arguments instead of a text response. The application executes the function, returns the result to the model, and the model uses this information to formulate its final response to the user.

Function calling is supported by major model providers including OpenAI (function calling / tool use), Anthropic (tool use), Google (function calling), and open-source models through frameworks like LangChain. The reliability of function calling depends on the model ability to correctly identify when a function should be called, select the right function from available options, and generate valid parameters. Structured output guarantees and JSON schema validation improve reliability for production applications.

Function calling is the foundation for AI agent architectures, enabling models to interact with databases, APIs, file systems, web services, and enterprise applications. Common use cases include database queries from natural language, API orchestration across multiple services, calculations and data transformations, information retrieval from internal systems, and workflow automation. Production implementations require robust error handling, parameter validation, rate limiting, and access control to ensure safe and reliable function execution.

Need Help With Function Calling?

Our team has deep expertise across the AI stack. Let's discuss your project.

Get in Touch