Installation
AvatarSDK
The core management class of the SDK, responsible for initialization and global configuration.Properties
sessionToken
sessionToken
userId
userId
version
version
Methods
initialize(context, appId, configuration)
initialize(context, appId, configuration)
context: Application contextappId: Your application identifierconfiguration: The configuration for AvatarKit
isDeviceSupported()
isDeviceSupported()
setRenderQuality(quality)
setRenderQuality(quality)
setRenderResolutionCap(enabled, maxHeight)
setRenderResolutionCap(enabled, maxHeight)
benchmark()
benchmark()
AvatarManager
Avatar resource manager, responsible for downloading, caching, and loading avatar data.Methods
initialize(context)
initialize(context)
context: Application context
load(id, onProgress)
load(id, onProgress)
id: The avatar identifieronProgress: Optional progress callback
Avatar instance.clear(id)
clear(id)
id: The avatar identifier to clear
clearAll()
clearAll()
getCacheSize(id)
getCacheSize(id)
id: The avatar identifier
getAllCacheSize()
getAllCacheSize()
getCacheStats()
getCacheStats()
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
onConversationState
onConversationState
onError
onError
volume
volume
Methods
start()
start()
close()
close()
pauseRendering()
pauseRendering()
resumeRendering()
resumeRendering()
interrupt()
interrupt()
send(audioData, end)
send(audioData, end)
audioData: The audio data to sendend: Whether this is the end of the audio stream
yield(audioData, end, audioFormat)
yield(audioData, end, audioFormat)
audioData: The audio dataend: Whether this is the end of the audio streamaudioFormat: The audio format (optional)
yield(animations, reqId)
yield(animations, reqId)
animations: List of encoded motion data framesreqId: The request ID returned from yield audio
AvatarView
3D rendering view that automatically creates and manages AvatarController.Initializers
constructor(context)
constructor(context)
Properties
avatarController
avatarController
Methods
init(avatar, scope)
init(avatar, scope)
avatar: The avatar to displayscope: Coroutine scope, usually obtained viaactivity.lifecycleScope
cleanup()
cleanup()
Render over an Avatar Background
Download the optional 16:9 background from Spatius Studio and add it as a drawable resource. In Compose, place the backgroundImage and AvatarView in the same Box. AvatarView renders on a transparent surface by default, so the background shows through.
Avatar
Avatar data class containing core avatar information.Configuration
SDK configuration class.Initializers
Configuration(region, audioFormat, drivingServiceMode, logLevel)
Configuration(region, audioFormat, drivingServiceMode, logLevel)
region: The region to connect to ("us-west","ap-northeast", or"cn-beijing")audioFormat: The audio format configurationdrivingServiceMode: The driving service modelogLevel: The log levelrenderQuality: Render quality tier
AudioFormat
Audio format configuration for AvatarKit.Initializers
AudioFormat(sampleRate:)
AudioFormat(sampleRate:)
sampleRate: The audio sample rate in Hz. Supported sample rates are: 8000, 16000, 22050, 24000, 32000, 44100, 48000.

