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 | "warn" | Log level |
language | LanguageCode | No | "ko_kr" | Language code used for TTS voice, subtitles, and STT recognition |
enable_microphone | boolean | No | true | Whether to use microphone input for STT. When true, the browser microphone permission is requested during init(), and the microphone is active and transmitting audio from the moment the connection is established. Initialize with false if you do not use voice input. When false, no permission is requested. |
auto_send | boolean | No | false | false (Push-to-Send): control speech recognition via startListening/endListening. true (Auto Send): STT stays active, and server voice activity detection (VAD) detects speech segments to request responses automatically. |
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. |
Calling startListening(), endListening(), or cancelListening() while enable_microphone is false does not raise an error. The signals are still sent to the server, but no audio is delivered.
Even if the microphone cannot be acquired, the session stays alive and only a warning is logged.
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 |
"info" | info, warn, error | View only key events (connection complete, initialization, etc.) |
"warn" | warn, error | View only potential issues (default) |
"error" | error | Errors only |
"silent" | None | Completely disable console output |
LanguageCode
Specifies the avatar's TTS voice and subtitle language, and the user's STT recognition language.
| Value | Language |
|---|---|
"ko_kr" | Korean (default) |
"en_us" | English |
"ja_jp" | Japanese |
"id_id" | Indonesian |
Connection Flow
Error Handling
If initialization fails, the SDK releases its internal connection resources, returns to the IDLE state, and then 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
// "Init failed: ..." -> Initialization failure at another stage
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).