Loading...
  • ビルド
  • 管理
  • モデルと料金
  • クライアントSDK
  • APIリファレンス
Search...
⌘K
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
  • 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
  • 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
ビルド/ツール

Claudeでのツール使用

Claudeを外部ツールとAPIに接続します。ツールが実行される場所とエージェントループの仕組みについて学びます。

ツール使用により、Claudeは定義したまたはAnthropicが提供する関数を呼び出すことができます。Claudeはユーザーのリクエストとツールの説明に基づいてツールを呼び出すタイミングを決定し、アプリケーションが実行する(クライアントツール)またはAnthropicが実行する(サーバーツール)構造化された呼び出しを返します。

Anthropicが実行を処理するサーバーツールを使用した最も単純な例を以下に示します。

import anthropic

client = anthropic.Anthropic()
response = client.messages.create(
    model="claude-opus-4-7",
    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)

ツール使用の仕組み

ツールは主にコードが実行される場所によって異なります。クライアントツール(ユーザー定義ツールとbashやtext_editorなどのAnthropicスキーマツールを含む)はアプリケーション内で実行されます。Claudeはstop_reason: "tool_use"と1つ以上のtool_useブロックで応答し、コードが操作を実行してからtool_resultを返します。サーバーツール(web_search、code_execution、web_fetch、tool_search)はAnthropicのインフラストラクチャ上で実行されます。実行を処理することなく結果を直接確認できます。

エージェントループを含む完全な概念モデルと各アプローチを選択するタイミングについては、ツール使用の仕組みを参照してください。

MCPサーバーへの接続については、MCPコネクタを参照してください。独自のMCPクライアントを構築する場合は、modelcontextprotocol.ioを参照してください。

厳密なツール使用でスキーマ準拠を保証する

ツール定義にstrict: trueを追加して、Claudeのツール呼び出しが常にスキーマと正確に一致することを確認します。厳密なツール使用を参照してください。

ツールアクセスは、エージェントに提供できる最も高いレバレッジプリミティブの1つです。LAB-Bench FigQA(科学図の解釈)やSWE-bench(実世界のソフトウェアエンジニアリング)などのベンチマークでは、基本的なツールを追加するだけでも、人間の専門家のベースラインを上回ることが多い、不釣り合いな機能向上が得られます。


ツール使用の例

完全なハンズオンチュートリアルについては、チュートリアルを参照してください。個別の概念の参照例については、ツールの定義とツール呼び出しの処理を参照してください。


価格

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.7auto, none
any, tool
346 tokens
313 tokens
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.

現在のモデルごとの価格については、モデル概要表を参照してください。

ツール使用プロンプトを送信する場合、他のAPIリクエストと同様に、応答は報告されたusageメトリクスの一部として入力トークン数と出力トークン数の両方を出力します。


次のステップ

パスを選択する

概念を理解する

ツールが実行される場所、ループの仕組み、ツールを使用するタイミング。

段階的に構築する

チュートリアル:単一のツール呼び出しから本番環境まで。

すべてのツールを参照する

Anthropic提供ツールとプロパティのディレクトリ。

Was this page helpful?