Constructor
Methods
connect()
Connect to a streaming session. The Odyssey API automatically assigns an available session. If you start a stream withbroadcast: 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
createClientCredentials()
Added in v1.3.0. See the Client Credentials guide for the full two-phase auth pattern.
ClientCredentials object.
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.
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.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
Returns:
Promise<Recording> - Recording data with presigned URLs.
listStreamRecordings()
Added in v1.0.0
Returns:
Promise<StreamRecordingsListResponse> - Paginated list of stream recordings.
Simulate API Methods
Simulate API methods were added in v1.0.0
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(streamer)
Returns:
Promise<SpectatorConnection> - Resolves with a spectator connection object containing a MediaStream for playback and lifecycle controls.
Properties
isConnected
currentStatus
'authenticating' | 'connecting' | 'reconnecting' | 'connected' | 'disconnected' | 'failed'
currentSessionId
null if not connected.
mediaStream
connectionState
'new' | 'connecting' | 'connected' | 'disconnected' | 'failed' | 'closed' | null
iceConnectionState
'new' | 'checking' | 'connected' | 'completed' | 'failed' | 'disconnected' | 'closed' | null