Skip to main content
Sessions

Thread 事件流

流式读取指定 Session thread 的事件。

GET /api/v1/cloud/sessions/{session_id}/threads/{thread_id}/stream 以 Server-Sent Events 流式返回一个 thread 的公开事件。

路径参数

参数类型说明
session_idstringsess_ 为前缀的 Session ID
thread_idstringsthr_ 为前缀的 Thread ID

请求头

头部必选说明
AuthorizationBearer $QODER_PAT
Accept使用 text/event-stream
Last-Event-ID提供后从该事件 ID 之后续传。事件 ID 不存在、已被归档、指向非公开内部事件,或不属于该 thread 时返回 400

示例请求

curl -N -X GET "https://api.qoder.com.cn/api/v1/cloud/sessions/sess_019f00000000000000000000000000aa/threads/sthr_019f00000000000000000000000002bb/stream" \
  -H "Authorization: Bearer $QODER_PAT" \
  -H "Accept: text/event-stream"

流格式

id: evt_019f00000000000000000000000003cc
event: agent.message
data: {"id":"evt_019f00000000000000000000000003cc","type":"agent.message","content":[{"type":"text","text":"Thread response"}],"processed_at":"2026-06-15T08:02:00.000Z"}

id: evt_c3d4e5f6a7b8c9d0
event: session.thread_status_idle
data: {"agent_name":"my-agent","id":"evt_c3d4e5f6a7b8c9d0","processed_at":"2026-06-15T08:02:01.000Z","session_thread_id":"sthr_019f00000000000000000000000002bb","stop_reason":{"type":"end_turn"},"type":"session.thread_status_idle"}
服务端会定期发送 : heartbeat 注释行以保持连接活跃。

错误码

HTTP类型触发条件
400invalid_request_errorLast-Event-ID 未能识别该 Session/thread 中的有效公开事件
401authentication_errorPAT 无效或过期
404not_found_errorSession 或 thread 不存在
完整错误信封格式见 错误参考