Loading...
    • Developer Guide
    • API Reference
    • MCP
    • Resources
    • Release Notes
    Search...
    ⌘K
    First steps
    Intro to ClaudeQuickstart
    Models & pricing
    Models overviewChoosing a modelWhat's new in Claude 4.6Migration guideModel deprecationsPricing
    Build with Claude
    Features overviewUsing the Messages APIHandling stop reasonsPrompting best practices
    Model capabilities
    Extended thinkingAdaptive thinkingEffortFast mode (beta: research preview)Structured outputsCitationsStreaming MessagesBatch processingPDF supportSearch resultsMultilingual supportEmbeddingsVision
    Tools
    OverviewHow tool use worksTutorial: Build a tool-using agentDefine toolsHandle tool callsParallel tool useTool Runner (SDK)Strict tool useTool use with prompt cachingServer toolsTroubleshootingTool referenceWeb search toolWeb fetch toolCode execution toolMemory toolBash toolComputer use toolText editor tool
    Tool infrastructure
    Manage tool contextTool combinationsTool searchProgrammatic tool callingFine-grained tool streaming
    Context management
    Context windowsCompactionContext editingPrompt cachingToken counting
    Files & assets
    Files API
    Agent Skills
    OverviewQuickstartBest practicesSkills for enterpriseClaude API skillUsing Skills with the API
    Agent SDK
    OverviewQuickstartHow the agent loop works
    MCP in the API
    MCP connectorRemote MCP servers
    Claude on 3rd-party platforms
    Amazon BedrockMicrosoft FoundryVertex AI
    Prompt engineering
    OverviewConsole prompting tools
    Test & evaluate
    Define success and build evaluationsUsing the Evaluation ToolReducing latency
    Strengthen guardrails
    Reduce hallucinationsIncrease output consistencyMitigate jailbreaksStreaming refusalsReduce prompt leak
    Administration and monitoring
    Admin API overviewData residencyWorkspacesUsage and Cost APIClaude Code Analytics APIAPI and data retention
    Console
    Log in
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...
    Loading...

    Solutions

    • AI agents
    • Code modernization
    • Coding
    • Customer support
    • Education
    • Financial services
    • Government
    • Life sciences

    Partners

    • Amazon Bedrock
    • Google Cloud's Vertex AI

    Learn

    • Blog
    • Catalog
    • Courses
    • Use cases
    • Connectors
    • Customer stories
    • Engineering at Anthropic
    • Events
    • Powered by Claude
    • Service partners
    • Startups program

    Company

    • Anthropic
    • Careers
    • Economic Futures
    • Research
    • News
    • Responsible Scaling Policy
    • Security and compliance
    • Transparency

    Learn

    • Blog
    • Catalog
    • Courses
    • Use cases
    • Connectors
    • Customer stories
    • Engineering at Anthropic
    • Events
    • Powered by Claude
    • Service partners
    • Startups program

    Help and security

    • Availability
    • Status
    • Support
    • Discord

    Terms and policies

    • Privacy policy
    • Responsible disclosure policy
    • Terms of service: Commercial
    • Terms of service: Consumer
    • Usage policy
    Tools

    Tool use with Claude

    Connect Claude to external tools and APIs. Learn where tools execute and how the agentic loop works.

    Tool use lets Claude call functions you define or that Anthropic provides. Claude decides when to call a tool based on the user's request and the tool's description, then returns a structured call that your application executes (client tools) or that Anthropic executes (server tools).

    Here's the simplest example using a server tool, where Anthropic handles execution:

    import anthropic
    
    client = anthropic.Anthropic()
    response = client.messages.create(
        model="claude-opus-4-6",
        max_tokens=1024,
        tools=[{"type": "web_search_20260209", "name": "web_search"}],
        messages=[{"role": "user", "content": "What's the latest on the Mars rover?"}],
    )
    print(response.content)

    How tool use works

    Tools differ primarily by where the code executes. Client tools (including user-defined tools and Anthropic-schema tools like bash and text_editor) run in your application: Claude responds with stop_reason: "tool_use" and one or more tool_use blocks, your code executes the operation, and you send back a tool_result. Server tools (web_search, code_execution, web_fetch, tool_search) run on Anthropic's infrastructure: you see the results directly without handling execution.

    For the full conceptual model including the agentic loop and when to choose each approach, see How tool use works.

    For connecting to MCP servers, see the MCP connector. For building your own MCP client, see modelcontextprotocol.io.

    Guarantee schema conformance with strict tool use

    Add strict: true to your tool definitions to ensure Claude's tool calls always match your schema exactly. See Strict tool use.

    Tool access is one of the highest-leverage primitives you can give an agent. On benchmarks like LAB-Bench FigQA (scientific figure interpretation) and SWE-bench (real-world software engineering), adding even basic tools produces outsized capability gains, often surpassing human expert baselines.


    Tool use examples

    For a complete hands-on walkthrough, see the tutorial. For reference examples of individual concepts, see Define tools and Handle tool calls.


    Pricing

    Tool use requests are priced based on:

    1. The total number of input tokens sent to the model (including in the tools parameter)
    2. The number of output tokens generated
    3. For server-side tools, additional usage-based pricing (e.g., web search charges per search performed)

    Client-side tools are priced the same as any other Claude API request, while server-side tools may incur additional charges based on their specific usage.

    The additional tokens from tool use come from:

    • The tools parameter in API requests (tool names, descriptions, and schemas)
    • tool_use content blocks in API requests and responses
    • tool_result content blocks in API requests

    When you use tools, we also automatically include a special system prompt for the model which enables tool use. The number of tool use tokens required for each model are listed below (excluding the additional tokens listed above). Note that the table assumes at least 1 tool is provided. If no tools are provided, then a tool choice of none uses 0 additional system prompt tokens.

    ModelTool choiceTool use system prompt token count
    Claude Opus 4.6auto, none
    any, tool
    346 tokens
    313 tokens
    Claude Opus 4.5auto, none
    any, tool
    346 tokens
    313 tokens
    Claude Opus 4.1auto, none
    any, tool
    346 tokens
    313 tokens
    Claude Opus 4auto, none
    any, tool
    346 tokens
    313 tokens
    Claude Sonnet 4.6auto, none
    any, tool
    346 tokens
    313 tokens
    Claude Sonnet 4.5auto, none
    any, tool
    346 tokens
    313 tokens
    Claude Sonnet 4auto, none
    any, tool
    346 tokens
    313 tokens
    Claude Sonnet 3.7 (deprecated)auto, none
    any, tool
    346 tokens
    313 tokens
    Claude Haiku 4.5auto, none
    any, tool
    346 tokens
    313 tokens
    Claude Haiku 3.5auto, none
    any, tool
    264 tokens
    340 tokens
    Claude Opus 3 (deprecated)auto, none
    any, tool
    530 tokens
    281 tokens
    Claude Sonnet 3auto, none
    any, tool
    159 tokens
    235 tokens
    Claude Haiku 3auto, none
    any, tool
    264 tokens
    340 tokens

    These token counts are added to your normal input and output tokens to calculate the total cost of a request.

    Refer to the models overview table for current per-model prices.

    When you send a tool use prompt, just like any other API request, the response will output both input and output token counts as part of the reported usage metrics.


    Next steps

    Choose your path

    Understand the concepts

    Where tools run, how the loop works, and when to use tools.

    Build step by step

    The tutorial: from a single tool call to production.

    Browse all tools

    Directory of Anthropic-provided tools and properties.

    Was this page helpful?

    • How tool use works
    • Tool use examples
    • Pricing
    • Next steps
    • Choose your path