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 にリアルタイムのウェブコンテンツへの直接アクセスを提供し、知識カットオフを超えた最新情報で質問に答えることができます。レスポンスには検索結果から引き出されたソースの引用が含まれます。

最新のウェブ検索ツールバージョン(web_search_20260209)は、Claude Mythos Preview、Claude Opus 4.7、Claude Opus 4.6、Claude Sonnet 4.6 で動的フィルタリングをサポートしています。Claude は検索結果がコンテキストウィンドウに到達する前にフィルタリングするコードを書いて実行でき、関連情報のみを保持して残りを破棄します。これにより、トークン消費を削減しながらより正確なレスポンスが得られます。前のツールバージョン(web_search_20250305)は動的フィルタリングなしで引き続き利用可能です。

Claude Mythos Preview の場合、ウェブ検索は Claude API、Microsoft Foundry、Google Vertex AI でサポートされています。ウェブ検索は Amazon Bedrock の Mythos Preview では利用できません。

Zero Data Retention の適格性と allowed_callers の回避策については、Server tools を参照してください。

モデルサポートについては、Tool reference を参照してください。

ウェブ検索の仕組み

API リクエストにウェブ検索ツールを追加すると:

  1. Claude はプロンプトに基づいて検索するかどうかを決定します。
  2. API は検索を実行し、Claude に結果を提供します。このプロセスは単一のリクエスト内で複数回繰り返される場合があります。
  3. ターンの終わりに、Claude は引用されたソースを含む最終レスポンスを提供します。

動的フィルタリング

ウェブ検索はトークン集約的なタスクです。基本的なウェブ検索では、Claude は検索結果をコンテキストに取り込み、複数のウェブサイトから完全な HTML を取得し、答えに到達する前にすべてを推論する必要があります。多くの場合、このコンテンツの大部分は無関係であり、レスポンスの品質を低下させる可能性があります。

web_search_20260209 ツールバージョンでは、Claude はクエリ結果を後処理するコードを書いて実行できます。完全な HTML ファイルを推論する代わりに、Claude は検索結果をコンテキストに読み込む前に動的にフィルタリングし、関連するもののみを保持して残りを破棄します。

動的フィルタリングは特に以下に効果的です:

  • 技術ドキュメントの検索
  • 文献レビューと引用検証
  • 技術研究
  • レスポンスの根拠付けと検証

動的フィルタリングには code execution tool を有効にする必要があります。改善されたウェブ検索ツールは Claude API と Microsoft Azure で利用可能です。Google Vertex AI では、基本的なウェブ検索ツール(動的フィルタリングなし)が利用可能です。

動的フィルタリングを有効にするには、web_search_20260209 ツールバージョンを使用します:

client = anthropic.Anthropic()

response = client.messages.create(
    model="claude-opus-4-7",
    max_tokens=4096,
    messages=[
        {
            "role": "user",
            "content": "Search for the current prices of AAPL and GOOGL, then calculate which has a better P/E ratio.",
        }
    ],
    tools=[{"type": "web_search_20260209", "name": "web_search"}],
)
print(response)

ウェブ検索の使い方

組織の管理者が Claude Console でウェブ検索を有効にする必要があります。

API リクエストでウェブ検索ツールを提供します:

client = anthropic.Anthropic()

response = client.messages.create(
    model="claude-opus-4-7",
    max_tokens=1024,
    messages=[{"role": "user", "content": "What's the weather in NYC?"}],
    tools=[{"type": "web_search_20250305", "name": "web_search", "max_uses": 5}],
)
print(response)

ツール定義

ウェブ検索ツールは以下のパラメータをサポートしています:

JSON
{
  "type": "web_search_20250305",
  "name": "web_search",

  // オプション:リクエストごとの検索数を制限
  "max_uses": 5,

  // オプション:これらのドメインからの結果のみを含める
  "allowed_domains": ["example.com", "trusteddomain.org"],

  // オプション:これらのドメインからの結果を除外
  "blocked_domains": ["untrustedsource.com"],

  // オプション:検索結果をローカライズ
  "user_location": {
    "type": "approximate",
    "city": "San Francisco",
    "region": "California",
    "country": "US",
    "timezone": "America/Los_Angeles"
  }
}

Max uses

max_uses パラメータは実行される検索数を制限します。Claude が許可された数を超える検索を試みた場合、web_search_tool_result は max_uses_exceeded エラーコードを持つエラーになります。

ドメインフィルタリング

allowed_domains と blocked_domains を使用したドメインフィルタリングについては、Server tools を参照してください。

ローカライゼーション

user_location パラメータを使用すると、ユーザーの位置情報に基づいて検索結果をローカライズできます。

  • type:位置情報のタイプ(approximate である必要があります)
  • city:都市名
  • region:地域または州
  • country:国
  • timezone:IANA タイムゾーン ID。

レスポンス

レスポンス構造の例を以下に示します:

Output
{
  "role": "assistant",
  "content": [
    // 1. Claude の検索決定
    {
      "type": "text",
      "text": "I'll search for when Claude Shannon was born."
    },
    // 2. 使用された検索クエリ
    {
      "type": "server_tool_use",
      "id": "srvtoolu_01WYG3ziw53XMcoyKL4XcZmE",
      "name": "web_search",
      "input": {
        "query": "claude shannon birth date"
      }
    },
    // 3. 検索結果
    {
      "type": "web_search_tool_result",
      "tool_use_id": "srvtoolu_01WYG3ziw53XMcoyKL4XcZmE",
      "content": [
        {
          "type": "web_search_result",
          "url": "https://en.wikipedia.org/wiki/Claude_Shannon",
          "title": "Claude Shannon - Wikipedia",
          "encrypted_content": "EqgfCioIARgBIiQ3YTAwMjY1Mi1mZjM5LTQ1NGUtODgxNC1kNjNjNTk1ZWI3Y...",
          "page_age": "April 30, 2025"
        }
      ]
    },
    {
      "text": "Based on the search results, ",
      "type": "text"
    },
    // 4. 引用を含む Claude のレスポンス
    {
      "text": "Claude Shannon was born on April 30, 1916, in Petoskey, Michigan",
      "type": "text",
      "citations": [
        {
          "type": "web_search_result_location",
          "url": "https://en.wikipedia.org/wiki/Claude_Shannon",
          "title": "Claude Shannon - Wikipedia",
          "encrypted_index": "Eo8BCioIAhgBIiQyYjQ0OWJmZi1lNm..",
          "cited_text": "Claude Elwood Shannon (April 30, 1916 – February 24, 2001) was an American mathematician, electrical engineer, computer scientist, cryptographer and i..."
        }
      ]
    }
  ],
  "id": "msg_a930390d3a",
  "usage": {
    "input_tokens": 6039,
    "output_tokens": 931,
    "server_tool_use": {
      "web_search_requests": 1
    }
  },
  "stop_reason": "end_turn"
}

検索結果

検索結果には以下が含まれます:

  • url:ソースページの URL
  • title:ソースページのタイトル
  • page_age:サイトが最後に更新された時期
  • encrypted_content:マルチターン会話で引用のために返す必要がある暗号化されたコンテンツ

引用

引用はウェブ検索で常に有効になっており、各 web_search_result_location には以下が含まれます:

  • url:引用されたソースの URL
  • title:引用されたソースのタイトル
  • encrypted_index:マルチターン会話で返す必要がある参照。
  • cited_text:引用されたコンテンツの最大 150 文字

ウェブ検索の引用フィールド cited_text、title、url は入力または出力トークン使用量にカウントされません。

API 出力をエンドユーザーに直接表示する場合、元のソースへの引用を含める必要があります。API 出力を修正する場合(再処理や独自のマテリアルとの組み合わせを含む)、エンドユーザーに表示する前に、法務チームとの相談に基づいて適切に引用を表示してください。

エラー

ウェブ検索ツールがエラーに遭遇した場合(レート制限に達するなど)、Claude API は依然として 200(成功)レスポンスを返します。エラーは以下の構造を使用してレスポンス本体内で表現されます:

Output
{
  "type": "web_search_tool_result",
  "tool_use_id": "servertoolu_a93jad",
  "content": {
    "type": "web_search_tool_result_error",
    "error_code": "max_uses_exceeded"
  }
}

可能なエラーコードは以下の通りです:

  • too_many_requests:レート制限を超過
  • invalid_input:無効な検索クエリパラメータ
  • max_uses_exceeded:ウェブ検索ツールの最大使用回数を超過
  • query_too_long:クエリが最大長を超過
  • unavailable:内部エラーが発生

pause_turn ストップ理由

pause_turn ストップ理由の後に続行するには、Server tools を参照してください。

プロンプトキャッシング

ターン全体でツール定義をキャッシュするには、Tool use with prompt caching を参照してください。

ストリーミング

ストリーミングが有効になっている場合、ストリームの一部として検索イベントを受け取ります。検索の実行中に一時停止があります:

Output
event: message_start
data: {"type": "message_start", "message": {"id": "msg_abc123", "type": "message"}}

event: content_block_start
data: {"type": "content_block_start", "index": 0, "content_block": {"type": "text", "text": ""}}

// Claude の検索決定

event: content_block_start
data: {"type": "content_block_start", "index": 1, "content_block": {"type": "server_tool_use", "id": "srvtoolu_xyz789", "name": "web_search"}}

// 検索クエリがストリーム
event: content_block_delta
data: {"type": "content_block_delta", "index": 1, "delta": {"type": "input_json_delta", "partial_json": "{\"query\":\"latest quantum computing breakthroughs 2025\"}"}}

// 検索実行中に一時停止

// 検索結果がストリーム
event: content_block_start
data: {"type": "content_block_start", "index": 2, "content_block": {"type": "web_search_tool_result", "tool_use_id": "srvtoolu_xyz789", "content": [{"type": "web_search_result", "title": "Quantum Computing Breakthroughs in 2025", "url": "https://example.com"}]}}

// 引用を含む Claude のレスポンス(この例では省略)

バッチリクエスト

Messages Batches API にウェブ検索ツールを含めることができます。Messages Batches API を通じたウェブ検索ツール呼び出しは、通常の Messages API リクエストと同じ価格です。

使用方法と価格

Web search usage is charged in addition to token usage:

"usage": {
  "input_tokens": 105,
  "output_tokens": 6039,
  "cache_read_input_tokens": 7123,
  "cache_creation_input_tokens": 7345,
  "server_tool_use": {
    "web_search_requests": 1
  }
}

Web search is available on the Claude API for $10 per 1,000 searches, plus standard token costs for search-generated content. Web search results retrieved throughout a conversation are counted as input tokens, in search iterations executed during a single turn and in subsequent conversation turns.

Each web search counts as one use, regardless of the number of results returned. If an error occurs during web search, the web search will not be billed.

次のステップ

Server tools

Anthropic が実行するツールの共有メカニクス。

Tool reference

すべての Anthropic 提供ツールのディレクトリ。

Was this page helpful?