tavily
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTavily Search API
Tavily 搜索API
Use Tavily's search API via direct calls to perform live web search, ideal for powering retrieval-augmented generation (RAG) for LLMs and agents.
curlOfficial documentation:https://docs.tavily.com/
通过直接调用使用Tavily的搜索API来执行实时网络搜索,非常适合为LLM和Agent提供检索增强生成(RAG)支持。
curl官方文档:https://docs.tavily.com/
When to Use
使用场景
Use this skill when you need:
- Fresh, up-to-date information (news, trends, ongoing events)
- Search results with sources/links to ground LLM or agent answers
- Research / desk research inside automation workflows
- A reliable retrieval layer for RAG, combined with skills like Notion or Firecrawl
在以下场景中使用该技能:
- 获取新鲜、实时的信息(新闻、趋势、正在发生的事件)
- 获取带来源/链接的搜索结果,为LLM或Agent的回答提供依据
- 在自动化工作流中进行调研/案头研究
- 为RAG搭建可靠的检索层,可与Notion或Firecrawl等技能结合使用
Prerequisites
前置条件
- Sign up for Tavily and create an API key
- Store your Tavily API key in the environment variable
TAVILY_API_KEY
Set it in your local shell or runtime environment, for example:
bash
export TAVILY_API_KEY="tvly-xxxxxxxxxxxxxxxx"Important: When usingin a command that pipes to another command, wrap the command containing$VARin$VAR. Due to a Claude Code bug, environment variables are silently cleared when pipes are used directly.bash -c '...'bashbash -c 'curl -s "https://api.example.com" -H "Authorization: Bearer $API_KEY"' | jq '.results[] | {title, url}'
- 注册Tavily账号并创建API密钥
- 将你的Tavily API密钥存储到环境变量中
TAVILY_API_KEY
在本地Shell或运行时环境中设置,例如:
bash
export TAVILY_API_KEY="tvly-xxxxxxxxxxxxxxxx"重要提示: 当在管道到另一个命令的命令中使用时,将包含$VAR的命令用$VAR包裹。由于Claude Code的一个bug,当直接使用管道时,环境变量会被静默清除。bash -c '...'bashbash -c 'curl -s "https://api.example.com" -H "Authorization: Bearer $API_KEY"' | jq '.results[] | {title, url}'
How to Use
使用方法
All examples below assume you have set in your environment.
The base endpoint for the Tavily search API is a request to:
TAVILY_API_KEYPOSThttps://api.tavily.com/search
with a JSON body.
以下所有示例均假设你已在环境中设置了。
Tavily搜索API的基础端点为向以下地址发送请求:
TAVILY_API_KEYPOSThttps://api.tavily.com/search
请求体为JSON格式。
1. Basic Search
1. 基础搜索
Write to :
/tmp/tavily_request.jsonjson
{
"query": "2025 AI Trending",
"search_depth": "basic",
"max_results": 5
}Then run:
bash
bash -c 'curl -s -X POST "https://api.tavily.com/search" --header "Content-Type: application/json" --header "Authorization: Bearer ${TAVILY_API_KEY}" -d @/tmp/tavily_request.json'Key parameters:
- : Search query or natural language question
query - :
search_depth- – faster, good for most use cases
"basic" - – deeper search and higher recall
"advanced"
- : Maximum number of results to return (e.g. 3 / 5 / 10)
max_results
将以下内容写入:
/tmp/tavily_request.jsonjson
{
"query": "2025 AI Trending",
"search_depth": "basic",
"max_results": 5
}然后运行:
bash
bash -c 'curl -s -X POST "https://api.tavily.com/search" --header "Content-Type: application/json" --header "Authorization: Bearer ${TAVILY_API_KEY}" -d @/tmp/tavily_request.json'关键参数:
- :搜索查询或自然语言问题
query - :
search_depth- – 速度更快,适用于大多数场景
"basic" - – 搜索更深入,召回率更高
"advanced"
- :返回的最大结果数(例如3/5/10)
max_results
2. Advanced Search
2. 高级搜索
Write to :
/tmp/tavily_request.jsonjson
{
"query": "serverless SaaS pricing best practices",
"search_depth": "advanced",
"max_results": 8,
"include_answer": true,
"include_domains": ["docs.aws.amazon.com", "cloud.google.com"],
"exclude_domains": ["reddit.com", "twitter.com"],
"include_raw_content": false
}Then run:
bash
bash -c 'curl -s -X POST "https://api.tavily.com/search" --header "Content-Type: application/json" --header "Authorization: Bearer ${TAVILY_API_KEY}" -d @/tmp/tavily_request.json'Common advanced parameters:
- : When
include_answer, Tavily returns a summarizedtruefieldanswer - : Whitelist of domains to include
include_domains - : Blacklist of domains to exclude
exclude_domains - : Whether to include raw page content (HTML / raw text). Default is
include_raw_content.false
将以下内容写入:
/tmp/tavily_request.jsonjson
{
"query": "serverless SaaS pricing best practices",
"search_depth": "advanced",
"max_results": 8,
"include_answer": true,
"include_domains": ["docs.aws.amazon.com", "cloud.google.com"],
"exclude_domains": ["reddit.com", "twitter.com"],
"include_raw_content": false
}然后运行:
bash
bash -c 'curl -s -X POST "https://api.tavily.com/search" --header "Content-Type: application/json" --header "Authorization: Bearer ${TAVILY_API_KEY}" -d @/tmp/tavily_request.json'常见高级参数:
- :设为
include_answer时,Tavily会返回一个汇总的true字段answer - :允许搜索的域名白名单
include_domains - :禁止搜索的域名黑名单
exclude_domains - :是否包含页面原始内容(HTML/纯文本),默认值为
include_raw_contentfalse
3. Typical Response Structure (Example)
3. 典型响应结构(示例)
Tavily returns a JSON object similar to:
json
{
"answer": "Brief summary...",
"results": [
{
"title": "Article title",
"url": "https://example.com/article",
"content": "Snippet or extracted content...",
"score": 0.89
}
]
}In agents or automation flows you typically:
- Use as a concise, ready-to-use summary
answer - Iterate over to extract
results+titleas references / citationsurl
Tavily返回的JSON对象类似如下格式:
json
{
"answer": "Brief summary...",
"results": [
{
"title": "Article title",
"url": "https://example.com/article",
"content": "Snippet or extracted content...",
"score": 0.89
}
]
}在Agent或自动化流程中,你通常会:
- 使用作为简洁、可直接使用的摘要
answer - 遍历提取
results+title作为参考/引用url
4. Using Tavily in n8n (HTTP Request Node)
4. 在n8n中使用Tavily(HTTP请求节点)
To integrate Tavily in n8n with the HTTP Request node:
- Method:
POST - URL:
https://api.tavily.com/search - Headers:
- :
Content-Typeapplication/json - :
AuthorizationBearer {{ $env.TAVILY_API_KEY }}
- Body: JSON, for example:
json
{
"query": "n8n self-hosted best practices",
"search_depth": "basic",
"max_results": 5
}This lets you pipe Tavily search results into downstream nodes such as LLMs, Notion, Slack notifications, etc.
要在n8n中通过HTTP请求节点集成Tavily:
- 方法:
POST - URL:
https://api.tavily.com/search - 请求头:
- :
Content-Typeapplication/json - :
AuthorizationBearer {{ $env.TAVILY_API_KEY }}
- 请求体:JSON格式,例如:
json
{
"query": "n8n self-hosted best practices",
"search_depth": "basic",
"max_results": 5
}这样你就可以将Tavily的搜索结果传递给下游节点,如LLM、Notion、Slack通知等。
Guidelines
使用指南
- Use only when necessary: it consumes more resources and is best for deep research / high-value questions.
advanced - Mind quotas and cost: Tavily typically offers free tiers plus paid usage; in automation flows, add guards (filters, rate limits).
- Post-process results with an LLM: use Tavily for retrieval, then let your LLM summarize, extract tables, or generate reports.
- Handle sensitive data carefully: avoid sending raw secrets or PII directly in ; anonymize or mask when possible.
query
- 仅在必要时使用模式:该模式会消耗更多资源,最适合深度研究/高价值问题。
advanced - 注意配额和成本:Tavily通常提供免费层和付费使用选项;在自动化流程中,添加防护措施(过滤器、速率限制)。
- 用LLM对结果进行后处理:使用Tavily进行检索,然后让LLM生成摘要、提取表格或生成报告。
- 谨慎处理敏感数据:避免在中直接发送原始密钥或个人身份信息(PII);尽可能匿名化或掩码处理。
query