init()
Initializes the SDK and starts the avatar connection.
Usage
js
await SDK.init(options);InitOption
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
sdk_key | string | Yes | - | SDK authentication key |
avatar_id | string | Yes | - | Avatar ID |
log_level | LogLevel | No | "debug" | Log level |
language | LanguageCode | No | "ko_kr" | Language code (TTS voice + subtitles) |
enable_microphone | boolean | No | true | Enable microphone (for STT) |
auto_send | boolean | No | false | false (Push to Send): manually control via startListening/endListening. true (Auto Send): STT always active, server VAD detects speech and triggers automatic response. Auto Send only works with avatars that support it — verify support before use. |
stt_only | boolean | No | false | STT-only mode. When true, the avatar does not respond and only STT results are returned. When false, STT results are returned and the avatar responds based on them. |
LogLevel
Controls the log level output to the browser console. Only logs at or above the set level are displayed.
| Value | Output Range | Use Case |
|---|---|---|
"debug" | debug, info, warn, error | Detailed debugging during development (default) |
"info" | info, warn, error | View only key events (connection complete, initialization, etc.) |
"warn" | warn, error | View only potential issues |
"error" | error | Errors only |
"silent" | None | Completely disable console output |
LanguageCode
Specifies the TTS voice and subtitle language for the avatar.
| Value | Language |
|---|---|
"ko_kr" | Korean (default) |
"en_us" | English |
"ja_jp" | Japanese |
"id_id" | Indonesian |
Connection Flow
Error Handling
On failure, the SDK performs internal cleanup, resets to IDLE, and throws an Error.
js
try {
await SDK.init(options);
} catch (error) {
// error.message contains the failure reason
// "Failed to connect: ..." -> SDK key validation or WebSocket connection failure
// "Failed to connect streaming: ..." -> Streaming connection failure
console.error(error.message);
}- If called while init/destroy is already in progress, it waits for the previous operation to complete before executing (Mutex serialization).