跳转到主要内容
POST
https://api.aisa.one/apis/v1
/
dataforseo
/
ai_optimization
/
chat_gpt
/
llm_responses
/
live
实时 ChatGPT LLM 响应
curl --request POST \
  --url https://api.aisa.one/apis/v1/dataforseo/ai_optimization/chat_gpt/llm_responses/live \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "user_prompt": "<string>",
  "model_name": "<string>",
  "max_output_tokens": 123,
  "temperature": 123,
  "top_p": 123,
  "web_search": true,
  "force_web_search": true,
  "web_search_country_iso_code": "<string>",
  "web_search_city": "<string>",
  "system_message": "<string>",
  "message_chain": [
    "<string>"
  ],
  "tag": "<string>"
}
'
import requests

url = "https://api.aisa.one/apis/v1/dataforseo/ai_optimization/chat_gpt/llm_responses/live"

payload = {
"user_prompt": "<string>",
"model_name": "<string>",
"max_output_tokens": 123,
"temperature": 123,
"top_p": 123,
"web_search": True,
"force_web_search": True,
"web_search_country_iso_code": "<string>",
"web_search_city": "<string>",
"system_message": "<string>",
"message_chain": ["<string>"],
"tag": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
user_prompt: '<string>',
model_name: '<string>',
max_output_tokens: 123,
temperature: 123,
top_p: 123,
web_search: true,
force_web_search: true,
web_search_country_iso_code: '<string>',
web_search_city: '<string>',
system_message: '<string>',
message_chain: ['<string>'],
tag: '<string>'
})
};

fetch('https://api.aisa.one/apis/v1/dataforseo/ai_optimization/chat_gpt/llm_responses/live', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.aisa.one/apis/v1/dataforseo/ai_optimization/chat_gpt/llm_responses/live",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'user_prompt' => '<string>',
'model_name' => '<string>',
'max_output_tokens' => 123,
'temperature' => 123,
'top_p' => 123,
'web_search' => true,
'force_web_search' => true,
'web_search_country_iso_code' => '<string>',
'web_search_city' => '<string>',
'system_message' => '<string>',
'message_chain' => [
'<string>'
],
'tag' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.aisa.one/apis/v1/dataforseo/ai_optimization/chat_gpt/llm_responses/live"

payload := strings.NewReader("{\n \"user_prompt\": \"<string>\",\n \"model_name\": \"<string>\",\n \"max_output_tokens\": 123,\n \"temperature\": 123,\n \"top_p\": 123,\n \"web_search\": true,\n \"force_web_search\": true,\n \"web_search_country_iso_code\": \"<string>\",\n \"web_search_city\": \"<string>\",\n \"system_message\": \"<string>\",\n \"message_chain\": [\n \"<string>\"\n ],\n \"tag\": \"<string>\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.aisa.one/apis/v1/dataforseo/ai_optimization/chat_gpt/llm_responses/live")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"user_prompt\": \"<string>\",\n \"model_name\": \"<string>\",\n \"max_output_tokens\": 123,\n \"temperature\": 123,\n \"top_p\": 123,\n \"web_search\": true,\n \"force_web_search\": true,\n \"web_search_country_iso_code\": \"<string>\",\n \"web_search_city\": \"<string>\",\n \"system_message\": \"<string>\",\n \"message_chain\": [\n \"<string>\"\n ],\n \"tag\": \"<string>\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.aisa.one/apis/v1/dataforseo/ai_optimization/chat_gpt/llm_responses/live")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"user_prompt\": \"<string>\",\n \"model_name\": \"<string>\",\n \"max_output_tokens\": 123,\n \"temperature\": 123,\n \"top_p\": 123,\n \"web_search\": true,\n \"force_web_search\": true,\n \"web_search_country_iso_code\": \"<string>\",\n \"web_search_city\": \"<string>\",\n \"system_message\": \"<string>\",\n \"message_chain\": [\n \"<string>\"\n ],\n \"tag\": \"<string>\"\n}"

response = http.request(request)
puts response.read_body
{
  "version": "<string>",
  "status_code": 123,
  "status_message": "<string>",
  "time": "<string>",
  "cost": 123,
  "tasks_count": 123,
  "tasks_error": 123,
  "tasks": [
    "<string>"
  ],
  "tasks.id": "<string>",
  "tasks.status_code": 123,
  "tasks.status_message": "<string>",
  "tasks.time": "<string>",
  "tasks.cost": 123,
  "tasks.result_count": 123,
  "tasks.path": [
    "<string>"
  ],
  "tasks.data": {},
  "tasks.result": [
    "<string>"
  ],
  "tasks.result.model_name": "<string>",
  "tasks.result.input_tokens": 123,
  "tasks.result.output_tokens": 123,
  "tasks.result.reasoning_tokens": 123,
  "tasks.result.web_search": true,
  "tasks.result.money_spent": 123,
  "tasks.result.datetime": "<string>",
  "tasks.result.items": [
    "<string>"
  ],
  "tasks.result.items.reasoning": {},
  "tasks.result.items.reasoning.type": "<string>",
  "tasks.result.items.reasoning.sections": [
    "<string>"
  ],
  "tasks.result.items.reasoning.sections.type": "<string>",
  "tasks.result.items.reasoning.sections.text": "<string>",
  "tasks.result.items.message": {},
  "tasks.result.items.message.type": "<string>",
  "tasks.result.items.message.sections": [
    "<string>"
  ],
  "tasks.result.items.message.sections.type": "<string>",
  "tasks.result.items.message.sections.text": "<string>",
  "tasks.result.items.message.sections.annotations": [
    "<string>"
  ],
  "tasks.result.items.message.sections.annotations.title": "<string>",
  "tasks.result.items.message.sections.annotations.url": "<string>",
  "tasks.result.fan_out_queries": [
    "<string>"
  ]
}

授权

Authorization
string
header
必填

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

请求体

application/json
user_prompt
string
必填

AI 模型的提示词,必填字段;您希望发送给 AI 模型的问题或任务;可在 user_prompt 字段中指定最多 500 个字符

model_name
string
必填

AI 模型名称,必填字段;model_name 由实际模型名称和版本名称组成;如果指定基础模型名称,默认使用其最新版本;例如,如果指定 gpt-4.1,将自动把 gpt-4.1-2025-04-14 设置为 model_name;你可以单独请求 https://api.dataforseo.com/v3/ai_optimization/chat_gpt/llm_responses/models,以获取可用 LLM 模型的列表

max_output_tokens
integer

AI 响应中的最大词元数,可选字段。推理模型的最小值(例如,Models 端点中的 reasoning 为 true):1024;非推理模型的最小值:16;最大值:4096;默认值:2048。注意:如果 web_search 设置为 true,或请求中指定了推理模型,则输出词元数可能超过指定的 max_output_tokens 限制。

temperature
number

AI 响应的随机性,可选字段。值越高,输出越多样;值越低,输出越聚焦。最小值:0,最大值:2,默认值:0.94。注意:推理模型不支持此字段。

top_p
number

启用网页搜索;可选字段;启用后,AI 模型可以访问并引用当前网页信息;默认值:false;注意:有关支持 web_search 的模型列表,请参阅 Models 端点;

强制 AI 智能体使用网页搜索,可选字段。要启用此参数,还必须启用 web_search;启用后,将强制 AI 模型访问并引用当前网页信息;默认值:false;注意:即使此参数设置为 true,也不能保证响应会引用网页来源。注意 #2:推理模型不支持此参数。

web_search_country_iso_code
string

位置的 ISO 国家/地区代码;可选字段;如果指定了 web_search_city,则此字段为必填;要启用此参数,还必须启用 web_search;启用后,AI 模型将从您指定的国家/地区搜索网络;注意:o3-mini、o1-pro、o1 模型不支持此参数

web_search_city
string

位置的城市名称;可选字段。注意:需指定 web_search_country_iso_code 才能使用此参数。注意 2:o3-mini、o1-pro、o1 模型不支持此参数。

system_message
string

AI 行为指令 可选字段 定义 AI 的角色、语气或特定行为 您可以在 system_message 字段中指定最多 500 个字符

message_chain
string[]

对话历史,可选字段。表示之前对话轮次的消息对象数组;每个对象必须包含 role 和 message 参数:role 字符串,值为 user 或 ai 角色;message 字符串,包含消息内容(最多 500 个字符);数组中最多可以指定 10 个消息对象;示例:"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?"}]

tag
string

用户定义的任务标识符。可选字段。字符数限制为 255。您可以使用此参数标识任务并将其与结果匹配;您将在响应的 data 对象中找到指定的 tag 值

响应

成功响应

version
string

API 的当前版本

status_code
integer

通用状态码;您可以在此处查看完整的响应码列表。注意:我们强烈建议设计必要的系统来处理相关异常或错误情况

status_message
string

常规信息消息;可在此处查看常规信息消息的完整列表

time
string

执行时间(秒)

cost
number

任务总成本(美元)

tasks_count
integer

tasks 数组中的任务数量

tasks_error
integer

返回错误的 tasks 数组中的任务数量

tasks
string[]

任务数组

tasks.id
string

任务标识符,系统中采用 UUID 格式的唯一任务标识符

tasks.status_code
integer

DataForSEO 生成的任务状态码;范围为:10000-60000;完整响应代码列表可在此处查看

tasks.status_message
string

任务的信息性消息,你可以在此处查看通用信息性消息的完整列表

tasks.time
string

执行时间(秒)

tasks.cost
number

任务成本(美元),包括基础任务价格与 money_spent 值之和

tasks.result_count
integer

结果数组中的元素数量

tasks.path
string[]

URL 路径

tasks.data
object

包含您在 POST 请求中指定的相同参数

tasks.result
string[]

结果数组

tasks.result.model_name
string

所用 AI 模型的名称

tasks.result.input_tokens
integer

输入中的词元数量,即已处理的词元总数

tasks.result.output_tokens
integer

输出中的词元数量,即 AI 响应生成的词元总数

tasks.result.reasoning_tokens
integer

推理词元数 用于生成推理内容的词元总数

表示是否使用了网络搜索

tasks.result.money_spent
number

AI 词元成本(美元),即第三方 AI 模型提供商根据其定价收取的费用

tasks.result.datetime
string

以 UTC 格式接收结果的日期和时间:“yyyy-mm-dd hh-mm-ss +00:00”,示例:2019-11-15 12:57:46 +00:00

tasks.result.items
string[]

响应条目数组,包含结构化 AI 响应数据

tasks.result.items.reasoning
object

响应中的元素

tasks.result.items.reasoning.type
string

元素类型 = 'reasoning' 注意:此元素仅在推理模型中受支持,且不保证返回

tasks.result.items.reasoning.sections
string[]

推理链分段对象数组,包含 LLM 生成的推理链分段

tasks.result.items.reasoning.sections.type
string

element='summary_text' 的类型

tasks.result.items.reasoning.sections.text
string

推理链部分的文本,用于总结模型的思考过程

tasks.result.items.message
object

响应中的元素

tasks.result.items.message.type
string

元素类型 = 'message'

tasks.result.items.message.sections
string[]

内容分区数组,包含 AI 响应的不同部分

tasks.result.items.message.sections.type
string

元素类型='text'

tasks.result.items.message.sections.text
string

AI 生成的文本内容

tasks.result.items.message.sections.annotations
string[]

用于生成响应的引用数组;如果 web_search 参数未设置为 true,则为 null。注意:即使 web_search 为 true,annotations 也可能返回空值,因为 AI 会尝试检索 Web 信息,但可能找不到相关结果。

tasks.result.items.message.sections.annotations.title
string

引用来源的域名或标题

tasks.result.items.message.sections.annotations.url
string

引用来源的 URL

tasks.result.fan_out_queries
string[]

扩展查询数组,包含从主查询派生的相关搜索查询,以提供更全面的响应