Web Search and Web Fetch Tools

The Claude API's web search tool lets Claude search the web and cite its sources for $10 per 1,000 searches plus tokens, and the web fetch tool lets it read a given page or PDF for token costs only. Both are server tools that Anthropic runs during the request.

The Claude API has two server tools for live web content: web search (web_search), which runs searches and returns cited results for $10 per 1,000 searches plus the tokens of the results, and web fetch (web_fetch), which reads the full text of a web page or PDF for no extra charge beyond tokens (prices as of Nov 6, 2026). Both run on Anthropic's side during the request, so unlike ordinary Tool Use your code never executes them or sends back a result.

These are the developer versions of features the Claude apps offer to everyone; for the chat feature, see Web Search. Web search arrived on the API on May 7, 2025 and web fetch in beta on Sep 10, 2025.

Quick facts

Web search price $10 per 1,000 searches plus result tokens; a failed search is free
Web fetch price Tokens only: about 2,500 for a 10 kB page, 25,000 for a 100 kB docs page, 125,000 for a 500 kB PDF
Web search versions web_search_20250305 (basic), web_search_20260209 (dynamic filtering), web_search_20260318 (response inclusion) (Web search tool)
Web fetch versions web_fetch_20250910 (basic), 20260209 (dynamic filtering), 20260309 (cache bypass), 20260318 (response inclusion) (Web fetch tool)
Not on Amazon Bedrock (neither tool); Google managed has only basic web search and no web fetch
Admin switch The Console's Capabilities page turns either tool off and sets domain lists

How do you turn on web search in the Claude API?

Add the tool to tools. Claude decides when to search, the API runs the searches (several per turn if needed), and Claude answers with citations:

import anthropic

client = anthropic.Anthropic()

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

The options (Web search tool):

  • max_uses caps searches per turn. The docs say a single fact typically takes 1 to 3 searches and comparative research 10 or more; failed searches count against the cap.
  • allowed_domains or blocked_domains, never both (a 400 error). Entries are bare domains with an optional path, such as example.com/blog, with no https://.
  • user_location localizes results by city, region, a two-letter country code and an IANA timezone.

Every answer carries web_search_result_location citations with the URL, title and up to 150 characters of cited_text, and those citation fields do not count as tokens. When showing results to end users, Anthropic's docs say the citations must be shown too. Each result also carries encrypted_content, which must be sent back unchanged in later turns or the request fails.

How does web fetch work?

Web fetch takes a URL and returns the page's text, or a PDF as a document, which Claude then reads and can cite:

response = client.messages.create(
    model="claude-opus-5-5",
    max_tokens=4096,
    messages=[{"role": "user", "content": "Please analyze the content at https://example.com/article"}],
    tools=[{"type": "web_fetch_20250910", "name": "web_fetch", "max_uses": 5}],
)

Its options are max_uses (no default limit), the same domain lists, max_content_tokens to truncate long pages, citations (off by default, unlike search), use_cache: false for fresh content on web_fetch_20260309 and later, and url_sources to choose which parts of the conversation count as places a URL may come from (Web fetch tool).

Three limits matter in practice:

  1. Only URLs already in the conversation. To limit data exfiltration, Claude cannot fetch an address that appears only in its own output or only in the system prompt. It must come from a user message, a client tool result, or an earlier search or fetch result; otherwise the result is url_not_in_prior_context.
  2. No JavaScript. Sites rendered dynamically with JavaScript are not supported; the docs point to the browser use tool (see Computer Use) for those.
  3. Text, HTML and PDF only, and it obeys robots.txt and refuses private addresses (url_not_allowed). Fetched pages may be served from Anthropic's cache.

Anthropic's own warning: enabling web fetch where Claude handles untrusted input next to sensitive data "poses data exfiltration risks". Its suggestions are to turn the tool off, cap max_uses, or restrict allowed_domains.

Dynamic filtering

With web_search_20260209, web_fetch_20260209 or later, Claude writes and runs code that filters search results or fetched pages before they enter its context, keeping only the relevant parts and saving tokens on search-heavy work. It needs Claude 4.6 or later models. The API turns on the Code Execution Tool for this automatically, and that code execution is free when one of these tool versions is in the request. To call search directly without filtering, set allowed_callers: ["direct"]. Dynamic filtering is not covered by zero data retention or HIPAA, while basic web search and web fetch are eligible for zero data retention (Web search tool).

Errors and long turns

A failing search or fetch still returns HTTP 200; the error sits inside the result block, with codes such as max_uses_exceeded, too_many_requests, query_too_long, url_not_accessible, unsupported_content_type and content_too_large. A long turn may stop with stop_reason: "pause_turn"; send the assistant message back unchanged to continue (Server tools). If an organization admin has switched a tool off, a request that includes it fails with a 400 invalid_request_error.

Where they work

Both tools run fully on the Claude API, Claude Platform on AWS and Claude Models on Google Cloud (Anthropic managed). Microsoft Foundry deployments hosted on Azure get only the basic versions, and Google managed gets only basic web search (Web search tool; Web fetch tool). Neither is available on Amazon Bedrock (Claude in Amazon Bedrock). See Claude on Cloud Platforms. In Managed Agents, both are part of the default agent toolset.

Frequently asked questions

How much does Claude API web search cost? Claude API web search costs $10 per 1,000 searches plus normal token prices for the results Claude reads, as of Nov 6, 2026; a search that fails is not billed.

Is the Claude web fetch tool free? The Claude web fetch tool has no per-fetch fee: you pay only the input tokens of the fetched content, so capping max_content_tokens is the way to control cost.

Can I limit Claude web search to certain websites? Yes. Set allowed_domains (or blocked_domains) on the Claude web search tool; admins can also set organization-wide domain lists on the Console's Capabilities page.

Why can't Claude fetch a URL it found itself? Claude's web fetch tool only fetches URLs that already appeared in the conversation, such as in your message or a search result, so a prompt injection cannot make Claude send data to an address it invented.

Does Claude web search work on Amazon Bedrock? No. As of Nov 6, 2026, Amazon Bedrock does not offer Claude's web search or web fetch server tools.

Sources

See also

About this page

Last updated Nov 6, 2026 by the Vi.ki team. Page text CC BY-SA 4.0.

Edit History

Hotkeys

/
Jump to the search box
? or Ctrl + /
Open this list
Esc
Close this list, the photo viewer, or the account menu

Photo viewer

← → or A D
Previous or next photo
↑ ↓ or W S
Previous or next photo
Home End
First or last photo
I
Show or hide the photo's info
Z
Clickless on or off: a pointer over a thumbnail shows it
N
Compare with the last photo: back to the one shown before this, and N again comes back
Q
Move the thumbnails to the next edge: top, bottom, left and round
, or Ctrl + ,
Open or close the viewer's settings
V
Clickless pan: a zoomed photo follows the pointer, rather than being dragged
Shift
Browse on or off
B
Show or hide the button bar
T
Show or hide the thumbnails
1
100% zoom on or off
0
Rate the photo as no opinion; again takes the answer back
+ -
Rate the photo a step higher or lower
F
Full screen: the photo alone. F again puts everything back.
Back to top