> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Web

> Give agents live internet access — search the web or fetch any URL in one line

Web tools let any agent search the internet or read any webpage, with automatic provider fallback so it works even without an API key.

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent

agent = Agent(
    name="Researcher",
    instructions="Answer questions using current information from the web.",
    web=True,
)
agent.start("What are the latest developments in AI this week?")
```

The user asks for current information; the agent searches or fetches pages with automatic provider fallback.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    subgraph "Web Feature"
        A["🤖 Agent"] --> S["🔍 Search"]
        A --> F["🌐 Fetch"]
        S --> P["📡 Providers"]
        P --> T["Tavily"]
        P --> B["Brave"]
        P --> D["DuckDuckGo"]
        F --> C["📄 Content"]
        C --> A
    end

    classDef agent fill:#8B0000,stroke:#7C90A0,color:#fff
    classDef action fill:#189AB4,stroke:#7C90A0,color:#fff
    classDef provider fill:#F59E0B,stroke:#7C90A0,color:#fff
    classDef output fill:#10B981,stroke:#7C90A0,color:#fff

    class A agent
    class S,F action
    class P,T,B,D provider
    class C output
```

## Quick Start

<Steps>
  <Step title="Level 1 — Bool (simplest)">
    Add `web=True` and the agent automatically searches the internet when it needs current information.

    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    from praisonaiagents import Agent

    agent = Agent(
        name="Researcher",
        instructions="Answer questions using current information from the web.",
        web=True,
    )

    agent.start("What are the latest developments in AI this week?")
    ```
  </Step>

  <Step title="Level 2 — String (pick a provider)">
    Pass a provider name to route searches through a specific engine.

    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    from praisonaiagents import Agent

    agent = Agent(
        name="Researcher",
        instructions="Answer questions using current information from the web.",
        web="tavily",
    )

    agent.start("What are the latest developments in AI this week?")
    ```
  </Step>

  <Step title="Level 3 — Config class (full control)">
    Use `WebConfig` to combine search, fetch, provider, and result limits.

    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    from praisonaiagents import Agent, WebConfig

    agent = Agent(
        name="Researcher",
        instructions="Research topics thoroughly.",
        web=WebConfig(
            search=True,
            fetch=True,
            search_provider="tavily",
            max_results=10,
        )
    )

    agent.start("Summarize the latest news on quantum computing.")
    ```
  </Step>

  <Step title="Alternative — Web tools directly">
    Use `search_web` and `web_crawl` as standalone tools inside any agent.

    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    from praisonaiagents import Agent
    from praisonaiagents.tools import search_web, web_crawl

    agent = Agent(
        name="Web Agent",
        instructions="Search and read web pages to answer questions.",
        tools=[search_web, web_crawl],
    )

    agent.start("Find and summarize the homepage of OpenAI.")
    ```
  </Step>
</Steps>

***

## How It Works

The agent decides when to search or fetch based on your query. Results flow back as context for the final answer.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
sequenceDiagram
    participant User
    participant Agent
    participant Search as Search Tool
    participant Fetch as Fetch Tool
    participant Provider as Search Provider

    User->>Agent: "Latest AI news?"
    Agent->>Search: search_web("latest AI news")
    Search->>Provider: Query (Tavily → Brave → DuckDuckGo)
    Provider-->>Search: Title + URL + Snippet × N
    Search-->>Agent: Results list
    Agent->>Fetch: web_crawl(top_url)
    Fetch-->>Agent: Full page content
    Agent-->>User: Summarized answer
```

***

## Configuration Options

<Card title="WebConfig API Reference" icon="code" href="/docs/sdk/praisonaiagents/config/feature-configs-module">
  Full API reference for `WebConfig` — search, fetch, providers, max\_results
</Card>

### WebConfig Fields

| Field             | Type           | Default        | Description                                                                     |
| ----------------- | -------------- | -------------- | ------------------------------------------------------------------------------- |
| `search`          | `bool`         | `True`         | Enable web search                                                               |
| `fetch`           | `bool`         | `True`         | Enable web page fetching                                                        |
| `search_provider` | `str`          | `"duckduckgo"` | Provider to use: `tavily`, `brave`, `exa`, `youdotcom`, `duckduckgo`, `searxng` |
| `max_results`     | `int`          | `5`            | Maximum search results returned                                                 |
| `search_config`   | `dict \| None` | `None`         | Provider-specific search settings                                               |
| `fetch_config`    | `dict \| None` | `None`         | Provider-specific fetch settings                                                |

### Search Provider Priority (auto-fallback)

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph TB
    Start["🔍 search_web()"] --> T{"Tavily available?"}
    T -->|Yes| TY["✅ Use Tavily"]
    T -->|No| B{"Brave available?"}
    B -->|Yes| BY["✅ Use Brave"]
    B -->|No| E{"Exa available?"}
    E -->|Yes| EY["✅ Use Exa"]
    E -->|No| Y{"You.com available?"}
    Y -->|Yes| YY["✅ Use You.com"]
    Y -->|No| D{"DuckDuckGo?"}
    D -->|Yes| DY["✅ Use DuckDuckGo (free)"]
    D -->|No| S["✅ Use SearxNG"]

    classDef decision fill:#F59E0B,stroke:#7C90A0,color:#fff
    classDef success fill:#10B981,stroke:#7C90A0,color:#fff
    classDef start fill:#8B0000,stroke:#7C90A0,color:#fff

    class Start start
    class T,B,E,Y,D decision
    class TY,BY,EY,YY,DY,S success
```

***

## Common Patterns

### Research Agent with Sources

Search the web and return cited sources alongside the answer.

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent

agent = Agent(
    name="Research Assistant",
    instructions="Answer questions with sources. Always cite URLs.",
    web=True,
)

agent.start("What is the current state of nuclear fusion research?")
```

### Crawl and Summarize a URL

Fetch a specific webpage and summarize it.

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent
from praisonaiagents.tools import web_crawl

agent = Agent(
    name="Summarizer",
    instructions="Fetch the given URL and write a 3-sentence summary.",
    tools=[web_crawl],
)

agent.start("Summarize https://openai.com/research/overview")
```

### Multi-Agent Research Pipeline

One agent searches, another writes the report.

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent, Task, PraisonAIAgents

searcher = Agent(
    name="Searcher",
    instructions="Search the web for information on the given topic.",
    web=True,
)

writer = Agent(
    name="Writer",
    instructions="Write a structured report based on research findings.",
)

search_task = Task(
    description="Find the top 5 sources on AI regulation in 2025",
    agent=searcher,
    expected_output="List of sources with summaries",
)

write_task = Task(
    description="Write a 500-word report on AI regulation",
    agent=writer,
    context=[search_task],
    expected_output="Formatted report",
)

agents = PraisonAIAgents(agents=[searcher, writer], tasks=[search_task, write_task])
agents.start()
```

***

## Best Practices

<AccordionGroup>
  <Accordion title="Use DuckDuckGo for zero-configuration setups">
    DuckDuckGo requires no API key and no package beyond `ddgs`. It's the best choice for local development, prototypes, and open-source projects where you can't bundle API keys.
  </Accordion>

  <Accordion title="Switch to Tavily for production accuracy">
    Tavily returns higher-quality snippets and supports full-page extraction. Set `TAVILY_API_KEY` in your environment and the agent will prefer it automatically over free providers.
  </Accordion>

  <Accordion title="Limit max_results to control token costs">
    Each search result adds tokens to the agent's context. Keep `max_results=5` (the default) for most queries. Only increase it when the task genuinely requires broad coverage, such as academic literature surveys.
  </Accordion>

  <Accordion title="Combine search and fetch for deep research">
    `search=True` finds the best URLs; `fetch=True` reads the full page content. Use both together when a snippet is not enough — for example, reading full API documentation or news articles.
  </Accordion>
</AccordionGroup>

***

## Related

<CardGroup cols={2}>
  <Card title="Search Providers" icon="globe" href="/docs/features/search-provider-registry">
    Choose DuckDuckGo, Tavily, or Serper for web search
  </Card>

  <Card title="Deep Research" icon="magnifying-glass" href="/docs/agents/deep-research">
    Multi-step research agents that synthesize information from many sources
  </Card>
</CardGroup>
