Skip to main content
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.

DuckDuckGo Praison AI Integration

pip install duckduckgo_search
Create a file called tools.py in the same directory as the agents.yaml file.
# 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

1

Install

pip install duckduckgo_search praisonaiagents
2

Search with agent

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?")

Best Practices

DuckDuckGo requires no API key - use it as the zero-cost fallback provider in search_web.
DuckDuckGo returns best results in the first 5 hits - higher limits add noise.
Prefer from praisonaiagents import search_web for automatic fallback across providers.
Use specific, descriptive queries rather than broad terms for better DuckDuckGo results.

Custom Tools

Build your own agent tools

Tools Overview

Browse PraisonAI tool documentation