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?")Quick 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
Web 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 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
| 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
Use 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 webBest 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.