主题
按任务 ID 获取 Gemini LLM 响应结果
本接口使用 GET 方法,通过以下路径获取指定任务的 Gemini LLM 结构化响应结果:
GET https://api.seermartech.cn/v3/ai_optimization/gemini/llm_responses/task_get/$id
任务需要通过任务创建接口提交。使用标准方法提交的任务最长可能需要 72 小时完成。如果该时间仍未完成,任务将标记为失败,并退还约 ¥0.0720 / 次的预扣费用。若账户余额为负,即使任务已成功完成,也无法获取结果。
计费说明
- 任务结果提交后 30 天可重复查询。
- 费用在创建任务时产生,调用本查询接口不会重复扣费。
- 标准方法任务的预扣费用参考价约为 ¥0.0720 / 次。
- AI 模型 Token 费用可能计任务总费用。
- 实扣费以响应头
X-SeerMarTech-Charge-CNY为准。
请求参数
接口通过 URL 路径接收任务 ID,不需要请求体。
| 参数 | 类型 | 填 | 说明 |
|---|---|---|---|
id | string | 是 | 任务唯一标识,采用 UUID 格式。任务创建成功后返回,可在 30 天用于查询结果。 |
请求示例
cURL
bash
task_id="02031608-0696-0110-0000-a81d0414edbe"
curl --location --request GET \
"https://api.seermartech.cn/v3/ai_optimization/gemini/llm_responses/task_get/${task_id}" \
--header "Authorization: Bearer smt_live_YOUR_KEY" \
--header "Content-Type: application/json"PHP
php
<?php
/**
* Method: GET
* Endpoint:
* https://api.seermartech.cn/v3/ai_optimization/gemini/llm_responses/task_get/$id
*/
$taskId = '07211938-0696-0613-0000-674a0f948d6b';
$ch = curl_init(
"https://api.seermartech.cn/v3/ai_optimization/gemini/llm_responses/task_get/"
. $taskId
);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer smt_live_YOUR_KEY',
'Content-Type: application/json',
],
]);
$response = curl_exec($ch);
if ($response === false) {
throw new Exception(curl_error($ch));
}
curl_close($ch);
$result = json_decode($response, true);
print_r($result);TypeScript
typescript
import axios from "axios";
const taskId = "02231934-2604-0066-2000-570459f04879";
axios({
method: "get",
url:
"https://api.seermartech.cn/v3/ai_optimization/gemini/llm_responses/task_get/"
+ taskId,
headers: {
Authorization: "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
},
})
.then((response) => {
// 获取任务结果
console.log(response.data);
})
.catch((error) => {
console.error("请求失败:", error.response?.data || error.message);
});Python
python
import requests
task_id = "07211938-0696-0613-0000-674a0f948d6b"
url = (
"https://api.seermartech.cn/v3/ai_optimization/gemini/"
f"llm_responses/task_get/{task_id}"
)
headers = {
"Authorization": "Bearer smt_live_YOUR_KEY",
"Content-Type": "application/json",
}
try:
response = requests.get(url, headers=headers)
response.raise_for_status()
result = response.json()
print(result)
except requests.RequestException as error:
print(f"请求失败:{error}")C#
csharp
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
public class GeminiLlmResponses
{
public static async Task GetTaskResult()
{
using var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue(
"Bearer",
"smt_live_YOUR_KEY"
);
string taskId = "07211938-0696-0613-0000-674a0f948d6b";
string url =
"https://api.seermartech.cn/v3/ai_optimization/gemini/"
+ $"llm_responses/task_get/{taskId}";
using var response = await httpClient.GetAsync(url);
string result = await response.Content.ReadAsStringAsync();
if ((int)response.StatusCode == 200)
{
Console.WriteLine(result);
}
else
{
Console.WriteLine($"请求失败:{result}");
}
}
}响应结构
接口返回 JSON 数据,顶层 tasks 数组。
顶层字段
| 字段 | 类型 | 说明 |
|---|---|---|
version | string | 当前 API 版本。 |
status_code | integer | 通用响应状态码。成功通常为 20000。完整错误码请参考错误码文档。 |
status_message | string | 通用状态说明。 |
time | string | 接口执行耗时,单位为秒。 |
cost | float | 平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。 |
tasks_count | integer | tasks 数组中的任务数量。 |
tasks_error | integer | tasks 数组中返回错误的任务数量。 |
tasks | array | 任务结果数组。 |
tasks 任务字段
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 任务唯一标识,UUID 格式。 |
status_code | integer | 当前任务的状态码,通常为 10000 至 60000。 |
status_message | string | 当前任务的状态说明。 |
time | string | 任务执行耗时,单位为秒。 |
cost | float | 平台原始 USD 成本兼容字段;人民币实扣以 X-SeerMarTech-Charge-CNY 为准。 |
result_count | integer | result 数组中的数量。 |
path | array | 请求路径信息。 |
data | object | 创建任务时提交的参数。 |
result | array | Gemini LLM 响应结果数组。 |
result 结果字段
| 字段 | 类型 | 说明 |
|---|---|---|
model_name | string | 实使用的 AI 模型名称。 |
input_tokens | integer | Token 数量,即处理的 Token 总数。 |
output_tokens | integer | 输出 Token 数量,即 AI 响应生成的 Token 总数。 |
reasoning_tokens | integer | 推理 Token 数量,即生成推理时使用的 Token 总数。 |
web_search | boolean | 是否使用了联网搜索。 |
money_spent | float | AI Token 产生的费用,扣费以响应头 X-SeerMarTech-Charge-CNY 为准。 |
datetime | string | 获取结果的 UTC 时间,格式为 yyyy-mm-dd hh-mm-ss +00:00。 |
items | array | 结构化 AI 响应。 |
时间示例:
text
2019-11-15 12:57:46 +00:00items 响应
items 是响应数组,可推理、正文消息和引用信息。
reasoning
推理模型可能返回 reasoning素,但该并非所有模型都会提供。
| 字段 | 类型 | 说明 |
|---|---|---|
type | string | 固定为 reasoning。 |
sections | array | 推理链分段数组。 |
reasoning.sections
| 字段 | 类型 | 说明 |
|---|---|---|
type | string | 分段类型,通常为 summary_text。 |
text | string | 对模型推理过程的摘要文本。 |
message
message 表示 AI 生成的消息。
| 字段 | 类型 | 说明 |
|---|---|---|
type | string | 固定为 message。 |
sections | array | 消息分段数组。 |
message.sections
| 字段 | 类型 | 说明 |
|---|---|---|
type | string | 类型,通常为 text。 |
text | string | AI 生成的文本。 |
annotations | array | null | 生成响应时使用的引用来源。当请求未将 web_search 设置为 true 时,该字段为 null。即使启用了联网搜索,如果模型未找到信息,该字段也可能为空。 |
annotations
| 字段 | 类型 | 说明 |
|---|---|---|
title | string | 引用来源的域名或标题。 |
url | string | 引用来源的跳转地址,可能指向原始来源的重定向地址。 |
start_index | integer | 引用文本在响应中的起始索引。 |
end_index | integer | 引用文本在响应中的结束索引。 |
text | string | 被标注的引用文本。 |
fan_out_queries
| 字段 | 类型 | 说明 |
|---|---|---|
fan_out_queries | array | 扩展搜索查询数组。模型会基于主查询生成搜索词,以获得更的回答。 |
响应示例
json
{
"version": "0.1.20260717",
"status_code": 20000,
"status_message": "Ok.",
"time": "6.9528 sec.",
"cost": 0.0378958,
"tasks_count": 1,
"tasks_error": 0,
"tasks": [
{
"id": "02031608-0696-0110-0000-a81d0414edbe",
"status_code": 20000,
"status_message": "Ok.",
"time": "6.9528 sec.",
"cost": 0.0378958,
"result_count": 1,
"path": [
"v3",
"ai_optimization",
"gemini",
"llm_responses",
"task_get"
],
"data": {
"api": "ai_optimization",
"function": "llm_responses",
"se": "gemini",
"system_message": "communicate as if we are in a business meeting",
"message_chain": [],
"temperature": 0.3,
"model_name": "gemini-2.5-flash",
"top_p": 0.5,
"web_search": true,
"user_prompt": "provide information on how relevant the amusement park business is in France now"
},
"result": [
{
"model_name": "gemini-2.5-flash",
"input_tokens": 128,
"output_tokens": 256,
"reasoning_tokens": 64,
"web_search": true,
"money_spent": 0.0123,
"datetime": "2026-07-17 12:57:46 +00:00",
"items": [
{
"type": "message",
"sections": [
{
"type": "text",
"text": "法国主题园市场目前仍备较强的商业性。",
"annotations": []
}
]
}
],
"fan_out_queries": [
"法国主题园市场规模",
"法国游乐园行业趋势"
]
}
]
}
]
}状态码与异常处理
- 当顶层
status_code或任务级status_code为20000时,表示请求或任务处理成功。 - 应同时检查
tasks_error、任务级status_code和status_message。 - 不建议根据 HTTP 状态码判断任务是否成功,应结合响应 JSON 中的业务状态码处理异常。
- 完整响应码和错误信息请参考错误码文档。
- 如果账户余额为负,即使任务状态已完成,也可能无法返回任务结果。
实用场景
- 评估市场主题:调用 Gemini 分析目标国家或地区的行业趋势,判断新市场和布局机会。
- 生成带来源的竞品洞察:启用联网搜索获取行业资料和引用链接,提升竞品研究报告的可追溯性。
- 扩展用户搜索意图:利用
fan_out_queries获取搜索查询,为聚类和选题提供补数据。 - 统计 AI成本:结合
input_tokens、output_tokens和money_spent,核算批量生成与 SEO 研究任务的成本。 - 构建异步分析流程:提交长耗时 LLM 任务,再通过任务 ID 定期查询结果,同步请求阻塞 SEO 数据处理流程。