> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xpertai.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# 接续已有运行的事件流

> 订阅已有运行，不会启动新任务。断线恢复时在 Last-Event-ID 中传入最近收到的 SSE id，例如 Redis 游标格式 1791763200000-0。回放依赖服务端保留的事件；回放不可用时不要自动重新发起运行。



## OpenAPI

````yaml /api/openapi.sdk.zh-Hans.json get /api/ai/threads/{thread_id}/runs/{run_id}/stream
openapi: 3.0.3
info:
  title: XpertAI SDK HTTP 接口
  version: 1.0.0
  description: >-
    SDK 指南使用的当前 HTTP 接口。使用服务端 API Key，通过 Authorization: Bearer <API_KEY> 或
    x-api-key 鉴权，不依赖 ChatKit。本参考覆盖指南中的案例，不代表 SDK 导出的所有方法都已实现；使用其他字段前请核对部署支持情况。
servers:
  - url: https://api.xpertai.cn
    description: XpertAI API，私有部署请替换为自己的 API 服务地址。
security:
  - ApiKeyBearer: []
  - ApiKeyHeader: []
tags:
  - name: Assistants
  - name: Threads
  - name: Runs
  - name: Contexts
  - name: Store
paths:
  /api/ai/threads/{thread_id}/runs/{run_id}/stream:
    get:
      tags:
        - Runs
      summary: 接续已有运行的事件流
      description: >-
        订阅已有运行，不会启动新任务。断线恢复时在 Last-Event-ID 中传入最近收到的 SSE id，例如 Redis 游标格式
        1791763200000-0。回放依赖服务端保留的事件；回放不可用时不要自动重新发起运行。
      operationId: join_run_stream
      parameters:
        - name: thread_id
          in: path
          required: true
          schema:
            type: string
        - name: run_id
          in: path
          required: true
          schema:
            type: string
        - name: Last-Event-ID
          in: header
          required: false
          schema:
            type: string
            pattern: ^\d+-\d+$
            example: 1791763200000-0
      responses:
        '200':
          description: >-
            SSE 示意帧，真实事件包含更多字段。保存每个 id 游标，忽略冒号开头的心跳注释，并处理生命周期、中断和错误事件。HTTP
            成功或连接关闭不代表任务成功。
          content:
            text/event-stream:
              schema:
                type: string
              example: >+
                id: 1791763200000-0

                data: {"type":"message","data":"Hello"}


                id: 1791763200001-0

                data:
                {"type":"event","event":"on_conversation_end","data":{"status":"idle","error":null}}

        '400':
          description: 请求参数、标识关联或操作状态不正确。
        '401':
          description: 缺少 API Key 或 API Key 无效。
        '403':
          description: 调用方无权访问目标资源。
        '404':
          description: 资源不存在或对调用方不可用。
components:
  securitySchemes:
    ApiKeyBearer:
      type: http
      scheme: bearer
      description: 服务端 API Key，不要暴露到浏览器代码中。
    ApiKeyHeader:
      type: apiKey
      in: header
      name: x-api-key

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.