列出会话事件
分页返回协调者线程的会话事件历史,按时间从早到晚排列。agent.delta 仅通过实时流发送,不会出现在历史中。
将 next_page_token 作为 page_token 传入以继续历史分页。升序时,翻页完成后将末页的 stream_cursor 作为 cursor 传给会话实时流接口。order 为 desc 或 processed_at_desc 时,保留首页(最新一页)的 stream_cursor,后续更早的历史页不得覆盖此位置。
客户端按事件 id 去重。开始订阅后,重连使用最近收到的 SSE 事件 ID,即使继续加载更早的历史也不覆盖该位置。
curl --request GET \
--url https://api.moonshot.cn/v1/sessions/{id}/events \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.moonshot.cn/v1/sessions/{id}/events"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.moonshot.cn/v1/sessions/{id}/events', 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.moonshot.cn/v1/sessions/{id}/events",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.moonshot.cn/v1/sessions/{id}/events"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.moonshot.cn/v1/sessions/{id}/events")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.moonshot.cn/v1/sessions/{id}/events")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"items": [
{
"id": "sevt_01h455vb4pex5vsknk084sn02q",
"processed_at": "2026-01-01T00:00:00Z",
"type": "user.message",
"data": {
"content": [
{
"type": "text",
"text": "Hello"
}
]
}
}
],
"next_page_token": "next-page-token",
"stream_cursor": "4096"
}{
"error": {
"type": "invalid_parameter_error",
"message": "The `name` parameter is invalid.",
"request_id": "req_01h455vb4pex5vsknk084sn02q",
"param": "name"
}
}{
"error": {
"type": "authentication_error",
"message": "Provide valid credentials before retrying.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}{
"error": {
"type": "resource_not_found_error",
"message": "The requested resource does not exist.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}{
"error": {
"type": "rate_limit_reached_error",
"message": "Too many requests. Retry after 60 seconds.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}{
"error": {
"type": "server_error",
"message": "The platform could not complete the request. Retry later.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}请求头
查询参数
响应
事件按请求顺序返回。每页都包含用于恢复实时流的 stream_cursor。
按请求顺序排列的一页会话事件历史。
本页的事件,按请求顺序排列。
用户消息已投递给智能体。data 携带按序排列的内容块;当消息来自输入队列时,事件复用该输入的 event_id 作为自己的 id。
- 用户消息
- 用户中断
- 用户工具确认
- 自定义工具结果
- 智能体消息
- 智能体推理
- 智能体工具调用
- 智能体工具调用结果
- 智能体模型调用开始
- 智能体推理开始
- 智能体消息开始
- 智能体工具调用开始
- 自定义工具调用
- 收到线程消息
- 发送线程消息
- 线程上下文已压缩
- 智能体增量输出
- 会话状态
- 会话错误
- 子线程已创建
- 线程状态
- 会话标题已更新
- 会话已更新
- 会话用量
Show child attributes
Show child attributes
[]
作为 cursor 传入对应会话或线程的实时流接口。每页都包含此位置,包括空页和没有 next_page_token 的末页。此位置与历史分页令牌相互独立,必须用于同一会话或线程。
升序读取历史时,翻页完成后使用末页的 stream_cursor。倒序读取历史时,保留首页(最新一页)的 stream_cursor;后续页向更早的历史推进,不得用其值覆盖首页的位置。开始订阅后,重连使用最近收到的 SSE 事件 ID,加载更早的历史不得覆盖该位置。
恢复订阅可能重放事件,客户端必须按事件 id 去重。没有合适锚点的页使用更早的重放位置,或返回 0 以从头重放。游标过期时应重新回填历史,不能直接切换到 now,否则可能跳过未读事件。
"4096"
此页面对您有帮助吗?
curl --request GET \
--url https://api.moonshot.cn/v1/sessions/{id}/events \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.moonshot.cn/v1/sessions/{id}/events"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.moonshot.cn/v1/sessions/{id}/events', 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.moonshot.cn/v1/sessions/{id}/events",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.moonshot.cn/v1/sessions/{id}/events"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.moonshot.cn/v1/sessions/{id}/events")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.moonshot.cn/v1/sessions/{id}/events")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"items": [
{
"id": "sevt_01h455vb4pex5vsknk084sn02q",
"processed_at": "2026-01-01T00:00:00Z",
"type": "user.message",
"data": {
"content": [
{
"type": "text",
"text": "Hello"
}
]
}
}
],
"next_page_token": "next-page-token",
"stream_cursor": "4096"
}{
"error": {
"type": "invalid_parameter_error",
"message": "The `name` parameter is invalid.",
"request_id": "req_01h455vb4pex5vsknk084sn02q",
"param": "name"
}
}{
"error": {
"type": "authentication_error",
"message": "Provide valid credentials before retrying.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}{
"error": {
"type": "resource_not_found_error",
"message": "The requested resource does not exist.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}{
"error": {
"type": "rate_limit_reached_error",
"message": "Too many requests. Retry after 60 seconds.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}{
"error": {
"type": "server_error",
"message": "The platform could not complete the request. Retry later.",
"request_id": "req_01h455vb4pex5vsknk084sn02q"
}
}