SPAvatarSDK
The main entry point class for the SDK, responsible for initialization and global configuration.SPCharacterManager
Character manager responsible for rendering and control.SPCharacterLoader
Character loader responsible for downloading and caching character resourcesConnection State
SPAvatar.ConnectionState
SDK connection state definitionConversation State
SPAvatar.ConversationState
SDK conversation state definitionPlayer State
SPAvatar.PlayerState
SDK player state definitionError Handling
SPAvatar.Error.ErrorType
SDK error type definitionUsage Examples
Basic Initialization
1
Create Configuration
2
Initialize SDK
Authentication will start when connecting to the service. If authentication fails, SPAvatarSDKDelegate will call the failure callback
Create Character View
1
Create Character Manager Instance
2
Create Character View
Audio Processing
Audio Usage Example
Implement Delegate Methods
SPCharacterManagerDelegate Implementation
Error Code Reference
| Error Type | Error Code | Description | Solution |
|---|---|---|---|
sdkNotVerified | 1001 | SDK not verified | Check if SDK started successfully |
characterIdWrong | 1002 | Character ID is invalid | Check character status |
characterAssetsMissing | 1003 | Character assets are missing | Check if character resources are complete |
characterCameraSettingsWrong | 1004 | Character camera settings are invalid | Check camera parameters |
serviceError | 1005 | Server error | Network service may be temporarily down, downgrade plan will be activated |
activeAudioSessionFailed | 1006 | Unsupported operation | Check for AudioEngine configuration conflicts |
startAudioEngineFailed | 1007 | Failed to start AudioEngine | Check SDK version and feature support |
sendDataWrong | 1008 | Sent data is invalid | Check if the audio data sent is valid |
requestTimeout | 1009 | Request timeout | Check network status |
Thread Safety
- Main Thread: UI-related operations must be executed on the main thread
- Background Thread: Network requests and file operations are executed on background threads
- Callbacks: All delegate callbacks are executed on the main thread
Memory Management
- SPAvatarKit automatically manages internal resources
- Avoid retain cycles by using
weakreferences for delegate objects - When exiting the character page, call close(shouldCleanup: Bool = true) through SPCharacterManager to clean up resources

