πŸ€– AI Tools
Β· 1 min read

What is Tool Calling? How AI Models Use External Tools


Tool calling (also called function calling) is how AI models execute actions in the real world. Instead of just generating text, the model outputs a structured request to call a specific function with specific parameters.

How it works

User: "What's the weather in Tokyo?"
    ↓
Model decides to call: get_weather(city="Tokyo")
    ↓
Your code executes the function
    ↓
Result: {temp: 22, condition: "sunny"}
    ↓
Model: "It's 22Β°C and sunny in Tokyo."

The model doesn’t execute the function itself β€” it tells YOUR code what to call. You execute it and return the result.

Why it matters

Tool calling is the foundation of:

  • MCP β€” the standard protocol for AI tool integration
  • AI agents β€” agents that read files, run tests, deploy code
  • RAG β€” retrieving documents before generating answers
  • AI coding tools β€” Claude Code, Aider, Cursor

Example (OpenAI format)

response = client.chat.completions.create(
    model="gpt-5.4",
    messages=[{"role": "user", "content": "Check if my server is up"}],
    tools=[{
        "type": "function",
        "function": {
            "name": "check_server",
            "parameters": {
                "type": "object",
                "properties": {"url": {"type": "string"}},
                "required": ["url"]
            }
        }
    }]
)

Learn more

Related: Best Hosting for AI Projects