Skip to content
API referenceWeb search / Web fetch

Web search / Web fetch

Web search and page fetching: APIs, limits and cost.

Model protocol

Claude Messages: Web search and Web fetch

Anthropic Messages with and without a server prompt supports exactly two server tools. Claude API executes them, so your application does not send an ordinary client tool_result.

ToolExact typeRequired limits
Web searchweb_search_20250305max_uses: 1–5
Web fetchweb_fetch_20250910max_uses: 1–3; max_content_tokens: 1–25,000 (approximate, text only)
json
{
  "model": "claude-opus-5",
  "max_tokens": 2048,
  "tools": [
    {
      "type": "web_search_20250305",
      "name": "web_search",
      "max_uses": 3,
      "allowed_domains": ["docs.python.org"]
    },
    {
      "type": "web_fetch_20250910",
      "name": "web_fetch",
      "max_uses": 2,
      "max_content_tokens": 12000,
      "allowed_domains": ["docs.python.org"],
      "citations": {"enabled": true}
    }

Strict object shape

ObjectAllowed fields
Web searchtype, name, max_uses; optional allowed_domains or blocked_domains, allowed_callers
Web fetchWeb search fields + required max_content_tokens; optional citations
  • name must be exactly web_search or web_fetch; at most one server tool of each type is allowed per request. Guard accepts only the listed fields: unknown fields (including the official search option user_location) and other typed tool variants are rejected with 400.
  • If supplied, allowed_callers must be exactly ["direct"].
  • allowed_domains and blocked_domains are mutually exclusive. Each list accepts at most 100 ASCII domains, with no scheme, IP address, query/fragment, backslash, or wildcard in the hostname.
  • Web search may include an optional path after the domain, such as docs.python.org/3/*; Web fetch accepts a bare domain only, with no path.
  • Web fetch citations, when supplied, must be exactly {"enabled": true} or {"enabled": false} with no extra fields. Client tools must omit type or use type: "custom".

Limits

  • The client must pass the limits above explicitly. A value over the limit or an unknown server-tool version is rejected with 400 before execution.
  • Both tools first return server_tool_use, followed by the corresponding web_search_tool_result or web_fetch_tool_result; search citations are always on, while fetch citations are optional.
  • A tool failure may arrive inside a successful HTTP 200: find a tool-result block whose content.type ends in _tool_result_error, then read content.error_code.
  • Web fetch accepts a URL no longer than 250 characters that already appeared in a user message, client tool result, or earlier search/fetch result. It supports text, HTML, and PDF; sites that require JavaScript rendering are unsupported, and failed fetches consume max_uses.
  • A successful Web search with no matches returns content: []; this is not a tool error.

Pricing

ItemCharge
Web search$0.01 per provider-reported billed request + ordinary input tokens for generated content
Provider-nonbillable Web search errorNo $0.01 tool charge
Web fetchNo separate fee; fetched content is billed as input tokens

Kimi, Composer and Grok

  • Kimi. Search and page fetch live in two separate endpoints, POST /v1/kimi/search and POST /v1/kimi/fetch. They never call the model: they return text that you put into your next chat request yourself. There is no separate charge for them, you pay only for the tokens of that request. Request bodies, limits and error codes are on Kimi · Chat Completions.
  • Composer and Grok. Built-in web search is available during a reply. There is no separate public call for controlling this search; typed Anthropic server tools are not accepted. Client functions are supplied separately through tools and run by your client.

Documentation sections

On this page