Skip to main content
WebSearchTools is a versatile toolkit that enables an Agent to search the web using multiple search backends. It uses the DDGS meta-search library which supports backends like Google, Bing, DuckDuckGo, Brave, Yandex, Yahoo, and more. This is the recommended toolkit for general web search functionality. For DuckDuckGo-specific usage, see DuckDuckGoTools.

Prerequisites

The following example requires the ddgs library. To install it, run the following command:
pip install -U ddgs

Example

from agno.agent import Agent
from agno.tools.websearch import WebSearchTools

# Basic usage with auto backend selection
agent = Agent(tools=[WebSearchTools()])
agent.print_response("What's happening in France?", markdown=True)

# Use a specific backend (e.g., google, bing, brave, yandex)
agent_google = Agent(
    tools=[WebSearchTools(backend="google")]
)
agent_google.print_response("Latest AI news", markdown=True)

Toolkit Params

ParameterTypeDefaultDescription
enable_searchboolTrueEnable web search function.
enable_newsboolTrueEnable news search function.
backendstr"auto"The backend to use for searching. Options: "auto", "duckduckgo", "google", "bing", "brave", "yandex", "yahoo", etc.
modifierOptional[str]NoneA modifier to be prepended to search queries.
fixed_max_resultsOptional[int]NoneA fixed number of maximum results.
proxyOptional[str]NoneProxy to be used for requests.
timeoutOptional[int]10The maximum number of seconds to wait for a response.
verify_sslboolTrueWhether to verify SSL certificates.

Toolkit Functions

FunctionDescription
web_searchSearch the web for a query. Parameters include query (str) for the search query and max_results (int, default=5) for maximum results. Returns JSON formatted search results.
search_newsGet the latest news from the web. Parameters include query (str) for the search query and max_results (int, default=5) for maximum results. Returns JSON formatted news results.

Supported Backends

The backend parameter supports the following options:
BackendDescription
autoAutomatically selects an available backend
duckduckgoDuckDuckGo search engine
googleGoogle search engine
bingMicrosoft Bing search engine
braveBrave Search
yandexYandex search engine
yahooYahoo search engine

Developer Resources