Tool Use
Call web search tools from Claude in sync, streaming, and async modes.
Anthropic retired the source's dated Sonnet 4 and Opus 4 models on June 15, 2026. Before running your saved copy, replace claude-sonnet-4-20250514 or claude-opus-4-20250514 with the active claude-sonnet-4-6 model. See model lifecycle status.
"""Run `uv pip install ddgs` to install dependencies."""
import asyncio
from agno.agent import Agent
from agno.models.anthropic import Claude
from agno.tools.websearch import WebSearchTools
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
agent = Agent(
model=Claude(id="claude-sonnet-4-20250514"),
tools=[WebSearchTools()],
markdown=True,
)
# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
# --- Sync ---
agent.print_response("Whats happening in France?")
# --- Sync + Streaming ---
agent.print_response("Whats happening in France?", stream=True)
# --- Async + Streaming ---
asyncio.run(agent.aprint_response("Whats happening in France?", stream=True))Run the Example
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateInstall dependencies
uv pip install -U agno anthropic ddgsExport your Anthropic API key
export ANTHROPIC_API_KEY="your_anthropic_api_key_here"Run the example
Save the code above as tool_use.py. Replace the source model ID claude-sonnet-4-20250514 with claude-sonnet-4-6, then run:
python tool_use.pyFull source: cookbook/90_models/anthropic/tool_use.py