Skip to main content

Installation

build.gradle.kts

AvatarSDK

The core management class of the SDK, responsible for initialization and global configuration.
Properties
The session token used to authenticate avatars with Motion Server.
The user identifier.
Returns the version of AvatarKit.
Methods
Initialize AvatarKit.
Parameters:
  • context: Application context
  • appId: Your application identifier
  • configuration: The configuration for AvatarKit
Returns a Boolean value that indicates whether AvatarKit supports the current device.
Update the global rendering quality tier.
Cap render backing-buffer height while preserving view layout size.
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 AvatarManager. Must be called before use.
Parameters:
  • context: Application context
Loads an avatar by ID.
Parameters:
  • id: The avatar identifier
  • onProgress: Optional progress callback
Returns: The loaded Avatar instance.
Clears cached data for a specific avatar.
Parameters:
  • id: The avatar identifier to clear
Clears all cached avatar data.
Gets the cache size for a specific avatar.
Parameters:
  • id: The avatar identifier
Returns: The cache size in bytes.
Gets the total cache size for all avatars.
Returns: The total cache size in bytes.
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
Callback for connection state changes.
Callback for conversation state changes.
Callback for error events.
The volume of playback (0.0 to 1.0).
Methods
Starts the avatar driving service connection.
Close connection.
Pause the avatar view to pause rendering.
Resume the avatar view to resume rendering.
Stops playback and terminates the current conversation.
Sends audio to the avatar driving service.For audio source and timing guidance, see Audio.
Parameters:
  • audioData: The audio data to send
  • end: Whether this is the end of the audio stream
Returns: A conversation ID string.
Yields audio from the host.
Parameters:
  • audioData: The audio data
  • end: Whether this is the end of the audio stream
  • audioFormat: The audio format (optional)
Returns: A conversation ID string.
Yields animations from the host.
Parameters:
  • animations: List of encoded motion data frames
  • reqId: The request ID returned from yield audio

AvatarView

3D rendering view that automatically creates and manages AvatarController.
Initializers
Creates a new avatar view.
Properties
The controller for the avatar.
Methods
Initialize view with avatar.
Parameters:
  • avatar: The avatar to display
  • scope: Coroutine scope, usually obtained via activity.lifecycleScope
Clean up all resources. Should be called when no longer in use.

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 background Image and AvatarView in the same Box. AvatarView renders on a transparent surface by default, so the background shows through.
For square or portrait display windows, center this 16:9 stage inside a clipped outer container. See Avatar Background for the shared cropping rules.

Avatar

Avatar data class containing core avatar information.

Configuration

SDK configuration class.
Initializers
Creates a new configuration with the specified parameters.
Parameters:
  • region: The region to connect to ("us-west", "ap-northeast", or "cn-beijing")
  • audioFormat: The audio format configuration
  • drivingServiceMode: The driving service mode
  • logLevel: The log level
  • renderQuality: Render quality tier

AudioFormat

Audio format configuration for AvatarKit.
Initializers
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.

RenderQuality

Render quality tiers for AvatarKit.

FrameStarvationMode

Controls playback behavior when motion data cannot keep up with the audio clock.

LogLevel

Log levels for AvatarKit.

ConnectionState

Connection state sealed class.

ConversationState

Avatar conversation state enum.

LoadProgress

Load progress sealed class.