web-search-tavily

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Web Search (Tavily API)

网页搜索(Tavily API)

Search the web using Tavily's AI-optimized search API. Returns high-quality, structured results with relevance scores and optional AI-generated summaries.
Note: This skill requires a Tavily API key. For basic web search using the agent's built-in capability, see
web-search
.
使用Tavily的AI优化搜索API进行网页搜索。返回带有相关性评分和可选AI生成摘要的高质量结构化结果。
注意: 本技能需要Tavily API密钥。如果要使用Agent内置功能进行基础网页搜索,请查看
web-search

When to Use This Skill

何时使用本技能

Use this skill when:
  • You need to find current information not in your training data
  • The user asks about recent events, news, or updates
  • You need to verify facts or find authoritative sources
  • Research requires real-time web data
  • Keywords mentioned: search, look up, find online, current, latest, news
Do NOT use this skill when:
  • Information is already in your knowledge base and doesn't need verification
  • The user asks about historical facts that don't change
  • You're working with local files or code (use other tools)
  • A more specific skill exists for the task (e.g., documentation lookup)
在以下场景使用本技能:
  • 你需要查找训练数据中没有的最新信息
  • 用户询问近期事件、新闻或更新内容
  • 你需要验证事实或查找权威来源
  • 研究需要实时网页数据
  • 提及以下关键词:搜索、查找、在线查询、当前、最新、新闻
请勿在以下场景使用本技能:
  • 信息已存在于你的知识库中且无需验证
  • 用户询问不会变化的历史事实
  • 你正在处理本地文件或代码(使用其他工具)
  • 存在更适合该任务的特定技能(例如:文档查询)

Prerequisites

前提条件

Before using this skill, ensure:
  • TAVILY_API_KEY environment variable is set with a valid API key
  • Deno is installed (for running the search script)
  • Internet access is available
Get a Tavily API key at: https://tavily.com
使用本技能前,请确保:
  • 已设置TAVILY_API_KEY环境变量,且密钥有效
  • 已安装Deno(用于运行搜索脚本)
  • 具备互联网访问权限
获取Tavily API密钥:https://tavily.com

Quick Start

快速开始

Run a simple search:
bash
deno run --allow-env --allow-net=api.tavily.com scripts/search.ts "your search query"
Example with AI-generated answer:
bash
deno run --allow-env --allow-net=api.tavily.com scripts/search.ts "React 19 new features" --answer
运行简单搜索:
bash
deno run --allow-env --allow-net=api.tavily.com scripts/search.ts "你的搜索查询"
带AI生成答案的示例:
bash
deno run --allow-env --allow-net=api.tavily.com scripts/search.ts "React 19 new features" --answer

Script Usage

脚本使用

bash
deno run --allow-env --allow-net=api.tavily.com scripts/search.ts [options] "query"
bash
deno run --allow-env --allow-net=api.tavily.com scripts/search.ts [选项] "查询词"

Options

选项

OptionDescriptionDefault
--answer
Include AI-generated answer summaryfalse
--depth <level>
Search depth:
basic
or
advanced
basic
--results <n>
Number of results to return5
--topic <type>
Topic type:
general
,
news
, or
finance
general
--time <range>
Time filter:
day
,
week
,
month
, or
year
none
--include <domains>
Only include these domains (comma-separated)none
--exclude <domains>
Exclude these domains (comma-separated)none
--raw
Include raw page content in resultsfalse
--json
Output as JSON (for programmatic use)false
--help
Show help message-
选项描述默认值
--answer
包含AI生成的答案摘要false
--depth <level>
搜索深度:
basic
advanced
basic
--results <n>
返回结果数量5
--topic <type>
主题类型:
general
news
finance
general
--time <range>
时间筛选:
day
week
month
year
none
--include <domains>
仅包含这些域名(逗号分隔)none
--exclude <domains>
排除这些域名(逗号分隔)none
--raw
在结果中包含原始页面内容false
--json
以JSON格式输出(供程序使用)false
--help
显示帮助信息-

Search Parameters

搜索参数

Topic Types

主题类型

  • general (default): Broad web search across all content types
  • news: Prioritizes news articles and current events
  • finance: Focuses on financial information and market data
  • general(默认):覆盖所有内容类型的广泛网页搜索
  • news:优先展示新闻文章和当前事件
  • finance:聚焦金融信息和市场数据

Search Depth

搜索深度

  • basic (default): Fast search, good for most queries
  • advanced: Deeper search with more comprehensive results (slower, higher API cost)
  • basic(默认):快速搜索,适合大多数查询
  • advanced:深度搜索,结果更全面(速度较慢,API成本更高)

Time Range

时间范围

Filter results by recency:
  • day: Last 24 hours
  • week: Last 7 days
  • month: Last 30 days
  • year: Last 365 days
按时效性筛选结果:
  • day:过去24小时
  • week:过去7天
  • month:过去30天
  • year:过去365天

Domain Filtering

域名筛选

Control which sites appear in results:
bash
undefined
控制结果中显示的站点:
bash
undefined

Only search documentation sites

仅搜索文档站点

scripts/search.ts "React hooks" --include docs.react.dev,developer.mozilla.org
scripts/search.ts "React hooks" --include docs.react.dev,developer.mozilla.org

Exclude social media

排除社交媒体

scripts/search.ts "AI news" --exclude twitter.com,reddit.com
undefined
scripts/search.ts "AI news" --exclude twitter.com,reddit.com
undefined

Output Format

输出格式

Human-Readable Output (default)

人类可读格式(默认)

🔍 Search: "React 19 new features"

Found 5 results in 234ms

📝 AI Answer:
────────────────────────────────────────────────────────────
React 19 introduces several new features including...
────────────────────────────────────────────────────────────

1. React 19 Release Notes
   https://react.dev/blog/2024/04/25/react-19
   React 19 is now available on npm! This release includes...
   Score: 0.987

2. What's New in React 19
   https://example.com/react-19-features
   A comprehensive overview of React 19's new features...
   Score: 0.945
🔍 搜索:"React 19 new features"

在234ms内找到5条结果

📝 AI答案:
────────────────────────────────────────────────────────────
React 19引入了多个新功能,包括...
────────────────────────────────────────────────────────────

1. React 19发布说明
   https://react.dev/blog/2024/04/25/react-19
   React 19现已在npm上线!本次版本包含...
   评分:0.987

2. React 19新功能详解
   https://example.com/react-19-features
   关于React 19新功能的全面概述...
   评分:0.945

JSON Output (--json)

JSON格式(--json)

json
{
  "query": "React 19 new features",
  "results": [
    {
      "title": "React 19 Release Notes",
      "url": "https://react.dev/blog/2024/04/25/react-19",
      "content": "React 19 is now available on npm...",
      "score": 0.987,
      "published_date": "2024-04-25"
    }
  ],
  "answer": "React 19 introduces several new features...",
  "response_time": 234
}
json
{
  "query": "React 19 new features",
  "results": [
    {
      "title": "React 19 Release Notes",
      "url": "https://react.dev/blog/2024/04/25/react-19",
      "content": "React 19 is now available on npm...",
      "score": 0.987,
      "published_date": "2024-04-25"
    }
  ],
  "answer": "React 19 introduces several new features...",
  "response_time": 234
}

Result Fields

结果字段

FieldTypeDescription
title
stringPage title
url
stringSource URL
content
stringRelevant excerpt from the page
score
numberRelevance score (0-1, higher is better)
published_date
stringPublication date (if available)
raw_content
stringFull page content (only with --raw)
字段类型描述
title
字符串页面标题
url
字符串来源URL
content
字符串页面相关摘录
score
数字相关性评分(0-1,分数越高相关性越强)
published_date
字符串发布日期(若可用)
raw_content
字符串完整页面内容(仅在使用--raw时提供)

Examples

示例

Example 1: Current Events Search

示例1:当前事件搜索

Scenario: Find recent news about a technology topic
bash
scripts/search.ts "OpenAI GPT-5 announcement" --topic news --time week --answer
Expected output: Recent news articles about GPT-5, with an AI-generated summary
场景:查找技术主题的近期新闻
bash
scripts/search.ts "OpenAI GPT-5 announcement" --topic news --time week --answer
预期输出:关于GPT-5的近期新闻文章,附带AI生成的摘要

Example 2: Documentation Lookup

示例2:文档查询

Scenario: Find specific technical documentation
bash
scripts/search.ts "Deno deploy edge functions tutorial" --depth advanced --results 10
Expected output: Comprehensive results from documentation and tutorial sites
场景:查找特定技术文档
bash
scripts/search.ts "Deno deploy edge functions tutorial" --depth advanced --results 10
预期输出:来自文档和教程站点的全面结果

Example 3: Fact Verification

示例3:事实验证

Scenario: Verify a specific claim or statistic
bash
scripts/search.ts "world population 2024" --include un.org,worldbank.org,census.gov --json
Expected output: JSON results from authoritative sources for programmatic verification
场景:验证特定声明或统计数据
bash
scripts/search.ts "world population 2024" --include un.org,worldbank.org,census.gov --json
预期输出:来自权威来源的JSON结果,供程序验证使用

Example 4: Financial Research

示例4:金融研究

Scenario: Research market information
bash
scripts/search.ts "NVIDIA stock analysis 2024" --topic finance --answer
Expected output: Financial analysis and market data with AI summary
场景:研究市场信息
bash
scripts/search.ts "NVIDIA stock analysis 2024" --topic finance --answer
预期输出:附带AI摘要的金融分析和市场数据

Common Issues and Solutions

常见问题与解决方案

Issue: "TAVILY_API_KEY environment variable is not set"

问题:"TAVILY_API_KEY environment variable is not set"

Symptoms: Script exits immediately with API key error
Solution:
  1. Get an API key from https://tavily.com
  2. Set the environment variable:
    bash
    export TAVILY_API_KEY="your-api-key-here"
  3. Or run with the variable inline:
    bash
    TAVILY_API_KEY="your-key" deno run --allow-env --allow-net=api.tavily.com scripts/search.ts "query"
症状:脚本因API密钥错误立即退出
解决方案
  1. https://tavily.com获取API密钥
  2. 设置环境变量:
    bash
    export TAVILY_API_KEY="your-api-key-here"
  3. 或在运行时直接传入变量:
    bash
    TAVILY_API_KEY="your-key" deno run --allow-env --allow-net=api.tavily.com scripts/search.ts "query"

Issue: "Invalid Tavily API key"

问题:"Invalid Tavily API key"

Symptoms: 401 authentication error
Solution:
  1. Verify your API key is correct (no extra spaces)
  2. Check if your API key has expired
  3. Verify your Tavily account is active
症状:出现401认证错误
解决方案
  1. 验证API密钥是否正确(无多余空格)
  2. 检查API密钥是否过期
  3. 确认你的Tavily账户处于活跃状态

Issue: "Tavily API rate limit exceeded"

问题:"Tavily API rate limit exceeded"

Symptoms: 429 error response
Solution:
  1. Wait a moment and retry
  2. Reduce request frequency
  3. Consider upgrading your Tavily plan for higher limits
症状:出现429错误响应
解决方案
  1. 等待片刻后重试
  2. 降低请求频率
  3. 考虑升级Tavily套餐以获取更高限额

Issue: No results returned

问题:无结果返回

Symptoms: Empty results array
Solution:
  1. Try broader search terms
  2. Remove domain filters that might be too restrictive
  3. Check if the topic exists online
  4. Try
    --depth advanced
    for harder queries
症状:结果数组为空
解决方案
  1. 尝试更宽泛的搜索词
  2. 移除可能过于严格的域名筛选
  3. 确认该主题是否存在于网络上
  4. 对较难的查询尝试使用
    --depth advanced

Limitations

局限性

This skill has the following limitations:
  • Requires active internet connection
  • API rate limits apply based on your Tavily plan
  • Results depend on Tavily's index coverage
  • Cannot access paywalled or login-required content
  • Real-time accuracy depends on Tavily's crawling frequency
  • Maximum query length and result count have API limits
本技能存在以下局限性:
  • 需要活跃的互联网连接
  • 根据你的Tavily套餐,API有调用频率限制
  • 结果依赖Tavily的索引覆盖范围
  • 无法访问付费墙或需要登录的内容
  • 实时准确性取决于Tavily的爬取频率
  • 查询长度和结果数量存在API限制

Related Skills

相关技能

  • research-workflow: For comprehensive research projects that use multiple searches with planning and synthesis
  • research-workflow:适用于需要多次搜索、规划和综合分析的全面研究项目