Skip to content

ChatGPT LLM 实时响应

接口说明

/v3/ai_optimization/chat_gpt/llm_responses/live 用于向指定的 ChatGPT 大模型发起实时请求,并返回结构化响应结果。

请求方式: POST接口地址: https://api.seermartech.cn/v3/ai_optimization/chat_gpt/llm_responses/live

该接口适合需要同步获取模型输出的场景,例如问答生成、市场信息摘要、带网页搜索的事实增强回答等。

计费说明

参考价需结合模型调用和返回的 cost / money_spent 字段综合判断。 扣费以响应头 X-SeerMarTech-Charge-CNY 为准。

从示例响应看,请求总成本为 0.0296424 USD,折合参考价约 ¥0.4743 / 次

使用限制

  • 所有 POST 数据使用 JSON(UTF-8 编码)
  • 请求体为 JSON 数组[{ ... }]
  • 每次 Live 请求只能 1 个任务
  • 频率限制:最高 2000 次 API 调用/分钟
  • 并发限制:当前 LLM Responses 每个平台每账号最多 30 个并发 Live 任务
  • 执行时长:单个 Live 任务当前最长可达 120 秒

请求参数

任务字段说明

字段名类型说明
user_promptstring。发送给模型的问题或任务描述。最多 500 个字符
model_namestring。模型名称。由基础模型名和版本组成;如果只传基础名称,系统会自动使用最新版本。例如传 gpt-4.1,可能自动解析为 gpt-4.1-2025-04-14。可通过 /v3/ai_optimization/chat_gpt/llm_responses/models 获取可用模型列表。
max_output_tokensinteger可选。模型输出的最大 token 数。推理模型(即 Models 接口中 reasoning=true 的模型)最小值为 1024;非推理模型最小值为 16;最大值 4096;默认值 2048。**注意:**如果设置了 web_search=true,或使用了推理模型,输出 token 可能该限制。
temperaturefloat可选。控制回答随机性。值越高,输出越发散;值越低,输出越聚焦。范围 0 - 2,默认 0.94。**注意:**推理模型不支持该参数。
top_pfloat可选。控制输出多样性,通过限制 token 候选范围实现。范围 0 - 1,默认 0.92注意:top_p 不能与 temperature 在同一请求中同时使用。
web_searchboolean可选。是否启用网页搜索。启用后,模型可访问并引用当前网页信息。默认 false。支持该能力的模型请参考 /v3/ai_optimization/chat_gpt/llm_responses/models
force_web_searchboolean可选。是否强制模型使用网页搜索。启用该参数时,同时设置 web_search=true。默认 false。**注意:**即使设置为 true,也不能保证响应中一定返回网页引用;推理模型不支持该参数。
web_search_country_iso_codestring可选。网页搜索所在国家/地区的 ISO 国家代码。启用该参数时,同时设置 web_search=true。模型会按指定国家进行网页搜索。注意:o3-minio1-proo1 不支持。
web_search_citystring可选。网页搜索所在城市名称。注意:o3-minio1-proo1 不支持。
system_messagestring可选。用于定义模型角色、语气或行为规则。最多 500 个字符
message_chainarray可选。历史对话链。数组中每个对象表示一轮历史消息, rolemessagerole 只能是 useraimessage 为消息,最长 500 个字符。最多支持 10 个消息对象
tagstring可选。用户自定义任务标识,最长 255 个字符。可用于请求与结果的业务对账,响应中的 data 对象会返回该值。

请求示例

cURL

bash
curl --location --request POST "https://api.seermartech.cn/v3/ai_optimization/chat_gpt/llm_responses/live" \
--header "Authorization: Bearer smt_live_YOUR_KEY" \
--header "Content-Type: application/json" \
--data-raw '[
 {
 "system_message": "请以商业会议汇报的语气进行回答",
 "message_chain": [
 {
 "role": "user",
 "message": "你好,最近法国休闲娱乐行业有哪些趋势?"
 },
 {
 "role": "ai",
 "message": "法国休闲娱乐行业正逐步恢复增长,是线下体验型消费。"
 }
 ],
 "max_output_tokens": 200,
 "model_name": "gpt-4.1-mini",
 "web_search": true,
 "web_search_country_iso_code": "FR",
 "web_search_city": "Paris",
 "user_prompt": "请说明当前法国游乐园行业的市场性和发展"
 }
]'

Python

python
import requests

url = "https://api.seermartech.cn/v3/ai_optimization/chat_gpt/llm_responses/live"
headers = {
 "Authorization": "Bearer smt_live_YOUR_KEY",
 "Content-Type": "application/json"
}

data = [
 {
 "system_message": "请以商业会议汇报的语气进行回答",
 "message_chain": [
 {
 "role": "user",
 "message": "你好,最近法国休闲娱乐行业有哪些趋势?"
 },
 {
 "role": "ai",
 "message": "法国休闲娱乐行业正逐步恢复增长,是线下体验型消费。"
 }
 ],
 "max_output_tokens": 200,
 "model_name": "gpt-4o",
 "web_search": True,
 "web_search_country_iso_code": "FR",
 "web_search_city": "Paris",
 "user_prompt": "请说明当前法国游乐园行业的市场性和发展"
 }
]

response = requests.post(url, headers=headers, json=data, timeout=180)
print(response.json)

TypeScript

typescript
import axios from "axios";

async function main {
 const response = await axios.post(
 "https://api.seermartech.cn/v3/ai_optimization/chat_gpt/llm_responses/live",
 [
 {
 system_message: "请以商业会议汇报的语气进行回答",
 message_chain: [
 {
 role: "user",
 message: "你好,最近法国休闲娱乐行业有哪些趋势?"
 },
 {
 role: "ai",
 message: "法国休闲娱乐行业正逐步恢复增长,是线下体验型消费。"
 }
 ],
 max_output_tokens: 200,
 model_name: "gpt-4.1-mini",
 web_search: true,
 web_search_country_iso_code: "FR",
 web_search_city: "Paris",
 user_prompt: "请说明当前法国游乐园行业的市场性和发展"
 }
 ],
 {
 headers: {
 Authorization: "Bearer smt_live_YOUR_KEY",
 "Content-Type": "application/json"
 },
 timeout: 180000
 }
 );

 console.log(response.data);
}

main.catch(console.error);

响应结构

接口返回 JSON 编码结果,顶层 tasks 数组。

顶层字段

字段名类型说明
versionstring当前 API 版本。
status_codeinteger通用状态码。完整错误码请参考 /v3/appendix/errors。建议在接时实现完整的异常处理机制。
status_messagestring通用状态描述。
timestring接口执行时间,单位秒。
costfloat本次请求总成本,单位 USD。
tasks_countintegertasks 数组中的任务数。
tasks_errorinteger返回错误的任务数。
tasksarray任务结果数组。

tasks[] 字段

字段名类型说明
idstring任务唯一标识,UUID 格式。
status_codeinteger任务状态码,范围通常为 10000-60000
status_messagestring任务状态说明。
timestring任务执行时间,单位秒。
costfloat任务成本,单位 USD。基础任务价格与 money_spent
result_countintegerresult 数组数量。
patharray当前请求的 URL 路径。
dataobject回显请求中提交的参数。
resultarray模型响应结果数组。

result[] 字段

字段名类型说明
model_namestring实使用的模型名称。
input_tokensintegertoken 总数。
output_tokensinteger输出 token 总数。
reasoning_tokensinteger推理 token 数量。
web_searchboolean是否使用了网页搜索。
money_spentfloatAI token 实消耗成本,单位 USD。为平台模型提供方收取的费用。
datetimestring结果返回时间,UTC 格式:yyyy-mm-dd hh-mm-ss +00:00
itemsarray结构化响应数组。
fan_out_queriesarray派生搜索词数组。基于主问题扩展出的检索词,用于提升回答完整性。

items[] 字段

reasoning 对象

字段名类型说明
typestring固定为 reasoning
sectionsarray推理链摘要分段。推理模型支持,且不保证一定返回

reasoning.sections[] 字段

字段名类型说明
typestring固定为 summary_text
textstring对模型思考过程的摘要文本。

message 对象

字段名类型说明
typestring固定为 message
sectionsarray模型最终回答分段。

message.sections[] 字段

字段名类型说明
typestring固定为 text
textstring模型生成的文本。
annotationsarray / null生成回答时使用的引用来源列表。如果 web_search 未启用,则通常为 null。即使启用了 web_search,如果未检索到可引用信息,也可能返回空数组。

annotations[] 字段

字段名类型说明
titlestring引用来源的域名或标题。
urlstring引用来源 URL。

响应示例

json
{
 "version": "0.1.20251208",
 "status_code": 20000,
 "status_message": "Ok.",
 "time": "4.7042 sec.",
 "cost": 0.0296424,
 "tasks_count": 1,
 "tasks_error": 0,
 "tasks": [
 {
 "id": "7c5f3b4a-4a1d-4b60-9d4f-1d9b3c8a1234",
 "status_code": 20000,
 "status_message": "Ok.",
 "time": "4.6121 sec.",
 "cost": 0.0296424,
 "result_count": 1,
 "path": [
 "v3",
 "ai_optimization",
 "chat_gpt",
 "llm_responses",
 "live"
 ],
 "data": {
 "api": "ai_optimization",
 "function": "llm_responses",
 "se": "chat_gpt",
 "system_message": "communicate as if we are in a business meeting",
 "message_chain": [
 {
 "role": "user",
 "message": "Hello, what's up?"
 },
 {
 "role": "ai",
 "message": "Hello! I’m doing well, thank you. How can I assist you today? Are there any specific topics or projects you’d like to discuss in our meeting?"
 }
 ],
 "temperature": 0.3,
 "top_p": 0.5,
 "web_search_country_iso_code": "FR",
 "web_search_city": "Paris",
 "model_name": "gpt-4.1-mini",
 "web_search": true,
 "user_prompt": "provide information on how relevant the amusement park business is in France now"
 },
 "result": [
 {
 "model_name": "gpt-4.1-mini",
 "input_tokens": 186,
 "output_tokens": 352,
 "reasoning_tokens": 0,
 "web_search": true,
 "money_spent": 0.0276424,
 "datetime": "2025-12-08 12:57:46 +00:00",
 "items": [
 {
 "type": "message",
 "sections": [
 {
 "type": "text",
 "text": "The amusement park business in France remains highly relevant and is showing signs of growth. The market is expected to reach USD 813.7 million by 2030, with a CAGR of 8.6% from 2025 to 2030.",
 "annotations": [
 {
 "title": "Grand View Research",
 "url": "https://www.grandviewresearch.com/horizon/outlook/amusement-parks-market/france"
 },
 {
 "title": "Statista",
 "url": "https://www.statista.com/outlook/amo/entertainment/amusement-parks/france"
 }
 ]
 }
 ]
 }
 ],
 "fan_out_queries": [
 "France amusement park market size",
 "France theme park industry growth",
 "Paris amusement park visitors"
 ]
 }
 ]
 }
 ]
}

状态码与错误处理

  • 顶层 status_code=20000 表示请求成功
  • tasks[].status_code=20000 表示单个任务执行成功
  • 若返回状态码,请根据 /v3/appendix/errors 进行处理
  • 建议重点处理以下异常场景:
  • 参数缺失或格式错误
  • temperaturetop_p 同时传
  • 推理模型使用了不支持的参数
  • web_search 参数组合不合法
  • 并发数或调用频率限
  • Live 任务时

接注意事项

  1. 每次只能提交一个任务,即使请求体是数组,也只能放 1 个对象。
  2. 不要同时传 temperaturetop_p,否则可能触发参数错误。
  3. 如果启用 force_web_search,同时设置 web_search=true
  4. 启用网页搜索后,模型会尽量检索并引用网页信息,但不保证一定返回引用来源
  5. 使用推理模型时,部分参数不可用,例如 temperatureforce_web_search
  6. message_chain 最多支持 10 轮历史消息,适合补上下文,但不建议塞冗长会话。
  7. 当启用网页搜索或使用推理模型时,输出 token 可能 max_output_tokens

实用场景

  • 生成市场快报:行业问题并启用网页搜索,快速生成带来源引用的行业概览,提升分析师做初步研究的效率。
  • 评估区域机会:结合 web_search_country_iso_codeweb_search_city,获取特定国家或城市视角下的市场信息,用于区域 SEO 与本地化商业判断。
  • 构建智能问答:通过 system_messagemessage_chain 维护回答风格与上下文,打造品牌化的运营、销售或客服问答能力。
  • 提取可追溯结论:利用 annotations 获取模型引用来源,便于审核、报告引用和事实校验,降低 AI 幻觉风险。
  • 比较模型效果与成本:通过 model_nameinput_tokensoutput_tokensmoney_spent 对不同模型的效果和花费进行横向评估,优化业务调用策略。

统一入口:官网 · LLM API · 控制台