# Tavily Search — Search API Built for AI Agents > Tavily Search returns LLM-ready answers from the web — not link lists. One call gets snippets, citations, optional generated answer. Free tier 1K/mo. ## Install Copy the content below into your project: ## Quick Use 1. Sign up at tavily.com → copy API key 2. `pip install tavily-python` (or `npm install @tavily/core`) 3. `client.search(query=..., include_answer=True)` returns LLM-ready snippets --- ## Intro Tavily Search is the search API designed for AI agents and RAG. Unlike Google Custom Search or Bing API, Tavily returns curated content snippets ready to feed an LLM — not a list of URLs to scrape. Optional `include_answer` gives a generated synthesis. Best for: AI agents that need fresh facts, citations, real-time info. Works with: Tavily REST API, Python / TypeScript SDK, MCP server. Setup time: 2 minutes. --- ### Hello world ```python from tavily import TavilyClient client = TavilyClient(api_key=os.environ["TAVILY_API_KEY"]) response = client.search( query="What is the latest version of Python?", search_depth="advanced", include_answer=True, include_raw_content=False, max_results=5, ) print(response["answer"]) # "As of October 2024, the latest stable version of Python is 3.13.0..." for r in response["results"]: print(f"{r['title']} — {r['url']}") print(r["content"][:200]) ``` ### Search depth | Mode | Use | Cost | |---|---|---| | `basic` | Quick fact lookups | 1 credit | | `advanced` | Multi-source research, RAG | 2 credits | Advanced mode crawls more sources and runs a rerank pass — better for answer quality, slightly higher latency and cost. ### Filter by domain ```python # Whitelist response = client.search( query="Latest LangChain release notes", include_domains=["python.langchain.com", "github.com"], ) # Blacklist response = client.search( query="Best vector databases", exclude_domains=["medium.com"], # avoid SEO blogspam ) ``` ### As MCP ```json { "mcpServers": { "tavily": { "command": "npx", "args": ["-y", "tavily-mcp"], "env": { "TAVILY_API_KEY": "tvly-..." } } } } ``` Now Claude Code / Cursor can call `tavily_search`, `tavily_extract`, `tavily_crawl` directly. --- ### FAQ **Q: Is Tavily free?** A: Yes — free tier 1,000 API credits/month, no credit card needed. Paid plans add higher quotas and team features. Pricing on tavily.com. **Q: How is Tavily different from Google search via SerpAPI?** A: SerpAPI returns Google's HTML organic results — you scrape and clean. Tavily already runs the cleaning, ranking, and (optionally) synthesis. Tavily is purpose-built for LLM consumption; SerpAPI is purpose-built for SERP scraping. **Q: Can I use Tavily with LangChain?** A: Yes — `langchain_community.tools.tavily_search.TavilySearchResults` is a built-in LangChain tool. Same for LlamaIndex, CrewAI, Pydantic AI. --- ## Source & Thanks > Built by [Tavily](https://github.com/tavily-ai). Commercial product with free tier. > > [tavily-ai/tavily-python](https://github.com/tavily-ai/tavily-python) — ⭐ Active --- ## 快速使用 1. 在 tavily.com 注册,复制 API key 2. `pip install tavily-python`(或 `npm install @tavily/core`) 3. `client.search(query=..., include_answer=True)` 返回 LLM 直接能用的片段 --- ## 简介 Tavily Search 是为 AI agent 和 RAG 设计的搜索 API。不像 Google Custom Search 或 Bing API,Tavily 返回精选的内容片段直接喂 LLM —— 不是要再去 scrape 的 URL 列表。可选的 `include_answer` 给出综合答案。适合需要新事实、引用、实时信息的 AI agent。兼容 Tavily REST API / Python / TypeScript SDK / MCP server。装机时间 2 分钟。 --- ### Hello world ```python from tavily import TavilyClient client = TavilyClient(api_key=os.environ["TAVILY_API_KEY"]) response = client.search( query="What is the latest version of Python?", search_depth="advanced", include_answer=True, include_raw_content=False, max_results=5, ) print(response["answer"]) # "As of October 2024, the latest stable version of Python is 3.13.0..." for r in response["results"]: print(f"{r['title']} — {r['url']}") print(r["content"][:200]) ``` ### 搜索深度 | 模式 | 用途 | 成本 | |---|---|---| | `basic` | 快速事实查询 | 1 credit | | `advanced` | 多源研究、RAG | 2 credits | advanced 模式爬更多源 + 重排,答案质量更好,延迟和成本略高。 ### 按域名过滤 ```python # 白名单 response = client.search( query="Latest LangChain release notes", include_domains=["python.langchain.com", "github.com"], ) # 黑名单 response = client.search( query="Best vector databases", exclude_domains=["medium.com"], # 避开 SEO blogspam ) ``` ### 当 MCP ```json { "mcpServers": { "tavily": { "command": "npx", "args": ["-y", "tavily-mcp"], "env": { "TAVILY_API_KEY": "tvly-..." } } } } ``` Claude Code / Cursor 直接调 `tavily_search` / `tavily_extract` / `tavily_crawl`。 --- ### FAQ **Q: Tavily 免费吗?** A: 免费 —— 免费档每月 1000 API credit,不要信用卡。付费档加更高配额和团队功能。价格见 tavily.com。 **Q: Tavily 跟 SerpAPI 调 Google 啥区别?** A: SerpAPI 返回 Google 的 HTML 自然结果,你自己 scrape + 清洗。Tavily 已经做了清洗、排序、可选的综合。Tavily 为 LLM 消费打造;SerpAPI 为 SERP scraping 打造。 **Q: 能配 LangChain 用吗?** A: 能 —— `langchain_community.tools.tavily_search.TavilySearchResults` 是 LangChain 内置工具。LlamaIndex / CrewAI / Pydantic AI 同样。 --- ## 来源与感谢 > Built by [Tavily](https://github.com/tavily-ai). Commercial product with free tier. > > [tavily-ai/tavily-python](https://github.com/tavily-ai/tavily-python) — ⭐ Active --- Source: https://tokrepo.com/en/workflows/tavily-search-search-api-built-for-ai-agents Author: Tavily