TavilySearch Tool
Guide for using the TavilySearch tool with PraisonAI agents.
The TavilySearch tool lets an agent run AI-optimised web search through the Tavily API.
Overview
The TavilySearch tool is a tool that allows you to search the web using the TavilySearch.
pip install "langchain-community>=0.2.11" tavily-python
export TAVILY_API_KEY="${TAVILY_API_KEY:?Set TAVILY_API_KEY in your shell}"from praisonaiagents import Agent, AgentTeam
from langchain_community.tools import TavilySearchResults
def search_tool(query: str):
tool = TavilySearchResults(
max_results=5,
search_depth="advanced",
include_answer=True,
include_raw_content=True,
include_images=True
)
return tool.run(query)
data_agent = Agent(instructions="I am looking for the top google searches on AI tools of 2025", tools=[search_tool])
editor_agent = Agent(instructions="Analyze the data and rank the tools based on their popularity")
agents = AgentTeam(agents=[data_agent, editor_agent])
agents.start()How It Works
Getting Started
- Simple Usage
- Install dependencies (see Overview above)
- Set required API keys in your environment
- Run the agent example in Overview
- With Configuration
Use the same tool with an agent — see the Overview example, or pass env vars from the sections above.
Best Practices
Keep TAVILY_API_KEY in the environment
Set TAVILY_API_KEY in your shell or .env. The tool reads it automatically — never hard-code the key.
Cap max_results
TavilySearchResults(max_results=5) controls how many hits return. Lower it so the agent processes fewer tokens.
Enable include_answer for direct answers
Set include_answer=True when the agent needs a synthesised answer rather than raw links — it saves a follow-up LLM step.