Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Anthropics Anthropic sdk python BetaWebFetchTool 20250910

From Leeroopedia
Knowledge Sources
Domains API Types, Beta, Tools
Last Updated 2026-02-15 12:00 GMT

Overview

BetaWebFetchTool20250910Param is a TypedDict that defines the configuration parameters for the beta web fetch server tool. This tool allows Claude to fetch content from web URLs during a conversation, enabling retrieval of live web page data as part of an API request.

Description

The BetaWebFetchTool20250910Param class is a typed dictionary used to configure the web_fetch server tool in beta API requests. It has two required fields: name (always "web_fetch") and type (always "web_fetch_20250910"). The tool supports domain-level access control through allowed_domains and blocked_domains, content size limits via max_content_tokens, usage caps via max_uses, and optional citation configuration for fetched documents.

Additional configuration includes:

  • allowed_callers -- Restricts which callers may invoke the tool (e.g., "direct" or "code_execution_20250825").
  • cache_control -- Allows setting a cache control breakpoint at this content block.
  • citations -- Enables citations for fetched documents (disabled by default).
  • defer_loading -- When true, the tool is not included in the initial system prompt.
  • strict -- When true, guarantees schema validation on tool names and inputs.

Usage

Use BetaWebFetchTool20250910Param when you want to include the web fetch tool in a beta API request. Pass it as an element in the tools list of a message creation or token counting call. This is useful for:

  • Allowing Claude to retrieve live web page content during a conversation.
  • Restricting which domains Claude can or cannot fetch from.
  • Limiting the amount of content pulled from web pages via max_content_tokens.

Code Reference

Source Location

  • Repository: Anthropic SDK Python
  • File: src/anthropic/types/beta/beta_web_fetch_tool_20250910_param.py

Signature

class BetaWebFetchTool20250910Param(TypedDict, total=False):
    name: Required[Literal["web_fetch"]]
    type: Required[Literal["web_fetch_20250910"]]
    allowed_callers: List[Literal["direct", "code_execution_20250825"]]
    allowed_domains: Optional[SequenceNotStr[str]]
    blocked_domains: Optional[SequenceNotStr[str]]
    cache_control: Optional[BetaCacheControlEphemeralParam]
    citations: Optional[BetaCitationsConfigParam]
    defer_loading: bool
    max_content_tokens: Optional[int]
    max_uses: Optional[int]
    strict: bool

Import

from anthropic.types.beta import BetaWebFetchTool20250910Param

I/O Contract

Fields

Field Type Required Description
name Literal["web_fetch"] Yes Name of the tool. Always "web_fetch".
type Literal["web_fetch_20250910"] Yes Tool type identifier.
allowed_callers List[Literal["direct", "code_execution_20250825"]] No Which callers may invoke this tool.
allowed_domains Optional[SequenceNotStr[str]] No List of domains to allow fetching from.
blocked_domains Optional[SequenceNotStr[str]] No List of domains to block fetching from.
cache_control Optional[BetaCacheControlEphemeralParam] No Cache control breakpoint configuration.
citations Optional[BetaCitationsConfigParam] No Citations configuration for fetched documents. Disabled by default.
defer_loading bool No If true, tool is not included in the initial system prompt.
max_content_tokens Optional[int] No Maximum tokens for web page text content. Does not apply to binary content like PDFs.
max_uses Optional[int] No Maximum number of times the tool can be used in the request.
strict bool No When true, guarantees schema validation on tool names and inputs.

Usage Examples

import anthropic

client = anthropic.Anthropic()

response = client.beta.messages.create(
    model="claude-sonnet-4-20250514",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Fetch and summarize https://example.com"}],
    tools=[
        {
            "name": "web_fetch",
            "type": "web_fetch_20250910",
            "allowed_domains": ["example.com"],
            "max_content_tokens": 5000,
        }
    ],
    betas=["web-fetch-2025-09-10"],
)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment