Once the connection is established, use RTCPeerConnection.ontract() event to obtain a video stream and attach it to your video HTML object:

const video = document.createElement('video')
peerConnection.ontrack = (event) => {
  const [remoteStream] = event.streams
  video.srcObject = remoteStream
}

The final step is to send a string with text that avatar will say:

const text = "Welcome to Elai real-time API"
await fetch(`https://apis.elai.io/api/v1/streams/render/${streamId}`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${SECRET_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ text })
})

📘

Text length limitations

Stream render API supports up to 7000 chars. Any text bigger than 600 symbols will be splitted into chunks and there might be a latency between chunks.

Note: Future API versions will be able to handle streams which will allow to decrease latency and splitting to chunks will be removed.

🚧

Multiple requests handling

If you send multiple requests to render text simultaneously or before the rendering is finished, they will be handled one by one in a queue, with the first come being the first rendered.

Language
Authorization
Header
Click Try It! to start a request and see the response here!