Claude APIの新しいAPI「Web Fetch」の内容をWeb Fetchを使って要約してみる

Claude APIの新しいAPI「Web Fetch」の内容をWeb Fetchを使って要約してみる

2025.09.11

こんにちは、せーのです。

今日は先程Anthropicから発表されたAPIの新機能「Web fetch tool」が出ましたので、早速使ってみたいと思います。

どんな機能

ということで早速
ドキュメントページ
を開いてみました。

webfetchtool1.png

これは、、、結構長い。
しかも結構パラメータがある。

「Web fetch tool」というくらいなのだから、おそらく Webを読み込む機能なのだと踏んでいます。
とりあえずこのページを読み込んでみて、どんな機能なのか確かめてみることにします。

とりあえず動かしてみる

ドキュメントページをスクロールしていくと、主要な言語による動かし方が書いてあります。
とりあえずサクッと、ということでShellでやってみます。

			
			curl https://api.anthropic.com/v1/messages \
    --header "x-api-key: $ANTHROPIC_API_KEY" \
    --header "anthropic-version: 2023-06-01" \
    --header "anthropic-beta: web-fetch-2025-09-10" \
    --header "content-type: application/json" \
    --data '{
        "model": "claude-opus-4-1-20250805",
        "max_tokens": 1024,
        "messages": [
            {
                "role": "user",
                "content": "Please analyze the content at https://example.com/article"
            }
        ],
        "tools": [{
            "type": "web_fetch_20250910",
            "name": "web_fetch",
            "max_uses": 5
        }]
    }'

		

API KEYのところを実際のAPI KEYに置き換えて叩いてみます。

			
			curl https://api.anthropic.com/v1/messages \
    --header "x-api-key: XXXXXXXXX" \
    --header "anthropic-version: 2023-06-01" \
    --header "anthropic-beta: web-fetch-2025-09-10" \
    --header "content-type: application/json" \
    --data '{
        "model": "claude-opus-4-1-20250805",
        "max_tokens": 1024,
        "messages": [
            {
                "role": "user",
                "content": "このページを日本語で要約してください。パラメータの説明など実際に使う時に必要な情報、重要なところは削らないでください。 https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/web-fetch-tool"
            }
        ],
        "tools": [{
            "type": "web_fetch_20250910",
            "name": "web_fetch",
            "max_uses": 5
        }]
    }'

		

すると、何やらとっても長いレスポンスが返ってきました。

			
			{
	"id": "msg_01VsnhiGc8hb2osYx31aPQyf",
	"type": "message",
	"role": "assistant",
	"model": "claude-opus-4-1-20250805",
	"content": [
		{
			"type": "server_tool_use",
			"id": "srvtoolu_013AhtXDEm12ro9uce69if9m",
			"name": "web_fetch",
			"input": {
				"url": "https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/web-fetch-tool"
			}
		},
		{
			"type": "web_fetch_tool_result",
			"tool_use_id": "srvtoolu_013AhtXDEm12ro9uce69if9m",
			"content": {
				"type": "web_fetch_result",
				"url": "https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/web-fetch-tool",
				"retrieved_at": "2025-09-10T16:55:29.387000+00:00",
				"content": {
					"type": "document",
					"source": {
						"type": "text",
						"media_type": "text/plain",
						"data": "Web fetch tool\nThe web fetch tool allows Claude to retrieve full content from specified web pages and PDF documents.\nThe web fetch tool is currently in beta. To enable it, use the beta header web-fetch-2025-09-10\nin your API requests.\nPlease use [this form](https://forms.gle/NhWcgmkcvPCMmPE86) to provide feedback on the quality of the model responses, the API itself, or the quality of the documentation.\nEnabling the web fetch tool in environments where Claude processes untrusted input alongside sensitive data poses data exfiltration risks. We recommend only using this tool in trusted environments or when handling non-sensitive data.\nTo minimize exfiltration risks, Claude is not allowed to dynamically construct URLs. Claude can only fetch URLs that have been explicitly provided by the user or that come from previous web search or web fetch results. However, there is still residual risk that should be carefully considered when using this tool.\nIf data exfiltration is a concern, consider:\n- Disabling the web fetch tool entirely\n- Using the\nmax_uses\nparameter to limit the number of requests - Using the\nallowed_domains\nparameter to restrict to known safe domains\nSupported models\nWeb fetch is available on:\n- Claude Opus 4.1 (\nclaude-opus-4-1-20250805\n) - Claude Opus 4 (\nclaude-opus-4-20250514\n) - Claude Sonnet 4 (\nclaude-sonnet-4-20250514\n) - Claude Sonnet 3.7 (\nclaude-3-7-sonnet-20250219\n) - Claude Sonnet 3.5 v2 (\n[deprecated](/en/docs/about-claude/model-deprecations)) (claude-3-5-sonnet-latest\n) - Claude Haiku 3.5 (\nclaude-3-5-haiku-latest\n)\nHow web fetch works\nWhen you add the web fetch tool to your API request:\n- Claude decides when to fetch content based on the prompt and available URLs.\n- The API retrieves the full text content from the specified URL.\n- For PDFs, automatic text extraction is performed.\n- Claude analyzes the fetched content and provides a response with optional citations.\nHow to use web fetch\nProvide the web fetch tool in your API request:\nTool definition\nThe web fetch tool supports the following parameters:\nMax uses\nThe max_uses\nparameter limits the number of web fetches performed. If Claude attempts more fetches than allowed, the web_fetch_tool_result\nwill be an error with the max_uses_exceeded\nerror code. There is currently no default limit.\nDomain filtering\nWhen using domain filters:\n- Domains should not include the HTTP/HTTPS scheme (use\nexample.com\ninstead ofhttps://example.com\n) - Subdomains are automatically included (\nexample.com\ncoversdocs.example.com\n) - Subpaths are supported (\nexample.com/blog\n) - You can use either\nallowed_domains\norblocked_domains\n, but not both in the same request.\nBe aware that Unicode characters in domain names can create security vulnerabilities through homograph attacks, where visually similar characters from different scripts can bypass domain filters. For example, аmazon.com\n(using Cyrillic ‘а’) may appear identical to amazon.com\nbut represents a different domain.\nWhen configuring domain allow/block lists:\n- Use ASCII-only domain names when possible\n- Consider that URL parsers may handle Unicode normalization differently\n- Test your domain filters with potential homograph variations\n- Regularly audit your domain configurations for suspicious Unicode characters\nContent limits\nThe max_content_tokens\nparameter limits the amount of content that will be included in the context. If the fetched content exceeds this limit, it will be truncated. This helps control token usage when fetching large documents.\nThe max_content_tokens\nparameter limit is approximate. The actual number of input tokens used can vary by a small amount.\nCitations\nUnlike web search where citations are always enabled, citations are optional for web fetch. Set \"citations\": {\"enabled\": true}\nto enable Claude to cite specific passages from fetched documents.\nWhen displaying web results or information contained in web results to end users, inline citations must be made clearly visible and clickable in your user interface.\nResponse\nHere’s an example response structure:\nFetch results\nFetch results include:\nurl\n: The URL that was fetchedcontent\n: A document block containing the fetched contentretrieved_at\n: Timestamp when the content was retrieved\nThe web fetch tool caches results to improve performance and reduce redundant requests. This means the content returned may not always be the latest version available at the URL. The cache behavior is managed automatically and may change over time to optimize for different content types and usage patterns.\nFor PDF documents, the content will be returned as base64-encoded data:\nErrors\nWhen the web fetch tool encounters an error, the Anthropic API returns a 200 (success) response with the error represented in the response body:\nThese are the possible error codes:\ninvalid_input\n: Invalid URL formaturl_too_long\n: URL exceeds maximum length (250 characters)url_not_allowed\n: URL blocked by domain filtering rules and model restrictionsurl_not_accessible\n: Failed to fetch content (HTTP error)too_many_requests\n: Rate limit exceededunsupported_content_type\n: Content type not supported (only text and PDF)max_uses_exceeded\n: Maximum web fetch tool uses exceededunavailable\n: An internal error occurred\nURL validation\nFor security reasons, the web fetch tool can only fetch URLs that have previously appeared in the conversation context. This includes:\n- URLs in user messages\n- URLs in client-side tool results\n- URLs from previous web search or web fetch results\nThe tool cannot fetch arbitrary URLs that Claude generates or URLs from container-based server tools (Code Execution, Bash, etc.).\nCombined search and fetch\nWeb fetch works seamlessly with web search for comprehensive information gathering:\nIn this workflow, Claude will:\n- Use web search to find relevant articles\n- Select the most promising results\n- Use web fetch to retrieve full content\n- Provide detailed analysis with citations\nPrompt caching\nWeb fetch works with [prompt caching](/en/docs/build-with-claude/prompt-caching). To enable prompt caching, add cache_control\nbreakpoints in your request. Cached fetch results can be reused across conversation turns.\nStreaming\nWith streaming enabled, fetch events are part of the stream with a pause during content retrieval:\nBatch requests\nYou can include the web fetch tool in the [Messages Batches API](/en/docs/build-with-claude/batch-processing). Web fetch tool calls through the Messages Batches API are priced the same as those in regular Messages API requests.\nUsage and pricing\nWeb fetch usage has no additional charges beyond standard token costs:\nThe web fetch tool is available on the Anthropic API at no additional cost. You only pay standard token costs for the fetched content that becomes part of your conversation context.\nTo protect against inadvertently fetching large content that would consume excessive tokens, use the max_content_tokens\nparameter to set appropriate limits based on your use case and budget considerations.\nExample token usage for typical content:\n- Average web page (10KB): ~2,500 tokens\n- Large documentation page (100KB): ~25,000 tokens\n- Research paper PDF (500KB): ~125,000 tokens"
					},
					"title": "Web fetch tool - Anthropic"
				}
			}
		},
		{
			"type": "text",
			"text": "## Web Fetch ツールの日本語要約\n\n### 概要\nWeb Fetchツールは、Claudeが指定されたWebページやPDFドキュメントから完全なコンテンツを取得できるようにするツールです。\n\n**重要な注意事項:**\n- 現在ベータ版\n- APIリクエストでベータヘッダー `web-fetch-2025-09-10` を使用して有効化する必要があります\n- 信頼できない入力と機密データを同時に処理する環境では、データ流出のリスクがあります\n\n### サポートされているモデル\n以下のClaudeモデルで利用可能:\n- Claude Opus 4.1 (`claude-opus-4-1-20250805`)\n- Claude Opus 4 (`claude-opus-4-20250514`)\n- Claude Sonnet 4 (`claude-sonnet-4-20250514`)\n- Claude Sonnet 3.7 (`claude-3-7-sonnet-20250219`)\n- Claude Sonnet 3.5 v2 (非推奨) (`claude-3-5-sonnet-latest`)\n- Claude Haiku 3.5 (`claude-3-5-haiku-latest`)\n\n### 主要なパラメータ\n\n#### 1. **max_uses**\n- Web fetchの実行回数を制限\n- 制限を超えるとエラーコード `max_uses_exceeded` が返される\n- デフォルト制限なし\n\n#### 2. **ドメインフィルタリング**\n- **allowed_domains**: 許可するドメインのリスト\n- **blocked_domains**: ブロックするドメインのリスト\n- 両方を同時に使用することはできません\n\n**ドメイン指定の注意点:**\n- HTTPスキーマを含めない(`https://example.com` ではなく `example.com`)\n- サブドメインは自動的に含まれる(`example.com` は `docs.example.com` をカバー)\n- サブパスもサポート(`example.com/blog`)\n- Unicode文字によるホモグラフ攻撃に注意が必要\n\n#### 3. **max_content_tokens**\n- 取得コンテンツのトークン数制限\n- 制限を超えると切り詰められる\n- 大きなドキュメントのトークン使用量制御に有効\n- 実際のトークン数は若干変動する可能性あり\n\n#### 4. **citations**\n- `\"citations\": {\"enabled\": true}` で引用を有効化\n- Web searchと異なり、Web fetchでは引用はオプション\n- エンドユーザーに表示する際は、引用を明確にクリック可能にする必要がある\n\n### レスポンス構造\n\n取得結果には以下が含まれます:\n- `url`: 取得したURL\n- `content`: 取得したコンテンツを含むドキュメントブロック\n- `retrieved_at`: コンテンツ取得時のタイムスタンプ\n\nPDFの場合、コンテンツはbase64エンコードされたデータとして返されます。\n\n### エラーコード\n- `invalid_input`: 無効なURL形式\n- `url_too_long`: URLが最大長(250文字)を超過\n- `url_not_allowed`: ドメインフィルタリングルールでブロック\n- `url_not_accessible`: コンテンツ取得失敗(HTTPエラー)\n- `too_many_requests`: レート制限超過\n- `unsupported_content_type`: サポートされていないコンテンツタイプ\n- `max_uses_exceeded`: 最大使用回数超過\n-"
		}
	],
	"stop_reason": "max_tokens",
	"stop_sequence": null,
	"usage": {
		"input_tokens": 3702,
		"cache_creation_input_tokens": 0,
		"cache_read_input_tokens": 0,
		"cache_creation": {
			"ephemeral_5m_input_tokens": 0,
			"ephemeral_1h_input_tokens": 0
		},
		"output_tokens": 1104,
		"service_tier": "standard",
		"server_tool_use": {
			"web_search_requests": 0,
			"web_fetch_requests": 1
		}
	}
}

		

おそらくこの日本語の部分が欲しい回答だと思います。
が、このままでは改行がエスケープされていて読みにくいので、読みやすく整形してみます。

			
			Web Fetch ツールの日本語要約

概要

Web Fetchツールは、Claudeが指定されたWebページやPDFドキュメントから完全なコンテンツを取得できるツールです。
重要事項: 現在ベータ版であり、APIリクエスト時にベータヘッダー web-fetch-2025-09-10 を使用する必要があります。信頼できない入力と機密データを同時に扱う環境では、データ流出リスクがあります。

サポートされているモデル

以下のClaudeモデルで利用可能です:Claude Opus 4.1 (claude-opus-4-1-20250805)、Opus 4 (claude-opus-4-20250514)、Sonnet 4 (claude-sonnet-4-20250514)、Sonnet 3.7 (claude-3-7-sonnet-20250219)、Sonnet 3.5 v2(非推奨、claude-3-5-sonnet-latest)、Haiku 3.5 (claude-3-5-haiku-latest)。

主要パラメータ

1. max_uses:実行回数の制限。上限を超えると max_uses_exceeded エラーが返ります。デフォルトでは制限なし。

2. ドメインフィルタリング:
	•	allowed_domains:許可するドメインのリスト
	•	blocked_domains:ブロックするドメインのリスト(※両方同時使用不可)
※https://などは含めず、example.com の形式で指定。example.com を指定すると docs.example.com などのサブドメインも含まれます。example.com/blog のようなサブパス指定も可能です。Unicodeによるホモグラフ攻撃への注意が必要です。

1. max_content_tokens:取得するコンテンツのトークン数を制限。超過すると切り詰められます。大規模ドキュメントの扱いに有効で、実際のトークン数には若干の変動があります。

2. citations:"citations": {"enabled": true} で引用を有効にできます。Web searchとは異なり引用は任意。エンドユーザーに表示する際は、引用を明示的かつクリック可能にする必要があります。

レスポンス構造

取得結果には以下が含まれます:
	•	url: 取得したURL
	•	content: 取得したコンテンツ(テキストまたはbase64 PDF)
	•	retrieved_at: 取得時のタイムスタンプ

エラーコード一覧

エラーコード	内容
invalid_input	無効なURL形式
url_too_long	URLが250文字を超過
url_not_allowed	ドメインフィルタリングでブロックされた
url_not_accessible	コンテンツにアクセスできない(HTTPエラー等)
too_many_requests	レート制限を超過
unsupported_content_type	非対応のコンテンツタイプ
max_uses_exceeded	最大使用回数を超過

		

だいぶ読みやすくなりました。

ということで読んでみると

  • Web Fetchツールは、Claudeが指定されたWebページやPDFドキュメントから「完全なコンテンツ」を取得できるツール
  • 実行回数の制限や許可ドメイン、ブロックドメインの機能がある。多分セキュリティやキャップの役割
  • 引用を有効にできる
  • PDFの場合base64形式で返される

ということがわかりました。

Web Search機能だとClaude側で引用情報が決められたり、内容をClaude側で判断して組み替えてしまいますが、Web fetchを使うことで「全文」を持ってこられるので、その後分析するもよし、DBに要約を入れるもよし、と使い勝手の幅が広がりそうですね。

まとめ

Web Fetchは「指定URLの全文取得」によって、原文の文脈や根拠を保ったまま分析・引用できるのが強みです。ベータ提供ゆえ、allowed_domains / blocked_domainsmax_usesmax_content_tokenscitations の設計を前提に、安全とコストをコントロールして使うのがコツだと感じました。検索で“見つける”のはWeb Search、精読と“根拠付きで扱う”のはWeb Fetch、という棲み分けが良さそうです。

要点

  • 重要なのは「全文をそのまま持てる」こと。引用を有効化すれば根拠提示もしやすい
  • 安全設計が前提:許可ドメイン・最大回数・トークン上限でガード
  • 大きなPDFはトークン消費が重いので max_content_tokens で上限設定
  • キャッシュの可能性があるため、最新性が重要な場合は別途確認フローを用意

使えそうなユースケース

  • ドキュメント/マニュアルの要約・比較・変更点抽出(リリースノート取り込みなど)
  • 研究論文・技術ブログの要点抽出とレポート作成(引用ONで根拠明示)
  • 契約書・規約PDFの条項抽出と差分レビュー(監査ログに引用を残す)
  • 競合サイトや公式ドキュメントの更新監視→定期サマリ配信
  • 社内ナレッジ/RAGの前処理(正規化・要約・チャンク化)
  • カスタマーサポートの一次情報リンク付きテンプレ回答生成
  • 教材ページからの小テスト/フラッシュカード自動生成

注意点

  • 機密データと同居させない運用(信頼できる環境での利用)
  • ドメインのホモグラフ対策:ASCIIのみの指定・正規化の考慮
  • 最新性が要る場合はキャッシュ想定で検証手段を併用
  • 予算管理:大型コンテンツは早めにトークン上限でガード

以上、まずは小さなスコープで安全設計を効かせつつ、Web Searchとの併用で「発見→全文精読→根拠付きアウトプット」の流れを作ると、早い段階から効果が出しやすいと思います。

Share this article

FacebookHatena blogX
Claude APIの新しいAPI「Web Fetch」の内容をWeb Fetchを使って要約してみる | DevelopersIO