Documentation Index
Fetch the complete documentation index at: https://docs.spatialreal.ai/llms.txt
Use this file to discover all available pages before exploring further.
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()
deviceScore()
deviceScore()
DeviceScore containing cpuScore and gpuScore.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()
interrupt()
interrupt()
send(audioData, end)
send(audioData, end)
audioData: PCM16 (S16LE) mono audio data. Byte length must be even (2 bytes per sample).end: 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, conversationId)
yield(animations, conversationId)
animations: List of animation dataconversationId: The request ID returned from yield audio
true if the server has sent all animation data (end signal received), false otherwise.AvatarView
3D rendering view that automatically creates and manages AvatarController.Initializers
constructor(context)
constructor(context)
Properties
controller
controller
avatarTransform
avatarTransform
onFirstRendering
onFirstRendering
Methods
init(avatar, scope)
init(avatar, scope)
avatar: The avatar to displayscope: Coroutine scope, usually obtained viaactivity.lifecycleScope
pauseRendering()
pauseRendering()
resumeRendering()
resumeRendering()
dispose()
dispose()
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)
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:)
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. |
Playing | The avatar is playing audio/animation. |
Paused | Playback is paused. |
LoadProgress
Load progress sealed class.| Case | Description |
|---|---|
Downloading(Float) | Downloading with progress (0-1). |
Completed | Loading completed. |
Failed(Throwable) | Loading failed with error. |

