What is Function Calling?

    A capability that allows language models to generate structured function invocations with appropriate arguments, enabling them to interact with external tools and APIs.

    Definition

    Function calling (also called tool use) is a capability where a language model generates structured output that represents a call to an external function or API, including the function name and correctly typed arguments. Rather than producing free-text responses, the model outputs a structured invocation — typically in JSON — that an application can parse and execute against real systems, returning the result to the model for incorporation into its response.

    This capability transforms LLMs from conversational text generators into orchestration engines that can take actions in the real world. A model with function calling can check a database, query a weather API, execute code, send emails, or update a CRM system — all by generating the appropriate function call based on the user's natural language request. The application layer handles execution; the model handles intent understanding and argument extraction.

    Function calling was popularized by OpenAI's API and has since been adopted across the LLM ecosystem. Open-source models like Llama 3, Mistral, and Qwen now include function calling capabilities trained through instruction tuning on function-calling datasets. The quality of function calling — correctly selecting the right function, extracting arguments from ambiguous natural language, and handling multi-step tool chains — varies significantly across models and benefits greatly from fine-tuning on domain-specific function schemas.

    Why It Matters

    Function calling is the foundation of agentic AI applications. Without it, LLMs can only generate text — with it, they can interact with databases, APIs, file systems, and business processes. This capability is what enables AI assistants to move beyond answering questions to actually completing tasks on behalf of users.

    For enterprise applications, function calling enables LLMs to integrate with existing systems. Instead of rebuilding business processes around an AI, organizations can expose their existing APIs as functions that the model can call. This dramatically reduces the integration effort required to add AI capabilities to existing workflows and ensures that the AI operates within the constraints of established systems.

    How It Works

    Function calling works through a protocol between the application and the model. The application provides the model with a list of available functions, each described by a name, description, and JSON schema for its parameters. When the user's request requires a function call, the model generates a structured response containing the function name and arguments in JSON format.

    The application parses the function call, validates the arguments against the schema, executes the function, and returns the result to the model. The model then incorporates the result into its response. For complex tasks, this cycle may repeat multiple times — the model might call a search function, use the results to formulate a database query, and then summarize the combined information. Training models for function calling involves instruction-tuning on datasets of natural language requests paired with correct function invocations.

    Example Use Case

    An internal help desk bot is connected to three functions: search_knowledge_base(query), create_ticket(title, priority, description), and check_ticket_status(ticket_id). When an employee says 'I can't access the VPN and need this fixed urgently,' the model calls search_knowledge_base('VPN access issue') to find relevant solutions, presents them to the user, and if the user says the solutions didn't work, calls create_ticket('VPN Access Failure', 'high', 'Employee unable to connect to VPN...') to escalate — all through natural conversation.

    Key Takeaways

    • Function calling allows models to generate structured API invocations from natural language requests.
    • It transforms LLMs from text generators into orchestration engines that can take real-world actions.
    • The application provides function schemas; the model generates calls; the application executes them.
    • Function calling quality varies across models and benefits significantly from domain-specific fine-tuning.
    • It is the foundational capability for agentic AI and tool-using AI assistants.

    How Ertas Helps

    Ertas Studio enables fine-tuning models specifically for function calling by training on datasets of natural language paired with correct tool invocations, improving the model's accuracy at selecting functions and extracting arguments for domain-specific tool sets.

    Related Resources

    Ship AI that runs on your users' devices.

    Early bird pricing starts at $14.50/mo — locked in for life. Plans for builders and agencies.