文档

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

  1. Sign in or create an account at maton.ai
  2. Go to maton.ai/settings
  3. 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

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:

ParameterTypeRequiredDescription
querystringYesSearch query string
max_resultsintegerNoNumber of results (0-20, default 5)
search_depthstringNobasic, advanced, fast, ultra-fast (default: basic)
topicstringNogeneral or news (default: general)
include_answerboolean/stringNotrue, false, basic, advanced
include_raw_contentboolean/stringNotrue, false, markdown, text
include_imagesbooleanNoInclude image results
include_domainsarrayNoOnly search these domains (max 300)
exclude_domainsarrayNoExclude these domains (max 150)
time_rangestringNoday, week, month, year
start_datestringNoFilter by date (YYYY-MM-DD)
end_datestringNoFilter 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:

ParameterTypeRequiredDescription
urlsstring/arrayYesURL or array of URLs to extract
querystringNoUser intent for reranking content
chunks_per_sourceintegerNoMax chunks per source (1-5, default 3)
extract_depthstringNobasic or advanced (default: basic)
formatstringNomarkdown or text (default: markdown)
include_imagesbooleanNoInclude extracted images
timeoutfloatNoMax 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:

ParameterTypeRequiredDescription
urlstringYesRoot URL to begin mapping
instructionsstringNoNatural language guidance for crawler
max_depthintegerNoExploration depth (1-5, default 1)
max_breadthintegerNoLinks per page level (1-500, default 20)
limitintegerNoTotal links to process (default 50)
select_pathsarrayNoRegex patterns for URL inclusion
exclude_pathsarrayNoRegex patterns for URL exclusion
allow_externalbooleanNoInclude external links (default true)
timeoutfloatNoMax 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:

ParameterTypeRequiredDescription
urlstringYesRoot URL to begin crawl
instructionsstringNoNatural language guidance (2x cost)
chunks_per_sourceintegerNoMax snippets per source (1-5, default 3)
max_depthintegerNoExploration depth (1-5, default 1)
max_breadthintegerNoLinks per page level (1-500, default 20)
limitintegerNoTotal links to process (default 50)
select_pathsarrayNoRegex patterns for URL inclusion
exclude_pathsarrayNoRegex patterns for URL exclusion
allow_externalbooleanNoInclude external links (default true)
extract_depthstringNobasic or advanced (default: basic)
formatstringNomarkdown or text (default: markdown)
timeoutfloatNoMax 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:

ParameterTypeRequiredDescription
inputstringYesResearch task or question
modelstringNomini, pro, or auto (default: auto)
streambooleanNoStream results via SSE (default: false)
output_schemaobjectNoJSON Schema for structured output
citation_formatstringNonumbered, 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_answer is enabled
  • Map returns URLs only; Crawl returns URLs with extracted content
  • Using instructions parameter 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 jq or other commands, environment variables like $MATON_API_KEY may not expand correctly in some shell environments

Error Handling

StatusMeaning
400Missing Tavily connection or invalid request
401Invalid or missing Maton API key
429Rate limit exceeded
432Plan limit exceeded
433Pay-as-you-go limit exceeded
4xx/5xxPassthrough error from Tavily API

Resources

相关技能

通过托管密钥认证调用 Exa API,完成网页搜索、内容抓取、相似页查找与异步研究任务。

26 次安装

通过托管认证调用 Firecrawl API,提供网页抓取、整站爬取、URL 发现和带正文内容的搜索能力。

95 次安装1 星标

通过托管 OAuth 代理接入 Google Search Console,查询搜索分析数据、管理 sitemap 并查看站点表现。

265 次安装10 星标

通过托管认证接入 Apify API,运行爬虫并管理 actors、数据集、键值存储与定时任务。

26 次安装

通过 Brave Search API 完成网页、图片、新闻与视频搜索,认证由网关托管。

44 次安装

零依赖的原生 Node.js 脚本,调用 Tavily 搜索接口,凭证只从进程环境读取。

24 次安装