Skip to content

Web Fetch

The WebFetch capability lets your agent fetch the contents of URLs. Like all provider-adaptive tools, it prefers the provider’s native web fetch tool and can fall back to a local implementation on other models.

WebFetch defaults to native-only. Backed by WebFetchTool on the native side (see Web Fetch Tool for provider support and configuration) — pass native=WebFetchTool(...) directly for full control.

For the local side, pass local=True for the bundled markdownify-based fetch tool (requires the web-fetch optional group), or any callable, Tool, or AbstractToolset.

Native constraint fields: allowed_domains, blocked_domains, max_uses, enable_citations, max_content_tokens. Only max_uses requires native; domain filters are enforced locally when native isn’t available.

web_fetch.py
from pydantic_ai.capabilities import WebFetch

# Native-only — raises on models without native web fetch
WebFetch()

# Native preferred; markdownify-based fallback (needs `pydantic-ai-slim[web-fetch]`)
WebFetch(local=True)

# Domain filters enforced locally when native isn't available
WebFetch(allowed_domains=['example.com'], local=True)