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

# Stream a run's frames

> Sends the agent's output as server-sent events as it is produced: a `frame` event per line, its data the line as JSON, and a `heartbeat` event every 30 seconds to keep the connection open. Closes once the run has ended and every line was sent. The connection may also close earlier; to pick up where it stopped, call again with the `seq` of the last line received as `after`, or let an SSE client reconnect: the `Last-Event-ID` header it sends is used when `after` is absent.



## OpenAPI

````yaml https://tracks.alpic.ai/api/openapi.json get /runs/{id}/frames/stream
openapi: 3.1.0
info:
  title: Tracks API
  version: 0.0.1
  description: >-
    Run coding agents such as Claude Code in isolated sandboxes with an API key
    of your organization. Create a run with a prompt, then follow its output and
    what it costs, or launch an experiment to compare agents on your scenarios.
servers:
  - url: https://tracks.alpic.ai/api
security: []
tags:
  - name: Runs
    description: Start coding agents and follow their work.
  - name: Files
    description: Upload files to place in a run's sandbox.
  - name: Connections
    description: >-
      Let agents use MCP servers as one of their users, without their
      credentials entering the sandbox.
  - name: Experiments
    description: >-
      Define scenarios to give several agents in several variants, judged on
      what they did.
  - name: Executions
    description: Launch experiments and read their results.
  - name: Library
    description: What your experiments can give their agents.
  - name: System
paths:
  /runs/{id}/frames/stream:
    get:
      tags:
        - Runs
      summary: Stream a run's frames
      description: >-
        Sends the agent's output as server-sent events as it is produced: a
        `frame` event per line, its data the line as JSON, and a `heartbeat`
        event every 30 seconds to keep the connection open. Closes once the run
        has ended and every line was sent. The connection may also close
        earlier; to pick up where it stopped, call again with the `seq` of the
        last line received as `after`, or let an SSE client reconnect: the
        `Last-Event-ID` header it sends is used when `after` is absent.
      operationId: runs.followFrames
      parameters:
        - name: id
          in: path
          schema:
            $ref: '#/components/schemas/RunId'
          required: true
        - name: after
          in: query
          schema:
            type: string
            pattern: ^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:[Ee][+-]?\d+)?$
            allOf:
              - description: Send only lines whose `seq` is greater than this.
          required: false
      responses:
        '200':
          description: Success
          content:
            text/event-stream:
              schema:
                anyOf:
                  - type: object
                    properties:
                      id:
                        anyOf:
                          - type: string
                          - type: 'null'
                      event:
                        type: string
                        enum:
                          - frame
                      data:
                        $ref: '#/components/schemas/FrameEncoded'
                    required:
                      - event
                      - data
                    additionalProperties: false
                  - type: object
                    properties:
                      id:
                        anyOf:
                          - type: string
                          - type: 'null'
                      event:
                        type: string
                        enum:
                          - heartbeat
                      data:
                        type: string
                        enum:
                          - ''
                    required:
                      - event
                      - data
                    additionalProperties: false
              x-effect-stream:
                encoding: sse
                causeSchema:
                  type: array
                  items:
                    anyOf:
                      - type: object
                        properties:
                          _tag:
                            type: string
                            enum:
                              - Fail
                          error:
                            not: {}
                        required:
                          - _tag
                          - error
                        additionalProperties: false
                      - type: object
                        properties:
                          _tag:
                            type: string
                            enum:
                              - Die
                          defect: {}
                        required:
                          - _tag
                          - defect
                        additionalProperties: false
                      - type: object
                        properties:
                          _tag:
                            type: string
                            enum:
                              - Interrupt
                          fiberId:
                            anyOf:
                              - type: number
                              - type: 'null'
                        required:
                          - _tag
                          - fiberId
                        additionalProperties: false
                errorSchema:
                  not: {}
                failureEvent: effect/http-api/stream/failure
        '400':
          description: >-
            The request is invalid: a value is missing, has the wrong type or is
            out of range. Fix it before sending the request again.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvalidRequestEncoded'
        '401':
          description: >-
            The API key is missing, malformed or revoked, or its organization is
            closed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiKeyRefusedEncoded'
        '404':
          description: No run with this id exists in your organization.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RunNotFoundEncoded'
      security:
        - bearer: []
components:
  schemas:
    RunId:
      type: string
      description: Unique identifier of the run.
    FrameEncoded:
      type: string
      contentMediaType: application/json
      contentSchema:
        $ref: '#/components/schemas/Frame'
    InvalidRequestEncoded:
      type: object
      properties:
        _tag:
          type: string
          enum:
            - InvalidRequest
        message:
          type: string
          description: Every problem found, in one sentence.
        location:
          type: string
          enum:
            - path
            - query
            - header
            - body
          description: The part of the request that is wrong.
        issues:
          type: array
          items:
            $ref: '#/components/schemas/RequestIssue'
          description: Each problem found, with where it is.
      required:
        - _tag
        - message
        - location
        - issues
      additionalProperties: false
    ApiKeyRefusedEncoded:
      type: object
      properties:
        _tag:
          type: string
          enum:
            - ApiKeyRefused
        message:
          type: string
      required:
        - _tag
        - message
      additionalProperties: false
    RunNotFoundEncoded:
      type: object
      properties:
        _tag:
          type: string
          enum:
            - RunNotFound
        message:
          type: string
      required:
        - _tag
        - message
      additionalProperties: false
    RequestIssue:
      type: object
      properties:
        path:
          type: array
          items:
            anyOf:
              - type: string
              - type: number
              - type: string
                enum:
                  - Infinity
                  - '-Infinity'
                  - NaN
          description: >-
            Keys leading to the wrong value inside that part of the request,
            such as `["agent", "model"]`. Empty when the problem concerns that
            part as a whole.
        message:
          type: string
          description: What is wrong with the value.
      required:
        - path
        - message
      additionalProperties: false
      description: One problem found in the request.
  securitySchemes:
    bearer:
      description: >-
        An API key of your organization, starting with `trk_`, sent as
        `Authorization: Bearer <key>`.
      type: http
      scheme: bearer

````

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