Skip to main content

Constructor

Creates a new Odyssey client instance with the provided API key.

Methods

connect()

Connect to a streaming session. The Odyssey API automatically assigns an available session. If you start a stream with broadcast: true, the SDK will invoke handlers.onBroadcastReady(...) with spectator playback details.
Returns: Promise<MediaStream> - Resolves with the MediaStream when the connection is fully ready (including data channel). You can call startStream() immediately after this resolves.
The connect() method supports two usage patterns: Await Style for sequential code, and Callback Style for event-driven code. Both patterns wait for the data channel to be ready before proceeding.

When to use each style

Both styles properly wait for the data channel to be ready. You do not need to add any artificial delays between connect() and startStream().

createClientCredentials()

Added in v1.3.0. See the Client Credentials guide for the full two-phase auth pattern.
Mint short-lived credentials that a client (e.g., browser) can use to connect without an API key. This provisions a session server-side and returns a ClientCredentials object.
Returns: Promise<ClientCredentials> - Credentials including session token, signaling URL, and streamer capabilities.

connectWithCredentials()

Added in v1.3.0. See the Client Credentials guide for the full two-phase auth pattern.
Connect using pre-minted credentials (no API key required). Call this on the client side with credentials received from your server.
Returns: Promise<MediaStream> - Resolves with the MediaStream when the connection is fully ready.

disconnect()

Disconnect from the session and clean up resources.

startStream()

Start an interactive stream session.
Returns: Promise<string> - Resolves with the stream ID when the stream is ready. Use this ID to retrieve recordings.
Image-to-video requirements:
  • SDK version 1.0.0+
  • Max size: 25MB
  • Supported formats: JPEG, PNG, WebP, GIF, BMP, HEIC, HEIF, AVIF
  • Images are resized to 1280x704 (landscape) or 704x1280 (portrait)

interact()

Send an interaction prompt to update the video content.
Returns: Promise<string> - Resolves with the acknowledged prompt when processed.

endStream()

End the current interactive stream session.
Returns: Promise<void> - Resolves when the stream has ended.

attachToVideo()

Attach the media stream to a video element.
Returns: The video element for chaining, or null if no element provided.

getRecording()

Added in v1.0.0
Get recording URLs for a completed stream.
Returns: Promise<Recording> - Recording data with presigned URLs.

listStreamRecordings()

Added in v1.0.0
List the user’s stream recordings. Only returns streams that have recordings.
Returns: Promise<StreamRecordingsListResponse> - Paginated list of stream recordings.

Simulate API Methods

Simulate API methods were added in v1.0.0
The Simulate API allows you to run scripted interactions asynchronously. Unlike the Interactive API, simulations execute in the background and produce recordings you can retrieve when complete.

simulate()

Create a new simulation job.
Returns: Promise<SimulationJob> - The created simulation job with ID and initial status.

getSimulateStatus()

Get the current status of a simulation job.
Returns: Promise<SimulationJobDetail> - Detailed status including streams created.

listSimulations()

List simulation jobs for the authenticated user.
Returns: Promise<SimulationJobsList> - Paginated list of simulation jobs.

cancelSimulation()

Cancel a pending or running simulation job.
Returns: Promise<{ job_id: string; status: string }> - The cancelled job’s ID and status.
Simulation methods can be called without an active connection. They only require a valid API key.

Broadcast Methods

Broadcast was added in v1.1.0
Broadcast is a feature in the Odyssey API that allows multiple clients to join and view the same live stream. Instead of creating separate streams or streams per user, Broadcast runs a single shared world and streams it to multiple connected clients in real time. All participants receive the same live output from the running stream. Broadcast provides the foundation for shared experiences. Application-level logic can be built on top of Broadcast to coordinate input, roles, and interaction patterns.

Broadcast(streamer)

connectToStream() Connect as a spectator to an existing broadcast stream.
Returns: Promise<SpectatorConnection> - Resolves with a spectator connection object containing a MediaStream for playback and lifecycle controls.

Properties

isConnected

Whether the client is currently connected and ready.

currentStatus

Current connection status. Possible values: 'authenticating' | 'connecting' | 'reconnecting' | 'connected' | 'disconnected' | 'failed'

currentSessionId

Current session ID, or null if not connected.

mediaStream

Current media stream containing video track from the streamer.

connectionState

Current WebRTC peer connection state. Possible values: 'new' | 'connecting' | 'connected' | 'disconnected' | 'failed' | 'closed' | null

iceConnectionState

Current ICE connection state. Possible values: 'new' | 'checking' | 'connected' | 'completed' | 'failed' | 'disconnected' | 'closed' | null