主题
SERP AI 摘要
POST /v3/serp/ai_summary
接口说明
/v3/serp/ai_summary 用于基于已有的 SERP 任务结果生成 AI 摘要。 本接口会读取指定 SERP 任务对应的搜索结果,并根据你提供的 prompt 输出总结性回答。
调用本接口时,提供 task_id。该值可从此前 SERP API 创建任务后的响应中获取。
- 请求方式:
POST - 接口地址:
https://api.seermartech.cn/v3/serp/ai_summary
计费说明
每次请求参考价约 ¥0.1600 / 次。
扣费以响应头 X-SeerMarTech-Charge-CNY 为准。
请求格式
所有 POST 数据均应使用 JSON(UTF-8 编码),请求体格式为 JSON 数组:
json
[
{
"task_id": "07031739-1535-0139-0000-9d1e639a5b7d",
"prompt": "解释这个搜索结果页的核心信息",
"include_links": true,
"fetch_content": true
}
]请求参数
| 字段名 | 类型 | 说明 |
|---|---|---|
task_id | string | 任务标识,填。 SERP 任务的唯一标识,UUID 格式。该任务 ID 可在 30 天用于随时请求摘要结果。 |
prompt | string | AI 提示词,可选。用于补说明你希望模型如何总结或回答。可以是问题、说明、限定条件等任意文本。最大长度 2000 个字符。**注意:**提示词需要与原 SERP 任务中的。 |
support_extra | boolean | 是否启用额外 SERP 特征,可选。设为 true 时,AI 除了分析 organic 自然结果外,还会结合 answer_box、knowledge_graph、featured_snippet。默认值:true。 |
fetch_content | boolean | 是否抓取 SERP 落地页,可选。设为 true 时,接口会进一步抓取搜索结果页面,AI 在生成摘要时会参考这些页面正文。默认值:false。 |
include_links | boolean | 是否在摘要中附带来源链接,可选。设为 true 时,响应中的 summary 会生成摘要所参考的来源链接。默认值:false。 |
响应结构
接口返回 JSON 编码结果,顶层 tasks 数组。
顶层字段
| 字段名 | 类型 | 说明 |
|---|---|---|
version | string | 当前 API 版本。 |
status_code | integer | 通用状态码。完整错误码请参考 /v3/appendix/errors。建议在接时实现完善的异常处理机制。 |
status_message | string | 通用状态信息。完整说明请参考 /v3/appendix/errors。 |
time | string | 执行耗时,单位为秒。 |
cost | float | 本次请求总费用,单位为。 |
tasks_count | integer | tasks 数组中的任务数量。 |
tasks_error | integer | 返回错误的任务数量。 |
tasks | array | 任务结果数组。 |
tasks[] 字段
| 字段名 | 类型 | 说明 |
|---|---|---|
id | string | 本平台任务 ID,UUID 格式。 |
status_code | integer | 任务级状态码,范围通常为 10000-60000。完整错误码请参考 /v3/appendix/errors。 |
status_message | string | 任务级状态说明。 |
time | string | 任务执行耗时,单位为秒。 |
cost | float | 当前任务费用,单位为。 |
result_count | integer | result 数组中的结果数量。 |
path | array | 请求路径。 |
data | object | 与请求中提交的参数一致。 |
result | array | 结果数组。 |
result[] 字段
| 字段名 | 类型 | 说明 |
|---|---|---|
items_count | integer | 结果项数量。 |
items | array | 结果项数组。 |
summary | string | AI 生成的摘要。摘要会基于请求参数及 SERP 结果生成。 |
调用示例
cURL
bash
curl --location --request POST "https://api.seermartech.cn/v3/serp/ai_summary" \
--header "Authorization: Bearer smt_live_YOUR_KEY" \
--header "Content-Type: application/json" \
--data-raw '[
{
"task_id": "07031739-1535-0139-0000-9d1e639a5b7d",
"prompt": "解释该搜索结果页的主要信息",
"include_links": true,
"fetch_content": true
}
]'Python
python
import requests
url = "https://api.seermartech.cn/v3/serp/ai_summary"
headers = {
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json"
}
data = [
{
"task_id": "07031739-1535-0139-0000-9d1e639a5b7d",
"prompt": "解释该搜索结果页的主要信息",
"include_links": True,
"fetch_content": True
}
]
response = requests.post(url, headers=headers, json=data)
print(response.json)TypeScript
typescript
import axios from "axios";
const postData = [
{
task_id: "07031739-1535-0139-0000-9d1e639a5b7d",
prompt: "解释该搜索结果页的主要信息",
include_links: true,
fetch_content: true
}
];
axios({
method: "post",
url: "https://api.seermartech.cn/v3/serp/ai_summary",
headers: {
Authorization: "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json"
},
data: postData
})
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.error(error);
});响应示例
json
{
"version": "0.1.20221214",
"status_code": 20000,
"status_message": "Ok.",
"time": "20.6765 sec.",
"cost": 0.01,
"tasks_count": 1,
"tasks_error": 0,
"tasks": [
{
"data": {
"api": "serp",
"function": "ai_summary",
"task_id": "07031739-1535-0139-0000-9d1e639a5b7d",
"prompt": "解释该搜索结果页的主要信息",
"include_links": true,
"fetch_content": true
},
"result": [
{
"items_count": 1,
"items": [
{
"summary": "这里返回基于指定 SERP 结果生成的 AI 摘要。"
}
]
}
]
}
]
}状态码与错误处理
- 顶层
status_code表示整次请求的执行状态。 tasks[].status_code表示单个任务的处理状态。- 建议同时检查:
- HTTP 状态码
- 顶层
status_code - 任务级
tasks[].status_code
常见成功状态:
| 状态码 | 含义 |
|---|---|
20000 | 请求成功。 |
更多错误码与说明请参考 /v3/appendix/errors。
使用说明与注意事项
- 本接口依赖已有的 SERP 任务结果,不能单独脱离
task_id使用。 prompt应与原始搜索或 SERP 主题保持,否则摘要质量可能下降。- 如果需要让 AI 结合落地页正文而是搜索结果摘要,建议启用
fetch_content=true。 - 如果你的业务需要在前端展示引用来源,建议启用
include_links=true。 - 若希望 AI 同时考虑精选摘要、知识图谱、答案框等模块,保持
support_extra=true即可。
实用场景
- 总结搜索意图:针对指定的 SERP 结果自动生成摘要,快速判断用户点与搜索意图分布。
- 提炼竞品主题:结合
fetch_content抓取排名页面正文,归纳竞品页面核心话题与信息结构,策划。 - 生成 SEO 简报:把复杂的搜索结果页压缩为可读摘要,便于运营、编辑和客户快速理解某的 SERP 格局。
- 输出可追溯结论:启用
include_links后返回来源链接,便于审 AI 结论依据,提升报告可信度。 - 识别 SERP 特征影响:结合
support_extra分析精选摘要、知识图谱、答案框等额外模块,帮助评估自然结果之外的机会。