47 model prices

    Guide

    What Is Tool Calling Function Calling 2026

    Tool calling (function calling) explained. How LLMs call APIs. Claude, OpenAI, structured output.

    2 min read

    Tool calling (Anthropic's term) — or function calling (OpenAI's term) — is the LLM ability to invoke predefined functions instead of just generating text.

    The Idea

    Without tool calling, an LLM only outputs text. With tool calling:

    1. You define tools with schemas
    2. LLM decides to invoke one
    3. LLM outputs a JSON tool_call
    4. Your code runs the function
    5. You feed the result back to the LLM
    6. LLM continues with the new context

    This unlocks agents.

    Anthropic Claude Tool Use

    tools = [{
        "name": "get_weather",
        "description": "Get weather for a city",
        "input_schema": {
            "type": "object",
            "properties": {"city": {"type": "string"}},
            "required": ["city"],
        }
    }]
    
    response = client.messages.create(
        model="claude-sonnet-4-6",
        max_tokens=1024,
        tools=tools,
        messages=[{"role": "user", "content": "Weather in Istanbul?"}]
    )
    

    OpenAI Function Calling

    tools = [{
        "type": "function",
        "function": {
            "name": "get_weather",
            "description": "Get weather",
            "parameters": {
                "type": "object",
                "properties": {"city": {"type": "string"}},
            }
        }
    }]
    

    Same idea, slightly different shape.

    Multi-Tool

    Most LLMs handle multiple tools in one call. They pick the right one based on the prompt.

    Parallel Tool Use

    Claude and GPT-4 can call multiple tools in parallel. Use when independent (no dependency between).

    Structured Output

    A common use: force the model to output strict JSON matching a schema. Set the tool as "the response itself" and you get type-safe output.

    Common Failure Modes

    • Bad tool descriptions: model picks wrong tool
    • Required fields missing in schema: model invents values
    • Vague return types: model can't reason about result
    • No max_iterations: agent loops forever

    Next Step

    Build a real agent: read how to build an AI agent.

    Newsletter

    The week in AI and developer tools, in one email.

    New models, tool releases and price changes. Once a week.