Documentation Index
Fetch the complete documentation index at: https://docs.praison.ai/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Tavily is an AI-powered search engine optimized for LLMs and AI agents. It provides high-quality, relevant search results with built-in answer synthesis.
Installation
pip install "praisonai[tools]"
Environment Variables
export TAVILY_API_KEY=your_api_key_here
Get your API key from Tavily.
Quick Start
from praisonai_tools import TavilyTool
# Initialize
tavily = TavilyTool()
# Search
results = tavily.search("What is quantum computing?")
print(results)
Usage with Agent
from praisonaiagents import Agent
from praisonai_tools import TavilyTool
agent = Agent(
name="Researcher",
instructions="You are a research assistant. Use Tavily to search for information.",
tools=[TavilyTool()]
)
response = agent.chat("Search for the latest AI news")
print(response)
Available Methods
search(query, max_results=5)
Search the web with AI-powered results.
from praisonai_tools import TavilyTool
tavily = TavilyTool()
results = tavily.search("Python best practices", max_results=3)
# Returns:
# {
# "query": "Python best practices",
# "answer": "AI-generated summary...",
# "results": [
# {"title": "...", "url": "...", "content": "...", "score": 0.95}
# ]
# }
search_context(query)
Get search context optimized for RAG applications.
context = tavily.search_context("machine learning fundamentals")
# Returns a string with relevant context for LLM consumption
Extract content from specific URLs.
content = tavily.extract("https://example.com,https://another.com")
# Returns list of extracted content from each URL
Configuration Options
tavily = TavilyTool(
api_key="your_key", # Optional: defaults to TAVILY_API_KEY env var
search_depth="advanced", # "basic" or "advanced"
include_answer=True, # Include AI-generated answer
max_tokens=6000 # Max tokens for context
)
Function-Based Usage
from praisonai_tools import tavily_search
# Quick search without instantiating class
results = tavily_search("latest tech news", max_results=5)
CLI Usage
# Set API key
export TAVILY_API_KEY=your_key
# Use with praisonai
praisonai --tools TavilyTool "Search for AI trends 2025"
Error Handling
from praisonai_tools import TavilyTool
tavily = TavilyTool()
results = tavily.search("my query")
if "error" in results:
print(f"Error: {results['error']}")
else:
print(f"Found {len(results['results'])} results")
Common Errors
| Error | Cause | Solution |
|---|
TAVILY_API_KEY not configured | Missing API key | Set TAVILY_API_KEY environment variable |
tavily-python not installed | Missing dependency | Run pip install tavily-python |
Invalid API key | Wrong API key | Verify your API key at tavily.com |