Skip to main content

GET /api/v1/tasks//stream

Returns a short-lived WebSocket URL that streams the live browser view of a running task. Pair it with a noVNC client (e.g. @novnc/novnc) to embed the live screen in your own dashboard.

Description

While a task is running, its browser is rendered in a headed Chromium inside the worker container and exposed over VNC via websockify. This endpoint resolves a task to a WebSocket URL (wss://...) you can pass directly to a noVNC RFB client to render the live view in a <canvas>. The URL is only valid while the task is actively running. Once the task finishes (success / failure / cancellation) the upstream WebSocket closes and the endpoint returns an error.

Authentication

Requires an API key in the x-api-key header. The same key used for POST /api/v1/inference works here.

Parameters

Path Parameters

  • task_id string required UUID of the task whose live stream you want. Obtain this from the task_id field in your task creation response or task listing.

Headers

  • x-api-key string required Your Optexity API key.

Code Examples

Fetch the stream URL

Success Response (200 OK)

Response Fields: The URL is short-lived (it embeds a signed token) and is only useful while the task is running. Re-fetch a fresh URL each time you (re)connect.

Error Responses

401 Unauthorized

404 Not Found

Returned when the task UUID doesn’t exist or doesn’t belong to your account.

409 Conflict

Returned when the task is queued, completed, failed, or cancelled — there is no live browser to stream.

Frontend Integration

Use @novnc/novnc’s RFB class. It attaches to a plain <div> and renders the live view into a <canvas> inside it. The full reference implementation is in LiveStreamViewer.jsx in the Optexity dashboard.
Install with npm install @novnc/novnc.

Reference implementations

Key RFB options

Lifecycle tips

  • Fetch a fresh stream_url on every (re)connect attempt — the token is short-lived.
  • Call rfb.disconnect() on component unmount to release the underlying WebSocket.
  • Handle the disconnect event: e.detail.clean === true typically means the task finished gracefully (show “Stream ended”); clean === false is a genuine network/auth failure (show retry).
  • The endpoint returns 409 while the task is queued — poll task status first and only call /stream once the task is running.