Perplexity Search Tools

Search the web with PerplexitySearch, including a variant filtered by recency window and allowed domains.

Demonstrates Perplexity Search tools for web search.

perplexity_tools.py
"""
Perplexity Search Tools
=============================

Demonstrates Perplexity Search tools for web search.
"""

from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.perplexity import PerplexitySearch

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------

# Example 1: Basic search with default settings
agent = Agent(
    model=OpenAIChat(id="gpt-5.6-luna"),
    tools=[PerplexitySearch()],
    markdown=True,
)

# Example 2: Search with recency and domain filters
agent_filtered = Agent(
    model=OpenAIChat(id="gpt-5.6-luna"),
    tools=[
        PerplexitySearch(
            max_results=10,
            search_recency_filter="week",
            search_domain_filter=["cnbc.com", "reuters.com", "bloomberg.com"],
            show_results=True,
        )
    ],
    markdown=True,
)

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    agent.print_response("What are the latest developments in AI agents?", stream=True)

The script runs the unfiltered agent. Replace that final call with agent_filtered.print_response(...) to exercise the week and domain filters. show_results=True logs retrieved results; it does not add citations automatically.

Run the Example

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Install dependencies

uv pip install -U agno openai

Export your API keys

export OPENAI_API_KEY="your_openai_api_key_here"
export PERPLEXITY_API_KEY="your_perplexity_api_key_here"

Run the example

Save the code above as perplexity_tools.py, then run:

python perplexity_tools.py

Full source: cookbook/91_tools/perplexity_tools.py