AvatarSDK
Main initialization and configuration interface for AvatarKit.Static Methods
appID()
appID()
configuration()
configuration()
sessionToken()
sessionToken()
setSessionToken(sessionToken)
setSessionToken(sessionToken)
userID()
userID()
setUserID(userID)
setUserID(userID)
supportsCurrentDevice()
supportsCurrentDevice()
version()
version()
initialize(appID:configuration:)
initialize(appID:configuration:)
appID: The app identifierconfiguration: The configuration for AvatarKit
benchmark()
benchmark()
AvatarManager
Manage avatar asset loading, caching, and retrieval.Static Properties
shared
shared
Instance Methods
load(id:onProgress:)
load(id:onProgress:)
id: The avatar identifieronProgress: Optional progress callback
Avatar instance.retrieve(id:)
retrieve(id:)
id: The avatar identifier
Avatar if available, otherwise null.derive(assetPath)
derive(assetPath)
assetPath: The path to the avatar asset
Avatar instance.clear(id:)
clear(id:)
id: The avatar identifier to clear
clearAll()
clearAll()
getCacheSize(id:)
getCacheSize(id:)
id: The avatar identifier
getAllCacheSize()
getAllCacheSize()
AvatarController
Instance Properties
onFirstRendering
onFirstRendering
onConnectionState
onConnectionState
onConversationState
onConversationState
onError
onError
Instance Methods
start()
start()
close()
close()
interrupt()
interrupt()
send(audioData, end:)
send(audioData, end:)
audioData: The audio data to sendend: Whether this is the end of the audio stream (default:false)
yieldAudioData(audioData, end:, audioFormat:)
yieldAudioData(audioData, end:, audioFormat:)
audioData: The audio dataend: Whether this is the end of the audio stream (default:false)audioFormat: The audio format (optional)
yieldAnimations(animations, conversationID:)
yieldAnimations(animations, conversationID:)
animations: List of animation dataconversationID: The conversation identifier
pointCount()
pointCount()
volume()
volume()
setVolume(volume)
setVolume(volume)
isOpaque()
isOpaque()
setOpaque(opaque)
setOpaque(opaque)
contentTransform()
contentTransform()
setContentTransform(transform)
setContentTransform(transform)
AvatarWidget
Constructor
AvatarWidget(avatar:onPlatformViewCreated:)
AvatarWidget(avatar:onPlatformViewCreated:)
avatar: The specified avataronPlatformViewCreated: Callback that provides the AvatarController instance when the platform view is created
Avatar
| Instance Property | Type | Description |
|---|---|---|
id | String | The avatar identifier. |
assetPath | String | The local asset path of the avatar. |
Configuration
Configuration for AvatarKit.Constructor
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
| 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.Constructor
AudioFormat(sampleRate:)
AudioFormat(sampleRate:)
sampleRate: The audio sample rate in Hz (default:16000)
| 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 |
|---|---|
off | Disable logging. |
error | Log errors only. |
warning | Log warnings and errors only. |
all | Log all messages. |
ConnectionState
Connection states for AvatarKit.| Case | Description |
|---|---|
disconnected | The connection has been closed. |
connecting | The connection is being established. |
connected | The connection is active. |
failed | The connection failed. |
ConversationState
Conversation states for AvatarKit.| Case | Description |
|---|---|
idle | No active conversation. |
paused | The conversation is paused. |
playing | The avatar is playing audio/animation. |
Transform
Transform for avatar content rendering.Constructor
Transform(x:y:scale:)
Transform(x:y:scale:)
x: The x-axis translation (default:0.0)y: The y-axis translation (default:0.0)scale: The scale factor (default:1.0)
| Static Property | Type | Description |
|---|---|---|
identity | Transform | The identity transform. |
| Instance Property | Type | Description |
|---|---|---|
x | double | The x-axis translation. |
y | double | The y-axis translation. |
scale | double | 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. |
sessionTokenInvalid | The session token is invalid. |
sessionTokenExpired | The session token has expired. |
failedToFetchAvatarMetadata | Failed to fetch avatar metadata. |
failedToDownloadAvatarAssets | Failed to download avatar assets. |

