Skip to main content

Installation

Download the latest AvatarKit.xcframework, unzip, and drag it into your Xcode project. Set Embed & Sign in your target’s Frameworks, Libraries, and Embedded Content.

AvatarSDK

Main initialization and configuration interface for AvatarKit.
Type Properties
The app identifier.
The app configuration.
The session token used to authenticate avatars with the AvatarKit Server.
The user identifier provided by the developer to identify the user in the AvatarKit Log Service.
Returns whether the current device meets the minimum requirements for avatar rendering.
Returns the version of AvatarKit.
Type Methods
Initialize AvatarKit.
Parameters:
  • appID: The app identifier
  • configuration: The configuration for AvatarKit
Measures the device’s computational performance for avatar rendering.
Returns: A DeviceScore containing cpuScore: Int and gpuScore: Int.

AvatarManager

Manage avatar asset loading, caching, and retrieval.
Type Properties
The shared avatar manager instance.
Instance Methods
Loads an avatar by ID.
Parameters:
  • id: The avatar identifier
  • onProgress: Optional progress callback
Returns: The loaded Avatar instance.
Cancels the loading of avatar by ID.
Parameters:
  • id: The avatar identifier
Cancels all loading of avatars.
Retrieves a cached avatar by ID.
Parameters:
  • id: The avatar identifier
Returns: The cached Avatar if available, otherwise nil.
Derives an avatar from a local asset path.
Parameters:
  • assetPath: The path to the avatar asset
Returns: The derived Avatar instance.
Clears cached data for a specific avatar.
Parameters:
  • id: The avatar identifier to clear
Clears all cached avatar data.
Clears least recently used avatars, keeping the specified count.
Parameters:
  • keepCount: Number of most recently used avatars to keep
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.

AvatarController

The main controller for managing avatar driving service connections and interactions.
Instance Properties
Callback when the avatar is first rendered.
Callback for connection state changes.
Callback for conversation state changes.
Callback for error events.
Starts the avatar driving service connection.
Closes the avatar driving service.
Pauses audio and animation playback.
Resumes audio and animation playback.
Whether the current avatar is actually rendering.
Stops playback and terminates the current conversation.
Sends audio to the avatar driving service.
Parameters:
  • data: 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:
  • data: 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: Array of animation data
  • conversationID: The conversation identifier
The point count of the current avatar.
The volume of playback.

AvatarView

A UIView subclass for rendering avatars.
Initializers
Creates a new avatar view with the specified avatar.
Parameters:
  • avatar: The avatar to display
Instance Properties
The controller for the avatar.
Transform for avatar content position and scale within the view.
Whether the view is opaque.
Instance Methods
Pause avatar rendering.
Resume avatar rendering.

Avatar

Represents an avatar instance.

Configuration

Configuration for AvatarKit.
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

Environments for AvatarKit.

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

DrivingServiceMode

Driving service modes for AvatarKit.

LogLevel

Log levels for AvatarKit.

ConnectionState

Connection states for AvatarKit.

ConversationState

Conversation states for AvatarKit.

Transform

Transform for avatar content rendering.
Initializers
Creates a new transform with the specified translation and scale.
Parameters:
  • x: The x-axis translation
  • y: The y-axis translation
  • scale: The scale factor

AvatarError

Avatar errors for AvatarKit.