AvatarSDK
Main initialization and configuration interface for AvatarKit.Type Properties
appID
appID
The app identifier.
configuration
configuration
The app configuration.
sessionToken
sessionToken
The session token used to authenticate avatars with the AvatarKit Server.
userID
userID
The user identifier provided by the developer to identify the user in the AvatarKit Log Service.
supportsCurrentDevice
supportsCurrentDevice
Returns a Boolean value that indicates whether AvatarKit supports the current device.
version
version
Returns the version of AvatarKit.
Type Methods
initialize(appID:configuration:)
initialize(appID:configuration:)
Initialize AvatarKit.Parameters:
appID: The app identifierconfiguration: The configuration for AvatarKit
benchmark()
benchmark()
Measures the device’s computational performance for avatar rendering.Returns: A performance score indicating the device’s capability.
AvatarManager
Manage avatar asset loading, caching, and retrieval.Type Properties
shared
shared
Instance Methods
load(id:onProgress:)
load(id:onProgress:)
Loads an avatar by ID.Parameters:
id: The avatar identifieronProgress: Optional progress callback
Avatar instance.retrieve(id:)
retrieve(id:)
Retrieves a cached avatar by ID.Parameters:
id: The avatar identifier
Avatar if available, otherwise nil.derive(assetPath:)
derive(assetPath:)
Derives an avatar from a local asset path.Parameters:
assetPath: The path to the avatar asset
Avatar instance.clear(id:)
clear(id:)
Clears cached data for a specific avatar.Parameters:
id: The avatar identifier to clear
clearAll()
clearAll()
Clears all cached avatar data.
clearLRU(keepCount:)
clearLRU(keepCount:)
Clears least recently used avatars, keeping the specified count.Parameters:
keepCount: Number of most recently used avatars to keep
getCacheSize(id:)
getCacheSize(id:)
Gets the cache size for a specific avatar.Parameters:
id: The avatar identifier
getAllCacheSize()
getAllCacheSize()
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
onFirstRendering
onFirstRendering
Callback when the avatar is first rendered.
onConnectionState
onConnectionState
Callback for connection state changes.
onConversationState
onConversationState
Callback for conversation state changes.
onError
onError
Callback for error events.
start()
start()
Starts the avatar driving service connection.
close()
close()
Closes the avatar driving service.
interrupt()
interrupt()
Stops playback and terminates the current conversation.
send(_:end:)
send(_:end:)
Sends audio to the avatar driving service.Parameters:
data: The audio data to sendend: Whether this is the end of the audio stream
yield(_:end:audioFormat:)
yield(_:end:audioFormat:)
Yields audio from the host.Parameters:
data: The audio dataend: Whether this is the end of the audio streamaudioFormat: The audio format (optional)
yield(_:conversationID:)
yield(_:conversationID:)
Yields animations from the host.Parameters:
animations: Array of animation dataconversationID: The conversation identifier
pointCount
pointCount
The point count of the current avatar.
volume
volume
The volume of playback.
AvatarView
A UIView subclass for rendering avatars.Initializers
init(avatar:)
init(avatar:)
Creates a new avatar view with the specified avatar.Parameters:
avatar: The avatar to display
Instance Properties
controller
controller
The controller for the avatar.
contentTransform
contentTransform
Transform for avatar content position and scale within the view.
isOpaque
isOpaque
Whether the view is opaque.
Avatar
Represents an avatar instance.| Instance Property | Type | Description |
|---|---|---|
id | String | The avatar identifier. |
Configuration
Configuration for AvatarKit.Initializers
init(environment:audioFormat:drivingServiceMode:logLevel:)
init(environment:audioFormat:drivingServiceMode:logLevel:)
Creates a new configuration with the specified parameters.Parameters:
environment: The environment to useaudioFormat: The audio format configurationdrivingServiceMode: The driving service modelogLevel: The log level
| Instance Property | Type | Description |
|---|---|---|
environment | Environment | Environment for AvatarKit. |
audioFormat | AudioFormat | Audio format for AvatarKit. |
drivingServiceMode | DrivingServiceMode | Driving service mode for AvatarKit. |
logLevel | LogLevel | Log level for AvatarKit. |
Environment
Environments for AvatarKit.| Case | Description |
|---|---|
intl | International environment. |
cn | China environment. |
AudioFormat
Audio format configuration for AvatarKit.Initializers
init(sampleRate:)
init(sampleRate:)
Creates a new audio format with the specified sample rate.Parameters:
sampleRate: The audio sample rate in Hz
| Instance Property | Type | Description |
|---|---|---|
sampleRate | Int | The audio sample rate in Hz. |
channelCount | Int | The number of audio channels. Fixed to 1 for mono. |
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. |
warning | Log warnings and errors only. |
error | Log errors only. |
off | Disable logging. |
ConnectionState
Connection states for AvatarKit.| Case | Description |
|---|---|
connecting | The connection is being established. |
connected | The connection is active. |
disconnected | The connection has been closed. |
failed(Error) | The connection failed with an error. |
ConversationState
Conversation states for AvatarKit.| Case | Description |
|---|---|
idle | No active conversation. |
playing | The avatar is playing audio/animation. |
paused | The conversation is paused. |
Transform
Transform for avatar content rendering.Initializers
init(x:y:scale:)
init(x:y:scale:)
Creates a new transform with the specified translation and scale.Parameters:
x: The x-axis translationy: The y-axis translationscale: The scale factor
| Type Property | Type | Description |
|---|---|---|
identity | Transform | The identity transform. |
| Instance Property | Type | Description |
|---|---|---|
x | Float | The x-axis translation. |
y | Float | The y-axis translation. |
scale | Float | The scale factor. |
AvatarError
Avatar errors for AvatarKit.| Case | Description |
|---|---|
appIDUnrecognized | The app ID is not recognized. |
avatarIDUnrecognized | The avatar ID is not recognized. |
avatarAssetMissing | The avatar asset is missing. |
failedToDownloadAvatarAssets | Failed to download avatar assets. |
failedToFetchAvatarMetadata | Failed to fetch avatar metadata. |
sessionTokenExpired | The session token has expired. |
sessionTokenInvalid | The session token is invalid. |
| Instance Property | Type | Description |
|---|---|---|
errorDescription | String? | A localized description of the error. |
failureReason | String? | The reason for the failure. |

