search
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSearch Skill
搜索Skill
Search the web and get relevant results optimized for LLM consumption.
使用网页搜索并获取针对LLM使用优化的相关结果。
Prerequisites
前提条件
Tavily API Key Required - Get your key at https://tavily.com
Add to :
~/.claude/settings.jsonjson
{
"env": {
"TAVILY_API_KEY": "tvly-your-api-key-here"
}
}需要Tavily API密钥 - 前往https://tavily.com获取你的密钥。
添加到:
~/.claude/settings.jsonjson
{
"env": {
"TAVILY_API_KEY": "tvly-your-api-key-here"
}
}Quick Start
快速开始
Using the Script
使用脚本
bash
./scripts/search.sh '<json>'Examples:
bash
undefinedbash
./scripts/search.sh '<json>'示例:
bash
undefinedBasic search
基础搜索
./scripts/search.sh '{"query": "python async patterns"}'
./scripts/search.sh '{"query": "python async patterns"}'
With options
带选项的搜索
./scripts/search.sh '{"query": "React hooks tutorial", "max_results": 10}'
./scripts/search.sh '{"query": "React hooks tutorial", "max_results": 10}'
Advanced search with filters
带过滤器的高级搜索
./scripts/search.sh '{"query": "AI news", "topic": "news", "time_range": "week", "max_results": 10}'
./scripts/search.sh '{"query": "AI news", "topic": "news", "time_range": "week", "max_results": 10}'
Domain-filtered search
域名过滤搜索
./scripts/search.sh '{"query": "machine learning", "include_domains": ["arxiv.org", "github.com"], "search_depth": "advanced"}'
undefined./scripts/search.sh '{"query": "machine learning", "include_domains": ["arxiv.org", "github.com"], "search_depth": "advanced"}'
undefinedBasic Search
基础搜索
bash
curl --request POST \
--url https://api.tavily.com/search \
--header "Authorization: Bearer $TAVILY_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"query": "latest developments in quantum computing",
"max_results": 5
}'bash
curl --request POST \
--url https://api.tavily.com/search \
--header "Authorization: Bearer $TAVILY_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"query": "latest developments in quantum computing",
"max_results": 5
}'Advanced Search
高级搜索
bash
curl --request POST \
--url https://api.tavily.com/search \
--header "Authorization: Bearer $TAVILY_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"query": "machine learning best practices",
"max_results": 10,
"search_depth": "advanced",
"include_domains": ["arxiv.org", "github.com"],
"chunks_per_source": 3
}'bash
curl --request POST \
--url https://api.tavily.com/search \
--header "Authorization: Bearer $TAVILY_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"query": "machine learning best practices",
"max_results": 10,
"search_depth": "advanced",
"include_domains": ["arxiv.org", "github.com"],
"chunks_per_source": 3
}'API Reference
API参考
Endpoint
端点
POST https://api.tavily.com/searchPOST https://api.tavily.com/searchHeaders
请求头
| Header | Value |
|---|---|
| |
| |
| 请求头 | 值 |
|---|---|
| |
| |
Request Body
请求体
| Field | Type | Default | Description |
|---|---|---|---|
| string | Required | Search query (keep under 400 chars) |
| integer | 5 | Maximum results (0-20) |
| string | | |
| string | | |
| integer | 3 | Chunks per source (advanced/fast only) |
| string | null | |
| array | [] | Domains to include (max 300) |
| array | [] | Domains to exclude (max 150) |
| boolean | false | Include AI-generated answer |
| boolean | false | Include full page content |
| boolean | false | Include image results |
| 字段 | 类型 | 默认值 | 描述 |
|---|---|---|---|
| 字符串 | 必填 | 搜索查询(保持在400字符以内) |
| 整数 | 5 | 最大结果数(0-20) |
| 字符串 | | |
| 字符串 | | |
| 整数 | 3 | 每个来源的内容块数(仅advanced/fast模式可用) |
| 字符串 | null | |
| 数组 | [] | 要包含的域名(最多300个) |
| 数组 | [] | 要排除的域名(最多150个) |
| 布尔值 | false | 包含AI生成的答案 |
| 布尔值 | false | 包含完整页面内容 |
| 布尔值 | false | 包含图片结果 |
Response Format
响应格式
json
{
"query": "latest developments in quantum computing",
"results": [
{
"title": "Page Title",
"url": "https://example.com/page",
"content": "Extracted text snippet...",
"score": 0.85
}
],
"response_time": 1.2
}json
{
"query": "latest developments in quantum computing",
"results": [
{
"title": "Page Title",
"url": "https://example.com/page",
"content": "Extracted text snippet...",
"score": 0.85
}
],
"response_time": 1.2
}Search Depth
搜索深度
| Depth | Latency | Relevance | Content Type |
|---|---|---|---|
| Lowest | Lower | NLP summary |
| Low | Good | Chunks |
| Medium | High | NLP summary |
| Higher | Highest | Chunks |
When to use each:
- : Real-time chat, autocomplete
ultra-fast - : Need chunks but latency matters
fast - : General-purpose, balanced
basic - : Precision matters (default recommendation)
advanced
| 深度 | 延迟 | 相关性 | 内容类型 |
|---|---|---|---|
| 最低 | 较低 | NLP摘要 |
| 低 | 良好 | 内容块 |
| 中等 | 高 | NLP摘要 |
| 较高 | 最高 | 内容块 |
使用场景:
- : 实时聊天、自动补全
ultra-fast - : 需要内容块但对延迟有要求
fast - : 通用用途,平衡延迟与相关性
basic - : 对精度有要求(推荐默认使用)
advanced
Examples
示例
News Search
新闻搜索
bash
curl --request POST \
--url https://api.tavily.com/search \
--header "Authorization: Bearer $TAVILY_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"query": "AI news today",
"topic": "news",
"time_range": "day",
"max_results": 10
}'bash
curl --request POST \
--url https://api.tavily.com/search \
--header "Authorization: Bearer $TAVILY_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"query": "AI news today",
"topic": "news",
"time_range": "day",
"max_results": 10
}'Domain-Filtered Search
域名过滤搜索
bash
curl --request POST \
--url https://api.tavily.com/search \
--header "Authorization: Bearer $TAVILY_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"query": "Python async best practices",
"include_domains": ["docs.python.org", "realpython.com", "github.com"],
"search_depth": "advanced"
}'bash
curl --request POST \
--url https://api.tavily.com/search \
--header "Authorization: Bearer $TAVILY_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"query": "Python async best practices",
"include_domains": ["docs.python.org", "realpython.com", "github.com"],
"search_depth": "advanced"
}'Search with Full Content
包含完整内容的搜索
bash
curl --request POST \
--url https://api.tavily.com/search \
--header "Authorization: Bearer $TAVILY_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"query": "React hooks tutorial",
"max_results": 3,
"include_raw_content": true
}'bash
curl --request POST \
--url https://api.tavily.com/search \
--header "Authorization: Bearer $TAVILY_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"query": "React hooks tutorial",
"max_results": 3,
"include_raw_content": true
}'Finance Search
金融搜索
bash
curl --request POST \
--url https://api.tavily.com/search \
--header "Authorization: Bearer $TAVILY_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"query": "AAPL earnings Q4 2024",
"topic": "finance",
"max_results": 10
}'bash
curl --request POST \
--url https://api.tavily.com/search \
--header "Authorization: Bearer $TAVILY_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"query": "AAPL earnings Q4 2024",
"topic": "finance",
"max_results": 10
}'Tips
提示
- Keep queries under 400 characters - Think search query, not prompt
- Break complex queries into sub-queries - Better results than one massive query
- Use to focus on trusted sources
include_domains - Use for recent information
time_range - Filter by (0-1) to get highest relevance results
score
- 保持查询在400字符以内 - 思考搜索查询,而不是提示词
- 将复杂查询拆分为子查询 - 比单个庞大的查询效果更好
- 使用聚焦可信来源
include_domains - 使用获取最新信息
time_range - 按(0-1)过滤 获取最高相关性结果
score