AI Model Wiki

    Skip to main content
    Back to Glossary

    Tool Use (Function Calling)

    Function calling (also called tool use) is a protocol through which an AI model signals that it wants to invoke a specific external function, providing structured arguments in a machine-readable format—usually JSON—so that the calling application can execute the function and return the result. The model does not run code itself; it outputs a well-formed request that the developer's infrastructure handles, then resumes reasoning once the response arrives. This pattern is supported natively by models from OpenAI, Anthropic, Google, and others, enabling reliable, schema-validated interactions with arbitrary software.

    Think of it like a lawyer who drafts a precise legal memo requesting information from a court registry: the lawyer doesn't personally retrieve the files but writes the exact document needed so the registry knows precisely what to return. The model is the lawyer; your API glue is the registry clerk.

    response = client.chat.completions.create(
        model="gpt-4o",
        messages=[{"role": "user", "content": "What's 1492 * 37?"}],
        tools=[{"type": "function", "function": calculator_schema}]
    )
    # model returns tool_calls[0].function.arguments = '{"a": 1492, "b": 37}'
    

    Your code runs the multiplication, sends the result back, and the model incorporates it into a final natural-language reply.

    Function calling is a concrete implementation of the broader Tool Use concept and depends on careful Prompt Engineering to describe available functions accurately. It pairs naturally with RAG when one of those functions performs a vector search, and with Inference latency budgets because each round-trip adds time.

    You'll encounter function calling when building any application that needs an LLM to query live data, trigger back-end actions, or coordinate multiple services in a single conversational turn.

    AI Terminology
    Glossary