通过托管密钥认证调用 Exa API,完成网页搜索、内容抓取、相似页查找与异步研究任务。
文档
Tavily Search
试用通过 Maton 网关调用 Tavily API,完成网页搜索、内容提取、站点爬取与异步研究任务。
它能做什么
通过 Maton 网关代理 Tavily API,使用托管 API Key 完成身份验证。共暴露五个端点:search、extract、crawl、map 与 research。search 支持按日期、域名、搜索深度和主题过滤,可选择附带 AI 生成的答案;research 为异步任务,完成后返回带有来源引用的研究内容,引用格式支持 numbered、MLA、APA、Chicago。
什么时候用它
- 进行网页搜索并附带 AI 摘要答案
- 从一个或多个 URL 抽取页面正文
- 发现站点结构或对整个站点执行爬取
- 发起异步研究任务并获取带引用的结论
技能文档
Tavily
Access the Tavily API with managed API key authentication. Perform AI-powered web searches, extract content from URLs, crawl websites, map site structure, and run in-depth research tasks.
Quick Start
# Search the web
python <<'EOF'
import urllib.request, os, json
data = json.dumps({"query": "latest AI news", "max_results": 5}).encode()
req = urllib.request.Request('https://gateway.maton.ai/tavily/search', data=data, method='POST')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
req.add_header('Content-Type', 'application/json')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
Base URL
https://gateway.maton.ai/tavily/{endpoint}
Replace {endpoint} with the Tavily API endpoint (search, extract, crawl, map, research). The gateway proxies requests to api.tavily.com and automatically injects your API key.
Authentication
All requests require the Maton API key in the Authorization header:
Authorization: Bearer $MATON_API_KEY
Environment Variable: Set your API key as MATON_API_KEY:
export MATON_API_KEY="YOUR_API_KEY"
Getting Your API Key
- Sign in or create an account at maton.ai
- Go to maton.ai/settings
- Copy your API key
Connection Management
Manage your Tavily API key connections at https://ctrl.maton.ai.
List Connections
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://ctrl.maton.ai/connections?app=tavily&status=ACTIVE')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
Create Connection
python <<'EOF'
import urllib.request, os, json
data = json.dumps({'app': 'tavily', 'method': 'API_KEY'}).encode()
req = urllib.request.Request('https://ctrl.maton.ai/connections', data=data, method='POST')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
req.add_header('Content-Type', 'application/json')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
Open the returned url in a browser to enter your Tavily API key.
Get Connection
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://ctrl.maton.ai/connections/{connection_id}')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
Delete Connection
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://ctrl.maton.ai/connections/{connection_id}', method='DELETE')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
Specifying Connection
If you have multiple Tavily connections, specify which one to use with the Maton-Connection header:
python <<'EOF'
import urllib.request, os, json
data = json.dumps({"query": "AI news"}).encode()
req = urllib.request.Request('https://gateway.maton.ai/tavily/search', data=data, method='POST')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
req.add_header('Content-Type', 'application/json')
req.add_header('Maton-Connection', '{connection_id}')
print(json.dumps(json.load(urllib.request.urlopen(req)), indent=2))
EOF
If omitted, the gateway uses the default (oldest) active connection.
API Reference
Search
Perform AI-powered web search with optional answer generation.
POST /tavily/search
Content-Type: application/json
{
"query": "What is artificial intelligence?",
"max_results": 5
}
Request Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| query | string | Yes | Search query string |
| max_results | integer | No | Number of results (0-20, default 5) |
| search_depth | string | No | basic, advanced, fast, ultra-fast (default: basic) |
| topic | string | No | general or news (default: general) |
| include_answer | boolean/string | No | true, false, basic, advanced |
| include_raw_content | boolean/string | No | true, false, markdown, text |
| include_images | boolean | No | Include image results |
| include_domains | array | No | Only search these domains (max 300) |
| exclude_domains | array | No | Exclude these domains (max 150) |
| time_range | string | No | day, week, month, year |
| start_date | string | No | Filter by date (YYYY-MM-DD) |
| end_date | string | No | Filter by date (YYYY-MM-DD) |
Response:
{
"query": "What is artificial intelligence?",
"answer": "Artificial intelligence (AI) is...",
"results": [
{
"title": "What is AI?",
"url": "https://example.com/ai",
"content": "AI is a branch of computer science...",
"score": 0.95
}
],
"response_time": 0.55
}
Extract
Extract content from one or more URLs.
POST /tavily/extract
Content-Type: application/json
{
"urls": ["https://example.com/article"],
"format": "markdown"
}
Request Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| urls | string/array | Yes | URL or array of URLs to extract |
| query | string | No | User intent for reranking content |
| chunks_per_source | integer | No | Max chunks per source (1-5, default 3) |
| extract_depth | string | No | basic or advanced (default: basic) |
| format | string | No | markdown or text (default: markdown) |
| include_images | boolean | No | Include extracted images |
| timeout | float | No | Max wait time in seconds (1-60) |
Response:
{
"results": [
{
"url": "https://example.com/article",
"raw_content": "# Article Title\n\nContent in markdown...",
"images": [],
"favicon": "https://example.com/favicon.ico"
}
],
"failed_results": [],
"response_time": 0.01
}
Map
Discover URLs from a website without extracting content.
POST /tavily/map
Content-Type: application/json
{
"url": "https://example.com",
"limit": 20
}
Request Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| url | string | Yes | Root URL to begin mapping |
| instructions | string | No | Natural language guidance for crawler |
| max_depth | integer | No | Exploration depth (1-5, default 1) |
| max_breadth | integer | No | Links per page level (1-500, default 20) |
| limit | integer | No | Total links to process (default 50) |
| select_paths | array | No | Regex patterns for URL inclusion |
| exclude_paths | array | No | Regex patterns for URL exclusion |
| allow_external | boolean | No | Include external links (default true) |
| timeout | float | No | Max wait time (10-150 seconds) |
Response:
{
"base_url": "https://example.com",
"results": [
"https://example.com/about",
"https://example.com/products",
"https://example.com/contact"
],
"response_time": 0.1
}
Crawl
Crawl a website and extract content from discovered pages.
POST /tavily/crawl
Content-Type: application/json
{
"url": "https://example.com",
"limit": 10,
"max_depth": 2
}
Request Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| url | string | Yes | Root URL to begin crawl |
| instructions | string | No | Natural language guidance (2x cost) |
| chunks_per_source | integer | No | Max snippets per source (1-5, default 3) |
| max_depth | integer | No | Exploration depth (1-5, default 1) |
| max_breadth | integer | No | Links per page level (1-500, default 20) |
| limit | integer | No | Total links to process (default 50) |
| select_paths | array | No | Regex patterns for URL inclusion |
| exclude_paths | array | No | Regex patterns for URL exclusion |
| allow_external | boolean | No | Include external links (default true) |
| extract_depth | string | No | basic or advanced (default: basic) |
| format | string | No | markdown or text (default: markdown) |
| timeout | float | No | Max wait time (10-150 seconds) |
Response:
{
"base_url": "https://example.com",
"results": [
{
"url": "https://example.com/about",
"raw_content": "# About Us\n\nContent...",
"favicon": "https://example.com/favicon.ico"
}
],
"response_time": 0.09
}
Research Tasks
Run async research tasks that gather sources and synthesize findings.
Create Research Task
POST /tavily/research
Content-Type: application/json
{
"input": "What are the latest developments in AI safety?",
"model": "mini"
}
Request Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| input | string | Yes | Research task or question |
| model | string | No | mini, pro, or auto (default: auto) |
| stream | boolean | No | Stream results via SSE (default: false) |
| output_schema | object | No | JSON Schema for structured output |
| citation_format | string | No | numbered, mla, apa, chicago |
Response:
{
"request_id": "582a6eec-9a10-43ba-830f-d9a1aeb19f07",
"status": "pending",
"input": "What are the latest developments in AI safety?",
"model": "mini",
"created_at": "2026-03-08T11:36:12.674507+00:00",
"response_time": 0.05
}
Get Research Task
GET /tavily/research/{request_id}
Response (completed):
{
"request_id": "582a6eec-9a10-43ba-830f-d9a1aeb19f07",
"status": "completed",
"content": "## AI Safety Developments\n\nResearch findings...",
"sources": [
{
"title": "Source Title",
"url": "https://example.com/source",
"favicon": "https://example.com/favicon.ico"
}
],
"created_at": "2026-03-08T11:36:12.674507+00:00",
"response_time": 45
}
Status values: pending, in_progress, completed, failed
Code Examples
JavaScript
// Search with answer
const response = await fetch('https://gateway.maton.ai/tavily/search', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.MATON_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: 'latest AI news',
max_results: 5,
include_answer: true
})
});
const data = await response.json();
Python
import os
import requests
# Search with answer
response = requests.post(
'https://gateway.maton.ai/tavily/search',
headers={'Authorization': f'Bearer {os.environ["MATON_API_KEY"]}'},
json={
'query': 'latest AI news',
'max_results': 5,
'include_answer': True
}
)
data = response.json()
Notes
- Search endpoints return AI-generated answers when
include_answeris enabled - Map returns URLs only; Crawl returns URLs with extracted content
- Using
instructionsparameter in crawl/map doubles the credit cost - Research tasks are async - poll with GET to check status
- Research models:
mini(fast/efficient),pro(comprehensive) - IMPORTANT: When piping curl output to
jqor other commands, environment variables like$MATON_API_KEYmay not expand correctly in some shell environments
Error Handling
| Status | Meaning |
|---|---|
| 400 | Missing Tavily connection or invalid request |
| 401 | Invalid or missing Maton API key |
| 429 | Rate limit exceeded |
| 432 | Plan limit exceeded |
| 433 | Pay-as-you-go limit exceeded |
| 4xx/5xx | Passthrough error from Tavily API |
Resources
相关技能
通过托管认证调用 Firecrawl API,提供网页抓取、整站爬取、URL 发现和带正文内容的搜索能力。
通过托管 OAuth 代理接入 Google Search Console,查询搜索分析数据、管理 sitemap 并查看站点表现。
通过托管认证接入 Apify API,运行爬虫并管理 actors、数据集、键值存储与定时任务。
通过 Brave Search API 完成网页、图片、新闻与视频搜索,认证由网关托管。
零依赖的原生 Node.js 脚本,调用 Tavily 搜索接口,凭证只从进程环境读取。