跳转到主要内容

Documentation Index

Fetch the complete documentation index at: https://docs.qoder.com/llms.txt

Use this file to discover all available pages before exploring further.

GET /v1/sessions/{session_id}/events 获取 Session 中的事件列表,按时间正序排列。支持游标分页。

请求头

头部必选说明
AuthorizationBearer <PAT>

路径参数

参数类型必选说明
session_idstringSession ID(sess_ 前缀)

查询参数

参数类型必选说明
limitinteger返回数量上限,默认 20
after_idstring游标分页:返回该事件 ID 之后的记录
before_idstring游标分页:返回该事件 ID 之前的记录
完整分页规范详见 分页

示例请求

curl -X GET "https://openapi.qoder.sh/api/v1/cloud/sessions/sess_019e392c0d1e74e095d21ea4c6b41def/events?limit=5" \
  -H "Authorization: Bearer $QODER_PAT"

示例响应

HTTP 200 OK
{
  "data": [
    {
      "id": "evt_019e392c0d787cfaa21bda98e06cd913",
      "type": "user.message",
      "content": "你好,这是一个测试消息",
      "session_id": "sess_019e392c0d1e74e095d21ea4c6b41def",
      "turn_id": "turn_019e392c0d787ceea6bb62943f9ac3ec",
      "schema_version": "1.0",
      "created_at": "2026-05-18T03:40:48.888851795Z",
      "processed_at": "2026-05-18T03:40:48.888851795Z"
    },
    {
      "id": "evt_771c1195bcbd4a07834d4ed4dd6450ca",
      "type": "session.status_rescheduled",
      "session_id": "sess_019e392c0d1e74e095d21ea4c6b41def",
      "turn_id": "turn_019e392c0d787ceea6bb62943f9ac3ec",
      "schema_version": "1.0",
      "created_at": "2026-05-18T03:40:50.321Z",
      "processed_at": "2026-05-18T03:40:50.321Z"
    }
  ],
  "first_id": "evt_019e392c0d787cfaa21bda98e06cd913",
  "last_id": "evt_771c1195bcbd4a07834d4ed4dd6450ca",
  "has_more": true
}

事件类型参考

type说明特有字段
user.message用户消息content (string)
agent.messageAgent 回复content (ContentBlock[])
agent.thinkingAgent 思考-
session.status_rescheduled会话被调度执行-
session.status_idle会话回到空闲usage, status, stop_reason
session.error会话执行错误error, details, retry_status
span.model_request_start模型请求开始-
span.model_request_end模型请求结束-
terminated执行终止-
agent.messagecontent 格式:
{
  "content": [
    {
      "type": "text",
      "text": "Agent 的回复文本内容"
    }
  ]
}
session.status_idle 的额外字段:
{
  "type": "session.status_idle",
  "status": "idle",
  "usage": {
    "input_tokens": 150,
    "output_tokens": 42,
    "cache_read_input_tokens": 0,
    "cache_creation_input_tokens": 0
  },
  "stop_reason": {
    "type": "end_turn"
  }
}
session.error 格式:
{
  "type": "session.error",
  "error": {
    "message": "The operation was aborted due to timeout",
    "type": "unknown_error"
  },
  "details": {
    "message": "The operation was aborted due to timeout",
    "name": "TimeoutError"
  },
  "retry_status": {
    "type": "exhausted"
  }
}

响应字段

字段类型说明
dataarray事件对象列表
first_idstring当前页第一条记录的 ID
last_idstring当前页最后一条记录的 ID
has_moreboolean是否还有更多记录

错误码

HTTPtype触发条件
401authentication_errorPAT 无效或过期
404not_found_errorSession 不存在
完整错误信封说明详见 错误参考