> ## 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.

# DuckDuckGo PraisonAI Integration

> Guide for integrating DuckDuckGo search capabilities with PraisonAI agents for web search functionality

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

agent = Agent(name="Researcher", tools=[duckduckgo])
agent.start("What are the latest AI developments?")
```

The user asks for current information; the agent searches the web with DuckDuckGo and cites findings.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    U[Input] --> A[Agent]
    A --> T[Tool]
    T --> O[Output]

    classDef agent fill:#8B0000,color:#fff
    classDef tool fill:#189AB4,color:#fff

    class A agent
    class U,O tool
    class T tool
```

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
sequenceDiagram
    participant User
    participant Agent
    participant Feature as DuckDuckGo PraisonAI Integration

    User->>Agent: Request
    Agent->>Feature: Process request
    Feature-->>Agent: Result
    Agent-->>User: Response
```

# DuckDuckGo Praison AI Integration

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
pip install duckduckgo_search
```

Create a file called tools.py in the same directory as the agents.yaml file.

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# example tools.py
from duckduckgo_search import DDGS
from praisonai_tools import BaseTool

class InternetSearchTool(BaseTool):
    name: str = "InternetSearchTool"
    description: str = "Search Internet for relevant information based on a query or latest news"

    def _run(self, query: str):
        ddgs = DDGS()
        results = ddgs.text(keywords=query, region='wt-wt', safesearch='moderate', max_results=5)
        return results
```

## Quick Start

<Steps>
  <Step title="Install">
    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    pip install duckduckgo_search praisonaiagents
    ```
  </Step>

  <Step title="Search with agent">
    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    from praisonaiagents import Agent, search_web

    agent = Agent(
        name="SearchAgent",
        instructions="Search the web to answer questions.",
        tools=[search_web],
    )

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

## Best Practices

<AccordionGroup>
  <Accordion title="Use as a free fallback">
    DuckDuckGo requires no API key - use it as the zero-cost fallback provider in `search_web`.
  </Accordion>

  <Accordion title="Keep max_results small">
    DuckDuckGo returns best results in the first 5 hits - higher limits add noise.
  </Accordion>

  <Accordion title="Use the unified search_web tool">
    Prefer `from praisonaiagents import search_web` for automatic fallback across providers.
  </Accordion>

  <Accordion title="Use specific queries">
    Use specific, descriptive queries rather than broad terms for better DuckDuckGo results.
  </Accordion>
</AccordionGroup>

## Related

<CardGroup cols={2}>
  <Card title="Custom Tools" icon="wrench" href="/docs/tools/custom">
    Build your own agent tools
  </Card>

  <Card title="Tools Overview" icon="toolbox" href="/docs/tools/tools">
    Browse PraisonAI tool documentation
  </Card>
</CardGroup>
