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
Environment Variables
How It Works
Quick Start
Usage with Agent
Available Methods
search(query, max_results=5)
Search the web with AI-powered results.search_context(query)
Get search context optimized for RAG applications.extract(urls)
Extract content from specific URLs.Configuration Options
Function-Based Usage
CLI Usage
Error Handling
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 |
Best Practices
Let TAVILY_API_KEY come from the environment
Let TAVILY_API_KEY come from the environment
TavilyTool() defaults to the TAVILY_API_KEY env var. Set it in your shell or .env rather than passing api_key= inline.Use search_context for RAG
Use search_context for RAG
search_context(query) returns text optimised for LLM consumption. Prefer it over raw search when feeding results straight into the agent.Tune search_depth
Tune search_depth
search_depth="advanced" returns richer results at higher latency. Use "basic" for quick lookups to keep the agent responsive.Related Tools
Exa Search
Neural search engine
DuckDuckGo
Privacy-focused search
Serper
Google search API

