请参阅 Search API Reference 和 Fetch API Reference 获取完整的请求与响应结构。
在请求头中发送你的 API key 和 JSON 内容类型:
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": "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 中的每一项包含:
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"])
请求字段:
{
"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 不可用、URL 被目标网站策略屏蔽、目标网站出错、内容类型不受支持,或页面没有可提取的 Markdown 内容。 408 读取请求体超时。 413 请求体过大。 429 超出 Search 或 Fetch 的 QPS 限制。 500 内部服务器错误。 504 下游请求超时。
Search 和 Fetch 均为只读操作。遇到 HTTP 408、429 或 5xx 错误时,请稍候重试。遇到 HTTP 402 时,请先为账户充值再重试。其余 4xx 错误在未修改请求的情况下请勿重试。
Search 和 Fetch 按成功请求计费,而非按 token 数量或返回结果数量计费: