LiveAvatar.start(options)
Opens a session and resolves with aLiveAvatar once the avatar is live. Billing starts here. Rejects with a LiveAvatarError if the session can’t start.
string
required
Your
tav_… key, from the dashboard. Keep it on your server.8000 | 12000 | 16000 | 24000 | 48000
default:"24000"
Your TTS audio’s sample rate (PCM16 mono).
class
default:"globalThis.WebSocket"
A WebSocket class, for Node.js 18 and 20:
import WebSocket from "ws".Methods
pushAudio(pcm, options?)
Queues your agent’s voice. It’s played after what’s already queued, in sync with the lips, so don’t play it yourself. Audio can arrive faster than real time.Int16Array | Buffer | Uint8Array | ArrayBuffer | string
required
PCM16 mono audio. Bytes may be in chunks of any size, even splitting a sample. A string is read as base64 (for example, OpenAI Realtime audio deltas).
number
This chunk’s sample rate, if it differs from the session’s.
number
Only with
livekit.publishAudio: false: the wall-clock time (ms since the epoch) this audio will be heard, sent about 400 ms early.clear()
Interrupts the avatar (barge-in): drops the audio that hasn’t played yet. ReturnsPromise<number | null>: how many milliseconds of the interrupted reply were heard, or null when you play the voice yourself.
handleView(body)
Direct mode only. Your page’s route: pass the request body fromLiveAvatarView, and return the result as JSON. It’s called once for the WebRTC offer and once with the browser’s answer. One route serves any number of viewers.
livekit option.
on(event, listener)
Subscribes to an event. Returns a function that unsubscribes.close()
Ends the session. The avatar stops, and billing stops.Properties
Events
LiveAvatarError
Why a session failed to start, or ended. ExtendsError.
Close codes
See Sessions and errors.