AvatarSDK
The core management class of the SDK, responsible for initialization and global configuration.Properties
sessionToken
sessionToken
The session token used to authenticate avatars with the AvatarKit Server.
userId
userId
The user identifier.
version
version
Returns the version of AvatarKit.
Methods
initialize(context, appId, configuration)
initialize(context, appId, configuration)
Initialize AvatarKit.Parameters:
context: Application contextappId: Your application identifierconfiguration: The configuration for AvatarKit
supportsCurrentDevice()
supportsCurrentDevice()
Returns a Boolean value that indicates whether AvatarKit supports the current device.
benchmark()
benchmark()
Measures the device’s computational performance for avatar rendering.Returns: A performance score indicating the device’s capability.
AvatarManager
Avatar resource manager, responsible for downloading, caching, and loading avatar data.Methods
initialize(context)
initialize(context)
Initialize AvatarManager. Must be called before use.Parameters:
context: Application context
load(id, onProgress)
load(id, onProgress)
Loads an avatar by ID.Parameters:
id: The avatar identifieronProgress: Optional progress callback
Avatar instance.clear(id)
clear(id)
Clears cached data for a specific avatar.Parameters:
id: The avatar identifier to clear
clearAll()
clearAll()
Clears all cached avatar data.
getCacheSize(id)
getCacheSize(id)
Gets the cache size for a specific avatar.Parameters:
id: The avatar identifier
getAllCacheSize()
getAllCacheSize()
Gets the total cache size for all avatars.Returns: The total cache size in bytes.
getCacheStats()
getCacheStats()
Get cache statistics.Returns: A
CacheStats object containing total entries, total size, and max size.AvatarController
Real-time communication controller that handles WebSocket connections and audio/video data.Properties
onConnectionState
onConnectionState
Callback for connection state changes.
onConversationState
onConversationState
Callback for conversation state changes.
onError
onError
Callback for error events.
volume
volume
The volume of playback (0.0 to 1.0).
Methods
start()
start()
Starts the avatar driving service connection.
stop()
stop()
Stop and close connection.
interrupt()
interrupt()
Stops playback and terminates the current conversation.
send(audioData, end)
send(audioData, end)
Sends audio to the avatar driving service.Parameters:
audioData: The audio data to sendend: Whether this is the end of the audio stream
yield(audioData, end, audioFormat)
yield(audioData, end, audioFormat)
Yields audio from the host.Parameters:
audioData: The audio dataend: Whether this is the end of the audio streamaudioFormat: The audio format (optional)
yield(animations, reqId)
yield(animations, reqId)
Yields animations from the host.Parameters:
animations: List of animation datareqId: The request ID returned from yield audio
AvatarView
3D rendering view that automatically creates and manages AvatarController.Initializers
constructor(context)
constructor(context)
Creates a new avatar view.
Properties
avatarController
avatarController
The controller for the avatar.
Methods
init(avatar, scope)
init(avatar, scope)
Initialize view with avatar.Parameters:
avatar: The avatar to displayscope: Coroutine scope (optional, defaults to lifecycle scope)
onPause()
onPause()
Pause rendering. Should be called in Activity/Fragment
onPause().onResume()
onResume()
Resume rendering. Should be called in Activity/Fragment
onResume().cleanup()
cleanup()
Clean up all resources. Should be called when no longer in use.
Avatar
Avatar data class containing core avatar information.| Property | Type | Description |
|---|---|---|
id | String | The avatar identifier. |
pointCount | Int | The avatar point count. |
Configuration
SDK configuration class.Initializers
Configuration(environment, audioFormat, drivingServiceMode, logLevel)
Configuration(environment, audioFormat, drivingServiceMode, logLevel)
Creates a new configuration with the specified parameters.Parameters:
environment: The environment to useaudioFormat: The audio format configurationdrivingServiceMode: The driving service modelogLevel: The log level
Environment
Environment enum.| Case | Description |
|---|---|
intl | International environment. |
cn | China environment. |
test | Test environment. |
AudioFormat
Audio format configuration for AvatarKit.Initializers
AudioFormat(sampleRate:)
AudioFormat(sampleRate:)
Creates a new audio format with the specified sample rate.Parameters:
sampleRate: The audio sample rate in Hz. Supported sample rates are: 8000, 16000, 22050, 24000, 32000, 44100, 48000.
DrivingServiceMode
Driving service modes for AvatarKit.| Case | Description |
|---|---|
SDK | The SDK handles driving service internally. |
HOST | The host application handles driving service. |
LogLevel
Log levels for AvatarKit.| Case | Description |
|---|---|
ALL | Log all messages. |
VERBOSE | Log verbose messages. |
DEBUG | Log debug messages. |
INFO | Log info messages. |
WARNING | Log warning messages. |
ERROR | Log error messages. |
OFF | Disable logging. |
ConnectionState
Connection state sealed class.| Case | Description |
|---|---|
Connecting | The connection is being established. |
Connected | The connection is active. |
Disconnected | The connection has been closed. |
Failed(Exception) | The connection failed with an exception. |
ConversationState
Avatar conversation state enum.| Case | Description |
|---|---|
Idle | Idle state, showing breathing animation. |
Active | Active, waiting for playable content. |
Playing | The avatar is playing audio/animation. |
LoadProgress
Load progress sealed class.| Case | Description |
|---|---|
Downloading(Float) | Downloading with progress (0-1). |
Completed | Loading completed. |
Failed(Throwable) | Loading failed with error. |

