Extending AI capabilities through function calling and external tool integration.
Tool use (function calling) is the mechanism that transforms LLMs from text generators into capable agents. Instead of just producing text, models can invoke external functions β search the web, query databases, execute code, call APIs β and incorporate the results into their responses.
Every major provider now supports tool use: OpenAI, Anthropic, and Google each have their own function calling APIs. The pattern is universal: you define available tools with JSON schemas, the model decides when to call them, and your code executes the actual function and returns results.
Function Calling Basics
Define tools with name, description, and JSON Schema parameters. The model generates a structured tool call instead of text. Your code executes it and returns results for the model to use.
OpenAI Function Calling
tools array with function definitions. Supports parallel_tool_calls, tool_choice forcing, and strict mode for guaranteed schema adherence. The original and most widely adopted approach.
Anthropic Tool Use
Claude's tool_use blocks in the messages API. Supports nested tools, tool_choice (auto/any/tool), and streaming tool calls. Known for high accuracy in complex multi-tool scenarios.
Parallel Tool Calls
Models can invoke multiple tools simultaneously when tasks are independent. Searching multiple databases, calling several APIs at once. Dramatically speeds up agent workflows.
Multi-Step Tool Use
The model calls a tool, gets results, reasons about them, then calls another tool. This loop enables complex workflows: search β read β analyze β write. Most real tasks require multiple steps.
Building Custom Tools
Define tools for your specific domain: inventory lookup, CRM queries, internal API calls, data transformations. Good tool descriptions are critical β the model decides when to use tools based on descriptions.
MCP (Model Context Protocol)
Anthropic's open standard for connecting AI models to tools and data sources. Servers expose tools via a standard protocol, enabling plug-and-play tool integration across different AI applications.
Computer Use
Using the screen as a tool β the model sees screenshots and generates mouse/keyboard actions. Anthropic's computer use enables AI to operate any software, not just API-enabled ones.
Error Handling
Tools fail β APIs timeout, queries return errors, permissions are denied. Robust tool implementations return clear error messages so the model can retry, use alternatives, or explain the failure.
Security Considerations
Tool calls can have real-world side effects. Validate parameters, sanitize inputs, implement rate limits, and use principle of least privilege. Never give models unrestricted database write access.
Function CallingAPI feature allowing LLMs to invoke external functions with structured parameters instead of generating text.
JSON SchemaThe standard format for defining tool parameters β types, descriptions, required fields, enums.
MCPModel Context Protocol β Anthropic's open standard for connecting AI to tools and data sources.
Computer UseAI capability to control a computer by viewing screenshots and generating mouse/keyboard actions.