Skip to main content
PerplexitySearch enables an Agent to search the web using the Perplexity Search API and return ranked results with titles, URLs, snippets, and publication dates.

Prerequisites

The following example requires the httpx library and an API key from Perplexity.
uv pip install -U httpx
export PERPLEXITY_API_KEY=***

Examples

Basic search:
from agno.agent import Agent
from agno.tools.perplexity import PerplexitySearch

agent = Agent(tools=[PerplexitySearch()], markdown=True)
agent.print_response("What are the latest developments in AI?")
Search with filters (news from the past week, specific domains):
agent_filtered = Agent(
    tools=[
        PerplexitySearch(
            max_results=10,
            search_recency_filter="week",
            search_domain_filter=["cnbc.com", "reuters.com", "bloomberg.com"],
        )
    ],
    markdown=True,
)
agent_filtered.print_response("Latest AI industry developments")

When to Use

Use PerplexitySearch when you need:
  • Current, ranked web search results with publication dates
  • Filtering by recency (past day, week, month, or year)
  • Restriction to specific domains or languages
  • Integration with agents that need up-to-date information

Toolkit Params

ParameterTypeDefaultDescription
api_keyOptional[str]NonePerplexity API key. If not provided, uses PERPLEXITY_API_KEY environment variable.
max_resultsint5Maximum number of results to return per query.
max_tokens_per_pageint2048Maximum content length per result in tokens.
search_recency_filterOptional[str]NoneFilter results by recency: day, week, month, or year.
search_domain_filterOptional[List[str]]NoneList of domains to restrict search results to.
search_language_filterOptional[List[str]]NoneList of ISO language codes to filter results by language.
show_resultsboolFalseLog search results for debugging.

Toolkit Functions

FunctionDescription
searchSearch the web using the Perplexity Search API. Takes a query (str) and optional max_results (int). Returns a JSON array of results with url, title, snippet, and date.
asearchAsync variant of search. Uses httpx.AsyncClient for non-blocking requests.

Developer Resources