深度求索 API(DeepSeek API)的搜索 API(Search API)与获取 API(Fetch API)为智能体和 RAG 应用提供实时网页内容访问:搜索 API 按查询找到网页并返回结构化结果,由深度求索自研搜索引擎提供支持;获取 API 获取单个网页并以 Markdown 返回内容。二者均为原始 JSON API,沿用与深度求索 API 相同的 Bearer 鉴权。基础地址是 https://api.deepseek.com,搜索 API 端点为 POST https://api.deepseek.com/v1/tools/search,获取 API 端点为 POST https://api.deepseek.com/v1/tools/fetch。
正文
Search API 和 Fetch API 让智能体和 RAG 应用能够获取实时网页内容:
- Search API 根据查询查找网页并返回结构化结果,由 DeepSeek 自研搜索引擎提供支持。
- Fetch API 获取单个网页并以 Markdown 形式返回其内容。
两者都是原始 JSON API,使用与 DeepSeek API 相同的 bearer 认证。
基础 URL 是 https://api.deepseek.com:
| API | Endpoint |
| --- | --- |
| Search | POST https://api.deepseek.com/v1/tools/search |
| Fetch | POST https://api.deepseek.com/v1/tools/fetch |
完整的请求和响应模式见 Search API Reference 和 Fetch API Reference。
身份验证
在请求头中发送 API key 和 JSON 内容类型:
| 请求头 | 是否必填 | 值 |
| --- | --- | --- |
| Authorization | 是 | Bearer <DeepSeek API Key> |
| Content-Type | 是 | application/json |
Search API
请求
请求示例(curl):
curl https://api.deepseek.com/v1/tools/search \
-H "Authorization: Bearer <DeepSeek API Key>" \
-H "Content-Type: application/json" \
-d '{
"query": "DeepSeek V4 release",
"count": 5,
"need_content": true
}'
Python 示例:
import requests
response = requests.post(
"https://api.deepseek.com/v1/tools/search",
headers={
"Authorization": "Bearer <DeepSeek API Key>",
},
json={
"query": "DeepSeek V4 release",
"count": 5,
"need_content": True,
},
)
response.raise_for_status()
for result in response.json()["results"]:
print(result["title"], result["url"])
print(result["summary"])
请求字段:
| 字段 | 类型 | 是否必填 | 默认值 | 说明 |
| --- | --- | --- | --- | --- |
| query | string | 是 | - | 搜索查询必须包含 1 到 128 个 Unicode 字符,不能全为空白,并支持下列查询运算符。 |
| count | integer | 否 | 10 | 返回结果数量,1 到 50 之间。 |
| ori_question | string | 否 | - | 触发搜索的用户原始问题,1 到 128 个字符,用于改进查询理解;null 视为未提供。 |
| localization | string | 否 | "" | 用于本地化搜索结果的可选 IP 地址。 |
| need_content | boolean | 否 | false | 是否在 content 中返回页面内容;为 false 时 content 始终为空字符串。 |
请求体中未知字段会被忽略。
查询运算符
查询会连同原始搜索语法一起转发。下面的示例把运算符与搜索词组合;你可以在一个查询中组合多个运算符。
| 运算符 | 示例 | 说明 |
| --- | --- | --- |
| site: | DeepSeek site:github.com | 将结果限制在指定站点;要指定多个站点,用空格分隔 site: 子句并用 OR 连接,例如 DeepSeek site:github.com OR site:huggingface.co。 |
| -site: | DeepSeek -site:example.com | 排除指定站点,多个站点用空格分隔。 |
| - | DeepSeek -advertisement | 排除包含该词的页面,多个词用空格分隔。 |
| -"..." | DeepSeek -"release notes" | 排除包含精确短语的页面,短语可含空格,多个短语用空格分隔。 |
| "..." | DeepSeek "exact phrase" | 匹配精确短语,多个短语用空格分隔。 |
| lang: | DeepSeek lang:zh,en | 将结果限制在指定语言代码,多个代码用逗号分隔,例如 lang:zh,en。 |
| after: | DeepSeek after:2025 或 DeepSeek after:2025-01-01 | 限制结果为指定日期之后发布的页面。 |
| before: | DeepSeek before:2026 或 DeepSeek before:2026-06-01 | 限制结果为指定日期之前发布的页面。 |
例如:
{
"query": "DeepSeek site:github.com OR site:huggingface.co lang:en after:2025",
"count": 10
}
响应
成功请求返回 HTTP 200 和 results 数组。正常搜索若无匹配结果则返回空数组。
{
"results": [
{
"rerank_score": 2.4,
"title": "DeepSeek V4 model released",
"url": "https://example.com/deepseek-v4",
"snippet": "DeepSeek V4 is now available, with tool calling and long-context support.",
"summary": "DeepSeek has released the V4 model. The release adds improved tool calling and long-context support for agent workflows.",
"content": "DeepSeek V4 is now generally available...",
"site_name": "Example News",
"site_icon": "https://example.com/favicon.ico",
"date": "2026-06-01T00:00:00+00:00",
"authority": 3
}
]
}
results 中每项包含:
| 字段 | 类型 | 说明 |
| --- | --- | --- |
| rerank_score | number | 0 到 3 的相关性评分,综合相关性、权威性和新鲜度等信号,1.5 分及以上视为高质量结果。 |
| title | string | 结果标题。 |
| url | string | 结果的 URL。 |
| snippet | string | 与查询相关的简短摘要,通常 100 到 200 个字符,适合在 UI 中展示。 |
| summary | string | 与查询相关的长摘要,通常 600 到 800 个字符,适合供模型阅读。 |
| content | string | 页面内容;当 need_content 为 false 或内容不可用时为空。 |
| site_name | string 或 null | 站点名称,不可用时为 null。 |
| site_icon | string 或 null | 站点图标 URL,不可用时为 null。 |
| date | string 或 null | 发布时间(UTC),格式为 RFC 3339,未知时为 null。 |
| authority | integer | 页面权威等级,0 到 4(-1 表示未知),3 及以上表示高度权威的来源。 |
Fetch API
请求
请求示例(curl):
curl https://api.deepseek.com/v1/tools/fetch \
-H "Authorization: Bearer <DeepSeek API Key>" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com/article"
}'
Python 示例:
import requests
response = requests.post(
"https://api.deepseek.com/v1/tools/fetch",
headers={
"Authorization": "Bearer <DeepSeek API Key>",
},
json={"url": "https://example.com/article"},
)
response.raise_for_status()
page = response.json()
print(page["title"])
print(page["content"])
请求字段:
| 字段 | 类型 | 是否必填 | 说明 |
| --- | --- | --- | --- |
| url | string | 是 | 要抓取的页面 URL,长度最多 8192 个字符,必须是带主机的 HTTP 或 HTTPS URL,且不能包含用户名或密码。 |
响应
{
"title": "Example article",
"content": "# Example article\n\nArticle content."
}
| 字段 | 类型 | 说明 |
| --- | --- | --- |
| title | string | 页面标题,标题不可用时为空。 |
| content | string | 抓取到的页面内容,Markdown 文本。 |
抓取受目标站点可用性和访问策略影响。
错误
错误采用兼容 OpenAI 的错误格式,param 字段始终为 null。
{
"error": {
"message": "'count' must be between 1 and 50",
"type": "invalid_request_error",
"param": null,
"code": "invalid_request_error"
}
}
| HTTP 状态码 | 说明 | | --- | --- | | 400 | 请求头或请求体无效,包括 JSON 格式错误或字段值无效。 | | 401 | API key 缺失或无效。 | | 402 | 账户余额不足。 | | 403 | Fetch 请求被安全策略拒绝。 | | 404 | Fetch 无法获取可用页面内容,例如 URL 不可用、被站点策略阻止、目标站点出错、内容类型不受支持或页面无可提取的 Markdown 内容。 | | 408 | 读取请求体超时。 | | 413 | 请求体过大。 | | 429 | 超出 Search 或 Fetch 的 QPS 限制。 | | 500 | 内部服务器错误。 | | 504 | 下游请求超时。 |
Search 和 Fetch 是只读接口。对于 HTTP 408、429 或 5xx 错误,应等待后重试。对于 HTTP 402,应先充值再重试。其他 4xx 错误在不修改请求的情况下不要重试。
计费
Search 和 Fetch 按成功请求计费,不按 token 或返回结果数量计费:
| API | 单位 | 价格 | | --- | --- | --- | | Search | 每 1,000 次成功请求 | $0.75 | | Fetch | 每 1,000 次成功请求 | $0.75 |
请求只有在返回 HTTP 200 并产生结果时才计费(Search 必须返回非空 results 数组,Fetch 必须返回页面内容)。失败请求、空搜索结果和超时不计费。count 只控制返回结果数量,不影响每次请求的价格。
注意:当你通过 DeepSeek Harness、Claude Code 或 Codex 使用 DeepSeek API 时,服务端工具调用已经会访问 Search 和 Fetch API。这些调用目前免费;按请求计费将从北京时间 2026 年 11 月 1 日 00:00 开始。
速率限制
对于每个账户,Search 和 Fetch 独立限流,访问其中一个不会消耗另一个的配额:
| API | QPS 限制 | | --- | --- | | Search | 5 | | Fetch | 5 |
QPS(每秒请求数)限制按账户级别计算,与所用 API key 无关,且独立于模型并发限制。超过账户级别 QPS 限制的请求会收到 HTTP 429。除账户级别限制外,Fetch 还受每域名 QPS 限制,超过该限制的请求也会收到 HTTP 429。
评论
你好,我无法给到相关内容。