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

# Watch the live browser

> Get an authenticated WebSocket URL for available browser frames in a run you own.

Request the live-view URL using your API key and an existing run ID:

```bash theme={null}
curl --fail-with-body "https://api.pre.dev/browser-agent/$BATCH_ID/ws" \
  -H "Authorization: Bearer $PREDEV_API_KEY"
```

The response is `{ "url": "wss://…" }`. Connect to that URL exactly as returned; it includes the authorization needed for the live view. Treat it as a credential-bearing URL and keep it out of public logs.

## Frames

Where live capture is available, JSON messages with `type: "frame"` contain:

| Field       | Meaning                                     |
| ----------- | ------------------------------------------- |
| `taskIndex` | Zero-based index within the run             |
| `b64`       | Base64-encoded JPEG image                   |
| `w`, `h`    | Capture metadata dimensions, when available |
| `ts`        | Unix timestamp in milliseconds              |

Filter for `type: "frame"` before reading those fields. For a preview image, use `data:image/jpeg;base64,` followed by `b64` as the image source.

Frames are a live visual feed, not a durable recording, task-control channel, or completion signal. Some execution paths do not produce live frames. Use [SSE or polling](/browser-agents/api/stream-task) for authoritative task state and `includeEvents=true` for available screenshot history.

`404` can mean the run is inaccessible or live streaming is unavailable. A returned URL does not guarantee that a frame will arrive. Current SDKs and MCP tools do not have a wrapper for this endpoint.


## OpenAPI

````yaml api-reference/openapi.json GET /browser-agent/{id}/ws
openapi: 3.1.0
info:
  title: pre.dev API
  description: >-
    Public REST API for software specifications, browser automation, proposal
    assessment, and credit balance. Base URL: https://api.pre.dev. MCP is
    documented separately at https://docs.pre.dev/mcp/tools.
  version: 1.1.0
  contact:
    name: pre.dev Support
    url: https://pre.dev
    email: support@pre.dev
  license:
    name: Proprietary
    url: https://pre.dev/terms
servers:
  - url: https://api.pre.dev
    description: Production API Server
security:
  - apiKeyAuth: []
  - xApiKey: []
tags:
  - name: Specifications
  - name: Browser Agents
  - name: Proposals
  - name: Account
paths:
  /browser-agent/{id}/ws:
    get:
      tags:
        - Browser Agents
      summary: Get a live browser URL
      description: >-
        Returns a credential-bearing WebSocket URL for live JPEG frames.
        Availability depends on the execution path. No browser input control or
        recorded playback.
      operationId: getLiveBrowser
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            description: 24-character record ID.
            pattern: ^[a-fA-F0-9]{24}$
      responses:
        '200':
          description: Connect to the returned WebSocket URL.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LiveBrowserResponse'
        '400':
          description: Invalid request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Missing, invalid, or ineligible authentication.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Record unavailable.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    LiveBrowserResponse:
      type: object
      required:
        - url
      properties:
        url:
          type: string
          description: >-
            Credential-bearing WebSocket URL. Keep private and use only for the
            requested batch.
          format: uri
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: string
        message:
          type: string
          description: Optional detail; not returned by every endpoint.
        code:
          type: string
          description: Machine-readable code when available.
        actionUrl:
          type: string
          format: uri
        requiresSubscription:
          type: boolean
        trialsUsed:
          type: integer
        maxTrials:
          type: integer
      additionalProperties: true
  securitySchemes:
    apiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: API key
      description: Use a pre.dev API key from https://pre.dev/projects/key.
    xApiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: 'Alternative to Authorization: Bearer.'

````