Messaging
sendMessage(text)
Sends a text message to the avatar. The avatar generates an LLM response and replies with voice.
js
SDK.sendMessage('Hello');| Parameter | Type | Description |
|---|---|---|
text | string | Message to send |
speak(option)
Makes the avatar read the given text as-is (without LLM processing).
You can pass a string or an option object.
js
// Text only
SDK.speak('Please read this sentence exactly');
// With an option object
SDK.speak({ text: 'Hello.' });| Parameter | Type | Description |
|---|---|---|
option | string | SpeakOption | Text string or option object |
SpeakOption
| Field | Type | Required | Description |
|---|---|---|---|
text | string | Yes | Text for the avatar to read |
Stopping speech and speaking again
If you call speak() or sendMessage() immediately after stopSpeaking(), the server may not process the request. See Avatar Control > stopSpeaking() for the safe calling pattern.
sendSpeakAudio(audio, sample_rate)
Sends Base64-encoded audio data so the avatar lip-syncs to the audio.
js
SDK.sendSpeakAudio(base64AudioData);
// Pass the sample rate as well
SDK.sendSpeakAudio(base64AudioData, sampleRate);| Parameter | Type | Required | Description |
|---|---|---|---|
audio | string | Yes | Base64-encoded audio data |
sample_rate | number | No | Sample rate (Hz) of the audio being sent. Pass the actual sample rate of the source audio — e.g. AudioContext.sampleRate (typically 48000) for browser recordings. If omitted, the server assumes 16000Hz, so audio with a different source rate may play back distorted (wrong speed/pitch). |
- The size limit applies per call. If the original bytes decoded from the Base64 string exceed 0.1MB, that call is not sent. When you split the audio across several calls, each call is checked on its own, and the limit does not apply to the cumulative total.
- Pass only the Base64 string in
audio. If it carries a data URL prefix such asdata:audio/...;base64,, the call is not sent. - Exceeding the size limit or passing a malformed Base64 string does not throw. Only that call is not sent, and a warning is logged to the console.
audiois always a single Base64 string per call (not an array). For long audio, slice the string and call repeatedly as below, then callendSpeakAudio()when done.
js
const CHUNK_SIZE = 96 * 1024;
for (let i = 0; i < base64Audio.length; i += CHUNK_SIZE) {
const chunk = base64Audio.slice(i, i + CHUNK_SIZE); // string
SDK.sendSpeakAudio(chunk, sampleRate);
}
SDK.endSpeakAudio();endSpeakAudio()
Ends the lip-sync audio streaming. Call it once after sending the last chunk. Once the server receives this signal, it begins lip-sync processing with the received audio.
js
SDK.endSpeakAudio();clearMessages()
Clears the conversation message list when using <chat-container>.
js
SDK.clearMessages();