API Reference

Avatar stream

Generate synchronized audio and blendshape frames over WebSocket.

WS/v1/avatar/stream

Requires avatar:interact or avatar:use. Send a JSON payload once, then receive audio and blendshape frames until completion.

Request payload

Payload fields include text, optional sessionId, and voice configuration.

import WebSocket from 'ws';

const ws = new WebSocket('wss://<gateway-host>/v1/avatar/stream', {
  headers: {
    Authorization: `Bearer ${process.env.DISRUPTIVERAIN_CLIENT_ID}:${process.env.DISRUPTIVERAIN_CLIENT_SECRET}`,
  },
});

ws.onopen = () => {
  ws.send(JSON.stringify({
    text: 'Hello from Disruptive Rain',
    sessionId: 'avatar_123',
    voiceId: 'default',
    emotion: 'neutral',
    speed: 1.0,
  }));
};

ws.onmessage = (event) => {
  const message = JSON.parse(event.data);
  if (message.type === 'audio') {
    console.log('audio frame', message.audio);
  }
  if (message.type === 'blendshape') {
    console.log('blendshape', message.frameIndex, message.coeffs);
  }
};

WebSocket upgrades require auth headers. Browsers cannot set custom headers on WebSocket connections, so proxy streaming through your backend if you need browser avatar playback.

Event payloads

{
  "type": "audio",
  "sessionId": "avatar_123",
  "audio": "<base64>",
  "format": "pcm_s16le",
  "sampleRate": 48000,
  "duration": 1.2
}
{
  "type": "blendshape",
  "sessionId": "avatar_123",
  "frameIndex": 12,
  "ptsMs": 240,
  "coeffs": {
    "jawOpen": 0.42,
    "mouthSmileLeft": 0.18
  }
}
Was this page helpful?