AI Model Wiki

    Skip to main content
    6 min read
    Lesson 3 of 5

    Tool Use & Function Calling Explained

    From the course AI Agents & Automation: Build Intelligent Workflows

    Tool use (also called function calling) is the mechanism that turns a language model into an agent. It lets the AI call external APIs, query databases, and interact with the real world.

    How Function Calling Works

    1. You define a set of "tools" — functions the AI can call, with descriptions and parameter schemas
    2. The AI receives a user request and your tool definitions
    3. The AI decides whether to call a tool and with what arguments
    4. Your code executes the tool and returns the result to the AI
    5. The AI uses the result to formulate its response

    Example: Weather Tool

    You define:

    • Tool name: get_weather
    • Description: "Get current weather for a city"
    • Parameters: { city: string, units: "celsius" | "fahrenheit" }

    User asks: "What's the weather like in Tokyo?"

    AI decides to call: get_weather({ city: "Tokyo", units: "celsius" })

    Your code calls a weather API and returns: { temp: 22, condition: "partly cloudy" }

    AI responds: "It's 22°C and partly cloudy in Tokyo right now."

    Common Tool Types

    • Search tools — Web search, database queries, document retrieval
    • Action tools — Send emails, create calendar events, update CRM records
    • Computation tools — Run calculations, execute code, process data
    • Integration tools — Connect to Slack, GitHub, Jira, Stripe, etc.

    Multi-Tool Orchestration

    Powerful agents use multiple tools in sequence:

    User: "Find our top 3 customers by revenue this quarter and draft a thank-you email to each"

    Agent thinks: I need to query the database, then compose emails

    1. Calls query_database for top customers
    2. Calls get_customer_details for each customer
    3. Calls draft_email three times with personalized content
    4. Presents drafts for human approval

    Parallel Tool Calls

    Modern APIs support parallel tool calling — the AI can request multiple tool executions simultaneously:

    • "What's the weather in Tokyo, London, and New York?" → 3 parallel get_weather calls
    • This reduces latency significantly for multi-step tasks

    Security Considerations

    • Principle of least privilege — Only give agents access to tools they need
    • Input validation — Always validate tool parameters before executing
    • Rate limiting — Prevent agents from making excessive API calls
    • Confirmation gates — Require human approval for destructive actions (delete, send, purchase)
    • Audit logging — Record every tool call for accountability

    Key Takeaways

    • •Function calling lets AI models invoke external APIs and tools
    • •You define tools with names, descriptions, and parameter schemas
    • •Agents can chain multiple tools together to complete complex tasks
    • •Parallel tool calling reduces latency for multi-step operations
    • •Always implement security: validation, rate limits, confirmation gates, and audit logs
    0 of 5 lessons marked complete

    Progress is kept in this browser only.