Tool use / function calling
Tool use (also called function calling) is a mechanism that lets Claude interact with external functions, APIs, and services you define. When you include tool definitions in your API request, Claude can decide to call one of those tools during its response — pausing text generation and returning a structured JSON request for your application to execute. Your application runs the function, returns the result, and Claude uses that result to continue its response.
There are two categories of tools: client tools, where your application handles execution (custom functions, database lookups, third-party API calls), and server tools, where Anthropic handles execution on its own infrastructure (web search, code execution, web fetch). Client tools require you to build an 'agentic loop' — a cycle of sending a request, receiving a tool_use block, executing the function, returning a tool_result, and sending the updated conversation back to Claude.
Tool use extends Claude beyond text generation into real-world task completion. Claude can retrieve live data it was not trained on, execute code, query databases, call APIs, and chain multiple tools together across complex multi-step workflows. The model never executes tools directly — it only decides when to call them and with what arguments, while your application or Anthropic's infrastructure handles the actual execution.
When you’d use it
- ◆Structured data extraction — A developer needs to parse unstructured customer feedback emails into a consistent database format. By defining a tool with the target schema and setting tool_choice to force its use, Claude reliably outputs structured JSON matching the schema — no regex or fragile text parsing needed.
- ◆Real-time data retrieval — A customer service bot needs to answer questions about live order status, inventory levels, and shipping ETAs. Tool definitions for each internal API endpoint let Claude decide which data to fetch, call the right function with correct parameters, and compose a natural-language answer from the results.
- ◆Multi-step task orchestration — A project management agent receives 'Create a task for Alice and post a summary to Slack.' It calls create_task(), then assign_task() with the returned task ID, then post_to_slack() with the task summary — adapting its approach if any intermediate step returns an error.
- ◆Agentic code execution and data analysis — Using Anthropic's server-side code execution tool, Claude receives a CSV file, writes Python to load it with pandas, calculates revenue by product, identifies trends, and generates a matplotlib chart — iterating on its code based on execution output until the analysis is complete, all within a single API session.
- ◆Large-scale tool discovery — An enterprise application exposes thousands of internal API endpoints. Rather than stuffing all definitions into every request (consuming massive tokens), the tool search server tool lets Claude search an index of available tools and load only the ones relevant to the current task.
What changed recently
- ◆2025-11-20 — Advanced tool use features entered beta, including tool search (lets Claude search thousands of tools without loading all definitions into context), programmatic tool calling, and the 'advanced-tool-use-2025-11-20' beta header. Tool definitions gained 'defer_loading', 'allowed_callers', and 'input_examples' fields.
- ◆2025-10-02 — Agent Skills entered beta (skills-2025-10-02). Skills are organized folders of instructions, scripts, and resources that Claude loads dynamically to perform specialized tasks, extending tool use with reusable capability packages.
- ◆2025-05-22 — Code execution tool entered public beta alongside the MCP connector, Files API, and 1-hour prompt caching. The code execution server tool (type: 'code_execution_20250825') lets Claude run Python in a sandboxed environment managed by Anthropic.
- ◆2025-01-29 — Structured Outputs reached General Availability. The beta header is no longer required. The legacy 'output_format' parameter was deprecated and replaced with 'output_config.format'.
This is the short version
The full chapter has three worked examples, the common pitfalls, and the workflow that makes it pay — plus the other 84 features, kept current.
Get Claude Master — $97 →