Web
Enable agents to search the web and fetch page content
Web capabilities let agents search the internet and fetch page content to answer questions with up-to-date information.
from praisonaiagents import Agent
agent = Agent(
name="News Agent",
instructions="Answer with up-to-date web results",
web="duckduckgo", # search only — no API key
)
agent.start("What are today's AI headlines?")graph LR
subgraph "Web Capabilities"
Agent[🤖 Agent] --> Search[🔍 Search]
Agent --> Fetch[📄 Fetch]
Search --> Results[📋 Results]
Fetch --> Content[📝 Content]
Results --> Answer[✅ Answer]
Content --> Answer
end
classDef agent fill:#10B981,stroke:#7C90A0,color:#fff
classDef web fill:#6366F1,stroke:#7C90A0,color:#fff
classDef result fill:#F59E0B,stroke:#7C90A0,color:#fff
class Agent agent
class Search,Fetch web
class Results,Content,Answer resultQuick Start
- Enable Web
python from praisonaiagents import Agent agent = Agent( name="Web Agent", instructions="You search the web for information", web=True # Enable web search and fetch ) agent.start("What are the latest AI news today?") - With Configuration
python from praisonaiagents import Agent, WebConfig agent = Agent( name="Research Agent", instructions="You do thorough web research", web=WebConfig( search=True, # Enable search fetch=True, # Enable page fetch search_provider="duckduckgo", # Search provider max_results=10, # Results per search ) )
Web Features
graph TB
subgraph "Features"
Search[🔍 Web Search<br/>Find relevant pages]
Fetch[📄 Page Fetch<br/>Get full content]
end
Search -->|"Query"| Results[📋 Search Results]
Fetch -->|"URL"| Content[📝 Page Content]
classDef feature fill:#189AB4,stroke:#7C90A0,color:#fff
classDef output fill:#10B981,stroke:#7C90A0,color:#fff
class Search,Fetch feature
class Results,Content outputWeb Search
Find relevant pages for a query:
agent = Agent(
instructions="You answer questions using web search",
web=WebConfig(search=True)
)
agent.start("What is the current price of Bitcoin?")Page Fetch
Retrieve full content from URLs:
agent = Agent(
instructions="You analyze web pages",
web=WebConfig(fetch=True)
)
agent.start("Summarize the content at https://example.com/article")Configuration Options
from praisonaiagents import WebConfig
config = WebConfig(
search=True, # Enable web search
fetch=True, # Enable page fetch
search_provider="duckduckgo", # Search provider
max_results=5, # Max results per search
search_config={}, # Provider-specific config
fetch_config={}, # Fetch-specific config
)| Option | Type | Default | Description |
|---|---|---|---|
search | bool | True | Enable web search |
fetch | bool | True | Enable page fetch |
search_provider | str | "duckduckgo" | Search provider |
max_results | int | 5 | Results per search |
search_config | dict | {} | Provider config |
fetch_config | dict | {} | Fetch config |
Choosing the right form
flowchart TD
Start([Need web tools?]) --> Q1{Provider string?}
Q1 -->|web="duckduckgo" etc.| SearchOnly[Search only]
Q1 -->|web="fetch_only"| FetchOnly[Fetch only]
Q1 -->|web=True| Both[Search + fetch]
Q1 -->|WebConfig(...)| Custom[Explicit flags]
classDef start fill:#6366F1,stroke:#7C90A0,color:#fff
classDef choice fill:#F59E0B,stroke:#7C90A0,color:#fff
classDef result fill:#10B981,stroke:#7C90A0,color:#fff
class Start start
class Q1 choice
class SearchOnly,FetchOnly,Both,Custom resultflowchart TD
Start([Need web tools?]) --> Q1{Provider string?}
Q1 -->|web="duckduckgo" etc.| SearchOnly[Search only]
Q1 -->|web="fetch_only"| FetchOnly[Fetch only]
Q1 -->|web=True| Both[Search + fetch]
Q1 -->|WebConfig(...)| Custom[Explicit flags]
classDef start fill:#6366F1,stroke:#7C90A0,color:#fff
classDef choice fill:#F59E0B,stroke:#7C90A0,color:#fff
classDef result fill:#10B981,stroke:#7C90A0,color:#fff
class Start start
class Q1 choice
class SearchOnly,FetchOnly,Both,Custom result| Form | Search | Fetch |
|---|---|---|
web="duckduckgo" | ✅ | ❌ |
web="tavily" | ✅ | ❌ |
web="google" | ✅ | ❌ |
web="bing" | ✅ | ❌ |
web="serper" | ✅ | ❌ |
web="search_only" | ✅ | ❌ |
web="fetch_only" | ❌ | ✅ |
web=True or WebConfig(search=True, fetch=True) | ✅ | ✅ |
Search Providers
graph LR
subgraph "Providers"
DDG[🦆 DuckDuckGo<br/>Free, no API key]
Google[🔍 Google<br/>API key required]
Tavily[🔎 Tavily<br/>AI-optimized]
Serper[📊 Serper<br/>Google results]
end
classDef free fill:#10B981,stroke:#7C90A0,color:#fff
classDef paid fill:#F59E0B,stroke:#7C90A0,color:#fff
class DDG free
class Google,Tavily,Serper paid| Provider | API Key | Best For |
|---|---|---|
duckduckgo | ❌ Not needed | General use, free |
google | ✅ Required | Comprehensive results |
tavily | ✅ Required | AI-optimized search |
serper | ✅ Required | Google results API |
bing | ✅ Required | Microsoft ecosystem |
Using Different Providers
# Provider string — search only (default for presets)
agent = Agent(web="duckduckgo")
# Search + fetch explicitly
agent = Agent(
web=WebConfig(search=True, fetch=True, search_provider="duckduckgo")
)
# DuckDuckGo via WebConfig (search only unless fetch=True)
agent = Agent(
web=WebConfig(search_provider="duckduckgo")
)
# Tavily (AI-optimized)
agent = Agent(
web=WebConfig(
search_provider="tavily",
search_config={"api_key": "your-key"}
)
)
# Google
agent = Agent(
web=WebConfig(
search_provider="google",
search_config={
"api_key": "your-key",
"cx": "your-search-engine-id"
}
)
)How It Works
sequenceDiagram
participant User
participant Agent
participant Search
participant Fetch
participant LLM
User->>Agent: Question
Agent->>Search: Search query
Search-->>Agent: URLs + snippets
opt Need full content
Agent->>Fetch: Fetch URL
Fetch-->>Agent: Page content
end
Agent->>LLM: Question + context
LLM-->>Agent: Answer
Agent-->>User: ResponseUse Cases
Research
Find and synthesize information from multiple sources
NewsGet current events and latest updates
Fact-CheckingVerify claims with web sources
MonitoringTrack topics and get updates
Combining with Knowledge
Web search complements local knowledge:
agent = Agent(
instructions="You answer using docs and web",
knowledge=["docs/"], # Local documents
web=True, # Web search fallback
)
# Agent checks local docs first, then searches webgraph TB
Query[❓ Query] --> Local{Local Knowledge?}
Local -->|"Found"| Answer[✅ Answer]
Local -->|"Not found"| Web[🌐 Web Search]
Web --> Answer
classDef query fill:#6366F1,stroke:#7C90A0,color:#fff
classDef decision fill:#F59E0B,stroke:#7C90A0,color:#fff
classDef answer fill:#10B981,stroke:#7C90A0,color:#fff
class Query query
class Local decision
class Web,Answer answerBest Practices
Use DuckDuckGo for simple needs
Free and requires no API key – good for basic search needs.
Use Tavily for AI applications
Tavily is optimized for AI agents with better structured results.
Limit results for speed
Lower max_results for faster responses when you don’t need many sources.
Combine with knowledge for best results
Use local knowledge for domain-specific info, web for current events.