BaiduSearch

Search the web with BaiduSearchTools using the Baidu search engine, with a configurable result count.

BaiduSearch enables an Agent to search the web for information using the Baidu search engine.

Prerequisites

The following example requires the baidusearch, pycountry, and openai libraries. To install them, run the following command:

uv pip install -U agno baidusearch pycountry openai

Example

cookbook/91_tools/baidusearch_tools.py
from agno.agent import Agent
from agno.tools.baidusearch import BaiduSearchTools

agent = Agent(
    tools=[BaiduSearchTools()],
    description="You are a search agent that helps users find the most relevant information using Baidu.",
    instructions=[
        "Given a topic by the user, respond with the 3 most relevant search results about that topic.",
        "Search for 5 results and select the top 3 unique items.",
        "Search in both English and Chinese.",
    ],
)

agent.print_response("What are the latest advancements in AI?", markdown=True)

Toolkit Params

ParameterTypeDefaultDescription
fixed_max_resultsOptional[int]NoneA fixed number of maximum results to return, overriding the max_results argument passed to baidu_search.
fixed_languageOptional[str]NoneUsed for language normalization/logging; not forwarded to the search provider.
headersOptional[Any]NoneStored but not forwarded to the underlying search request.
proxyOptional[str]NoneStored but not forwarded to the underlying search request.
timeoutint10Stored but not forwarded to the underlying search request.
debugboolFalseStored; does not configure the provider's debug mode.
enable_baidu_searchboolTrueEnable the baidu_search functionality.
allboolFalseEnable all functionality.

Toolkit Functions

FunctionDescription
baidu_searchUse this function to search Baidu for a query.

Language and request options

The current adapter calls the provider with only keyword and num_results. It does not enforce the language, proxy, headers, timeout, or debug values in this table. Search with appropriately phrased queries; the cookbook's English/Chinese instruction is a model instruction rather than a provider language filter.

Developer Resources