Fetch Webpage
The fetch_webpage tool enables Letta agents to fetch and convert webpages into readable text or markdown format. Useful for reading documentation, articles, and web content.
Quick Start
Section titled “Quick Start”from letta import Letta
client = Letta(token="LETTA_API_KEY")
agent = client.agents.create(model="openai/gpt-4o",tools=["fetch_webpage"],memory_blocks=[{"label": "persona","value": "I can fetch and read webpages to answer questions about online content."}])import { LettaClient } from "@letta-ai/letta-client";
const client = new LettaClient({ token: "LETTA_API_KEY" });
const agent = await client.agents.create({ model: "openai/gpt-4o", tools: ["fetch_webpage"], memoryBlocks: [ { label: "persona", value: "I can fetch and read webpages to answer questions about online content.", }, ],});Tool Parameters
Section titled “Tool Parameters”| Parameter | Type | Description |
|---|---|---|
url | str | The URL of the webpage to fetch |
Return Format
Section titled “Return Format”The tool returns webpage content as text/markdown.
With Exa API (if configured):
{ "title": "Page title", "published_date": "2025-01-15", "author": "Author name", "text": "Full page content in markdown"}Fallback (without Exa): Returns markdown-formatted text extracted from the HTML.
How It Works
Section titled “How It Works”The tool uses a multi-tier approach:
- Exa API (if
EXA_API_KEYis configured): Uses Exa’s content extraction - Trafilatura (fallback): Open-source text extraction to markdown
- Readability + html2text (final fallback): HTML cleaning and conversion
Self-Hosted Setup
Section titled “Self-Hosted Setup”For enhanced fetching on self-hosted servers, optionally configure an Exa API key. Without it, the tool still works using open-source extraction.
Optional: Configure Exa
Section titled “Optional: Configure Exa”docker run \ -e EXA_API_KEY="your_exa_api_key" \ letta/letta:latestservices: letta: environment: - EXA_API_KEY=your_exa_api_keyagent = client.agents.create( tools=["fetch_webpage"], tool_env_vars={ "EXA_API_KEY": "your_exa_api_key" })Common Patterns
Section titled “Common Patterns”Documentation Reader
Section titled “Documentation Reader”agent = client.agents.create( model="openai/gpt-4o", tools=["fetch_webpage", "web_search"], memory_blocks=[{ "label": "persona", "value": "I search for documentation with web_search and read it with fetch_webpage." }])Research Assistant
Section titled “Research Assistant”agent = client.agents.create( model="openai/gpt-4o", tools=["fetch_webpage", "archival_memory_insert"], memory_blocks=[{ "label": "persona", "value": "I fetch articles and store key insights in archival memory for later reference." }])Content Summarizer
Section titled “Content Summarizer”agent = client.agents.create( model="openai/gpt-4o", tools=["fetch_webpage"], memory_blocks=[{ "label": "persona", "value": "I fetch webpages and provide summaries of their content." }])When to Use
Section titled “When to Use”| Use Case | Tool | Why |
|---|---|---|
| Read specific webpage | fetch_webpage | Direct URL access |
| Find webpages to read | web_search | Discovery first |
| Read + search in one | web_search with include_text=true | Combined operation |
| Multiple pages | fetch_webpage | Iterate over URLs |