DeepSeek 上线 Search 和 Fetch API,每千次成功请求 $0.75
DeepSeek search and fetch – $0.75 per 1000 successful requests
DeepSeek 上线 Search API 和 Fetch API,为智能体和 RAG 应用提供实时网页内容获取能力,两接口均按成功请求计费,每 1000 次 $0.75,账户级 QPS 上限各为 5。
详细给出 Search 和 Fetch API 的接口字段、查询操作符、错误码与定价,可直接用于搭建智能体或 RAG 检索管道。
Search API 和 Fetch API 为智能体和 RAG 应用提供对实时网络内容的访问:
- Search API 根据查询查找网页并返回结构化结果。它由 DeepSeek 自研的搜索引擎驱动。
- Fetch API 获取单个网页并将其内容以 Markdown 形式返回。
两者都是原始的 JSON API。它们使用与 DeepSeek API 相同的 bearer 身份验证。
基础 URL 为 https://api.deepseek.com:
| API | 端点 |
|---|---|
| Search | POST https://api.deepseek.com/v1/tools/search |
| Fetch | POST https://api.deepseek.com/v1/tools/fetch |
请参阅 Search API 参考 和 Fetch API 参考 以获取完整的请求和响应 schema。
身份验证
在请求头中发送你的 API 密钥和 JSON 内容类型:
| Header | 必填 | 值 |
|---|---|---|
Authorization | 是 | Bearer <DeepSeek API Key> |
Content-Type | 是 | application/json |
Search API
请求
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
}'
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 时始终为空字符串。 |
请求体中未知的字段将被忽略。
查询运算符
查询会以完整的搜索语法转发。下面的示例将运算符与搜索词组合;你可以在一个查询中组合多个运算符。
| 运算符 | 示例 | 说明 |
|---|---|---|
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 个字符,用于在界面中显示。 |
summary | string | 与查询相关的长摘要,通常为 600 到 800 个字符,供模型读取。 |
content | string | 页面内容,当 need_content 为 false 或内容不可用时为空。 |
site_name | string or null | 站点名称,不可用时为 null。 |
site_icon | string or null | 站点图标的 URL,不可用时为 null。 |
date | string or null | UTC 格式的发布时间,按 RFC 3339 格式化,未知时为 null。 |
authority | integer | 页面的权威等级,0 到 4(-1 表示未知),值 3 及以上表示高权威来源。 |
Fetch API
请求
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"
}'
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 密钥缺失或无效。 |
| 402 | 账户余额不足。 |
| 403 | Fetch 请求被安全策略拒绝。 |
| 404 | Fetch 无法获取可用的页面内容,例如 URL 不可用、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 密钥无关,并且与模型并发限制相互独立。超出账户级 QPS 上限的请求将收到 HTTP 429。除了账户级限制外,Fetch 还受单域名 QPS 限制,超出该限制的请求同样会收到 HTTP 429。
来源:Hacker News · api-docs.deepseek.com