Web Fetch

Code

1from kern.agent import Agent
2from kern.models.anthropic import Claude
3
4agent = Agent(
5 model=Claude(
6 id="claude-opus-4-1-20250805",
7 betas=["web-fetch-2025-09-10"],
8 ),
9 tools=[
10 {
11 "type": "web_fetch_20250910",
12 "name": "web_fetch",
13 "max_uses": 5,
14 }
15 ],
16 markdown=True,
17)
18
19agent.print_response(
20 "Tell me more about https://en.wikipedia.org/wiki/Glacier_National_Park_(U.S.)",
21 stream=True,
22)

Usage

Set up your virtual environment

1uv venv --python 3.12
2source .venv/bin/activate
1uv venv --python 3.12
2.venv\Scripts\activate

Set your API key

1export ANTHROPIC_API_KEY=xxx

Install dependencies

1uv pip install -U anthropic kern-ai

Run Agent

1python cookbook/11_models/anthropic/web_fetch.py