curl --request POST \
--url https://api.xpertai.cn/api/ai/threads/{thread_id}/runs/stream \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"assistant_id": "22222222-2222-4222-8222-222222222222",
"input": {
"action": "send",
"message": {
"input": {
"input": "Hello, introduce yourself briefly."
}
}
}
}
'import requests
url = "https://api.xpertai.cn/api/ai/threads/{thread_id}/runs/stream"
payload = {
"assistant_id": "22222222-2222-4222-8222-222222222222",
"input": {
"action": "send",
"message": { "input": { "input": "Hello, introduce yourself briefly." } }
}
}
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({
assistant_id: '22222222-2222-4222-8222-222222222222',
input: {
action: 'send',
message: {input: {input: 'Hello, introduce yourself briefly.'}}
}
})
};
fetch('https://api.xpertai.cn/api/ai/threads/{thread_id}/runs/stream', 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.xpertai.cn/api/ai/threads/{thread_id}/runs/stream",
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([
'assistant_id' => '22222222-2222-4222-8222-222222222222',
'input' => [
'action' => 'send',
'message' => [
'input' => [
'input' => 'Hello, introduce yourself briefly.'
]
]
]
]),
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.xpertai.cn/api/ai/threads/{thread_id}/runs/stream"
payload := strings.NewReader("{\n \"assistant_id\": \"22222222-2222-4222-8222-222222222222\",\n \"input\": {\n \"action\": \"send\",\n \"message\": {\n \"input\": {\n \"input\": \"Hello, introduce yourself briefly.\"\n }\n }\n }\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.xpertai.cn/api/ai/threads/{thread_id}/runs/stream")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"assistant_id\": \"22222222-2222-4222-8222-222222222222\",\n \"input\": {\n \"action\": \"send\",\n \"message\": {\n \"input\": {\n \"input\": \"Hello, introduce yourself briefly.\"\n }\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.xpertai.cn/api/ai/threads/{thread_id}/runs/stream")
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 \"assistant_id\": \"22222222-2222-4222-8222-222222222222\",\n \"input\": {\n \"action\": \"send\",\n \"message\": {\n \"input\": {\n \"input\": \"Hello, introduce yourself briefly.\"\n }\n }\n }\n}"
response = http.request(request)
puts response.read_bodyid: 1791763200000-0
data: {"type":"message","data":"Hello"}
id: 1791763200001-0
data: {"type":"event","event":"on_conversation_end","data":{"status":"idle","error":null}}
Start a streaming run
Start a new run and stream its output. Save run_id from the Content-Location response header. For reconnection use GET /api/ai/threads/{thread_id}/runs/{run_id}/stream; repeating this POST can execute the task again. The body uses assistant_id and input, not the legacy request/options envelope.
curl --request POST \
--url https://api.xpertai.cn/api/ai/threads/{thread_id}/runs/stream \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"assistant_id": "22222222-2222-4222-8222-222222222222",
"input": {
"action": "send",
"message": {
"input": {
"input": "Hello, introduce yourself briefly."
}
}
}
}
'import requests
url = "https://api.xpertai.cn/api/ai/threads/{thread_id}/runs/stream"
payload = {
"assistant_id": "22222222-2222-4222-8222-222222222222",
"input": {
"action": "send",
"message": { "input": { "input": "Hello, introduce yourself briefly." } }
}
}
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({
assistant_id: '22222222-2222-4222-8222-222222222222',
input: {
action: 'send',
message: {input: {input: 'Hello, introduce yourself briefly.'}}
}
})
};
fetch('https://api.xpertai.cn/api/ai/threads/{thread_id}/runs/stream', 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.xpertai.cn/api/ai/threads/{thread_id}/runs/stream",
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([
'assistant_id' => '22222222-2222-4222-8222-222222222222',
'input' => [
'action' => 'send',
'message' => [
'input' => [
'input' => 'Hello, introduce yourself briefly.'
]
]
]
]),
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.xpertai.cn/api/ai/threads/{thread_id}/runs/stream"
payload := strings.NewReader("{\n \"assistant_id\": \"22222222-2222-4222-8222-222222222222\",\n \"input\": {\n \"action\": \"send\",\n \"message\": {\n \"input\": {\n \"input\": \"Hello, introduce yourself briefly.\"\n }\n }\n }\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.xpertai.cn/api/ai/threads/{thread_id}/runs/stream")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"assistant_id\": \"22222222-2222-4222-8222-222222222222\",\n \"input\": {\n \"action\": \"send\",\n \"message\": {\n \"input\": {\n \"input\": \"Hello, introduce yourself briefly.\"\n }\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.xpertai.cn/api/ai/threads/{thread_id}/runs/stream")
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 \"assistant_id\": \"22222222-2222-4222-8222-222222222222\",\n \"input\": {\n \"action\": \"send\",\n \"message\": {\n \"input\": {\n \"input\": \"Hello, introduce yourself briefly.\"\n }\n }\n }\n}"
response = http.request(request)
puts response.read_bodyid: 1791763200000-0
data: {"type":"message","data":"Hello"}
id: 1791763200001-0
data: {"type":"event","event":"on_conversation_end","data":{"status":"idle","error":null}}
Authorizations
Server-side API Key; do not expose it in browser code.
Path Parameters
Body
Published agent ID. HTTP uses assistant_id; the SDK accepts assistantId as a method argument.
Chat action payload. Examples show send; retry, resume and follow_up require the appropriate execution state and access.
- Option 1
- Option 2
- Option 3
- Option 4
Show child attributes
Show child attributes
Optional runtime context. Use only fields supported by your deployed agent.
Response
Schematic SSE frames; real events contain additional fields. Preserve each id cursor, ignore colon-prefixed heartbeat comments and inspect lifecycle, interruption and error events. HTTP success or connection close alone is not task success.
The response is of type string.