tavily

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Tavily Search API

Tavily 搜索API

Use Tavily's search API via direct
curl
calls to perform live web search, ideal for powering retrieval-augmented generation (RAG) for LLMs and agents.
Official documentation:
https://docs.tavily.com/

通过直接调用
curl
使用Tavily的搜索API来执行实时网络搜索,非常适合为LLM和Agent提供检索增强生成(RAG)支持。
官方文档:
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

前置条件

  1. Sign up for Tavily and create an API key
  2. 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 using
$VAR
in a command that pipes to another command, wrap the command containing
$VAR
in
bash -c '...'
. Due to a Claude Code bug, environment variables are silently cleared when pipes are used directly.
bash
bash -c 'curl -s "https://api.example.com" -H "Authorization: Bearer $API_KEY"' | jq '.results[] | {title, url}'
  1. 注册Tavily账号并创建API密钥
  2. 将你的Tavily API密钥存储到环境变量
    TAVILY_API_KEY
在本地Shell或运行时环境中设置,例如:
bash
export TAVILY_API_KEY="tvly-xxxxxxxxxxxxxxxx"

重要提示: 当在管道到另一个命令的命令中使用
$VAR
时,将包含
$VAR
的命令用
bash -c '...'
包裹。由于Claude Code的一个bug,当直接使用管道时,环境变量会被静默清除。
bash
bash -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
TAVILY_API_KEY
set in your environment. The base endpoint for the Tavily search API is a
POST
request to:
  • https://api.tavily.com/search
with a JSON body.

以下所有示例均假设你已在环境中设置了
TAVILY_API_KEY
。 Tavily搜索API的基础端点为向以下地址发送
POST
请求:
  • https://api.tavily.com/search
请求体为JSON格式。

1. Basic Search

1. 基础搜索

Write to
/tmp/tavily_request.json
:
json
{
  "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:
  • query
    : Search query or natural language question
  • search_depth
    :
    • "basic"
      – faster, good for most use cases
    • "advanced"
      – deeper search and higher recall
  • max_results
    : Maximum number of results to return (e.g. 3 / 5 / 10)

将以下内容写入
/tmp/tavily_request.json
json
{
  "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"
      – 搜索更深入,召回率更高
  • max_results
    :返回的最大结果数(例如3/5/10)

2. Advanced Search

2. 高级搜索

Write to
/tmp/tavily_request.json
:
json
{
  "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:
  • include_answer
    : When
    true
    , Tavily returns a summarized
    answer
    field
  • include_domains
    : Whitelist of domains to include
  • exclude_domains
    : Blacklist of domains to exclude
  • include_raw_content
    : Whether to include raw page content (HTML / raw text). Default is
    false
    .

将以下内容写入
/tmp/tavily_request.json
json
{
  "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
    :设为
    true
    时,Tavily会返回一个汇总的
    answer
    字段
  • include_domains
    :允许搜索的域名白名单
  • exclude_domains
    :禁止搜索的域名黑名单
  • include_raw_content
    :是否包含页面原始内容(HTML/纯文本),默认值为
    false

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
    answer
    as a concise, ready-to-use summary
  • Iterate over
    results
    to extract
    title
    +
    url
    as references / citations

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-Type
      :
      application/json
    • Authorization
      :
      Bearer {{ $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-Type
      :
      application/json
    • Authorization
      :
      Bearer {{ $env.TAVILY_API_KEY }}
  • 请求体:JSON格式,例如:
json
{
  "query": "n8n self-hosted best practices",
  "search_depth": "basic",
  "max_results": 5
}
这样你就可以将Tavily的搜索结果传递给下游节点,如LLM、Notion、Slack通知等。

Guidelines

使用指南

  1. Use
    advanced
    only when necessary
    : it consumes more resources and is best for deep research / high-value questions.
  2. Mind quotas and cost: Tavily typically offers free tiers plus paid usage; in automation flows, add guards (filters, rate limits).
  3. Post-process results with an LLM: use Tavily for retrieval, then let your LLM summarize, extract tables, or generate reports.
  4. Handle sensitive data carefully: avoid sending raw secrets or PII directly in
    query
    ; anonymize or mask when possible.
  1. 仅在必要时使用
    advanced
    模式
    :该模式会消耗更多资源,最适合深度研究/高价值问题。
  2. 注意配额和成本:Tavily通常提供免费层和付费使用选项;在自动化流程中,添加防护措施(过滤器、速率限制)。
  3. 用LLM对结果进行后处理:使用Tavily进行检索,然后让LLM生成摘要、提取表格或生成报告。
  4. 谨慎处理敏感数据:避免在
    query
    中直接发送原始密钥或个人身份信息(PII);尽可能匿名化或掩码处理。