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 the AvatarKit 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 whether the current device meets the minimum requirements for avatar rendering.
Measures the device’s computational performance for avatar rendering.
Returns: A DeviceScore containing cpuScore and gpuScore.

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.
Stops playback and terminates the current conversation.
Sends audio to the avatar driving service.
Parameters:
  • 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
Returns: A conversation ID string.
Audio data byte length must be even (2 bytes per sample). Odd-length data will cause a server-side validation error and WebSocket disconnect.
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. Returns whether the server has sent all animation data for this conversation.
Parameters:
  • animations: List of animation data
  • conversationId: The request ID returned from yield audio
Returns: 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
Creates a new avatar view.
Properties
The controller for the avatar.
Transform for avatar content position and scale within the view.
Callback when the first frame is rendered.
Methods
Initialize view with avatar.
Parameters:
  • avatar: The avatar to display
  • scope: Coroutine scope, usually obtained via activity.lifecycleScope
Pause avatar rendering.
Resume avatar rendering.
Release all resources. Call when the avatar view is no longer needed (e.g., in onDestroy).

Avatar

Avatar data class containing core avatar information.

Configuration

SDK configuration class.
Initializers
Creates a new configuration with the specified parameters.
Parameters:
  • environment: The environment to use
  • audioFormat: The audio format configuration
  • drivingServiceMode: The driving service mode
  • logLevel: The log level

Environment

Environment enum.

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.

LogLevel

Log levels for AvatarKit.

ConnectionState

Connection state sealed class.

ConversationState

Avatar conversation state enum.

LoadProgress

Load progress sealed class.