Skip to main content
Stream analysis from a live camera: connect to Interhuman over WebSocket, capture media, and send binary chunks as they are recorded. In this codealong, you will:
  1. Connect to wss://api.interhuman.ai/v1/stream/analyze
  2. Get camera (and microphone where your stack supports it)
  3. Send each recorded segment to Interhuman and read typed server events
Wire the three steps together in your app. Use JavaScript in the browser (getUserMedia + MediaRecorder) or Python on the desktop (opencv-python for video; see notes below for audio).
You’ll need an API key. Follow the API key guide for details.

1) Connect to the WebSocket

Open a TLS WebSocket to the stream endpoint. On connect, send session config as a text frame (UTF-8 JSON), then listen for text replies and parse JSON. Branch on type (signal.detected, engagement.updated, conversation_quality.updated, error).
Reference: Stream & analyze

2) Get camera and microphone

3) Send segments to Interhuman

Send each non-empty recording as a binary WebSocket frame. Start recording after the WebSocket is open and session config is sent.
When the user stops, release the camera and close the connection:

4) Read server envelopes

Every server message shares the same outer shape: type, timestamp, correlation_id, and data. Narrow on type before reading fields inside data.

signal.detected

Each entry in data.signals[] uses the same shape as upload responses: type, start, end, probability, and rationale.

engagement.updated

conversation_quality.updated (when opted in)

When your session config include lists conversation_quality_overall and/or conversation_quality_timeline, you may receive conversation_quality.updated with data.overall and/or data.timeline for the window that was just processed. See Conversation quality.

error

Errors use the same envelope with type: "error" and structured fields under data (for example code, message, link, and segment when applicable). See Error handling.

How to interpret it quickly

  • signal.detected: data.signals[] lists moment-level social signals for the segment; each rationale explains that detection.
  • engagement.updated: attention level for a time window within the segment (start / end are seconds within that segment).
  • conversation_quality.updated: optional overall and per-window quality metrics when requested.

Next steps