AvatarKit follows a four-stage lifecycle: Initialize → Load → Connect → Cleanup. Each stage maps to a core component.Documentation Index
Fetch the complete documentation index at: https://docs.spatialreal.ai/llms.txt
Use this file to discover all available pages before exploring further.
Overview
| Stage | Component | What happens |
|---|---|---|
| Initialize | AvatarSDK | Configures app ID, environment, audio format, and driving mode. Must be called once before any other API. |
| Load | AvatarManager | Downloads and caches avatar assets. Returns an Avatar instance. |
| Render | AvatarView | Creates the rendering surface and its associated AvatarController. |
| Connect | AvatarController | Opens a WebSocket to the driving service. The avatar begins responding to audio. |
Stage 1: Initialize
CallAvatarSDK.initialize() once at app startup. This sets global configuration that all subsequent operations depend on.
- Web
- iOS
- Android
AvatarSDK.sessionToken before connecting. The token authenticates your session with the driving service.
Stage 2: Load Avatar
UseAvatarManager to download and cache avatar assets. Loading is asynchronous and supports progress tracking.
- Web
- iOS
- Android
AvatarManager.clear(id:) or clearAll() to manage cache.
Stage 3: Render
Create anAvatarView with the loaded avatar. The view automatically creates an AvatarController you can access to manage the connection and send audio.
- Web
- iOS
- Android
Stage 4: Connect and Interact
Callcontroller.start() to open the WebSocket connection. Once connected, send audio with controller.send() (SDK Mode) or controller.yield() (Host Mode).
Call controller.interrupt() to stop the current playback immediately. Call controller.close() when done.
Cleanup
Clean up resources when the avatar is no longer needed.- Web
- iOS
- Android

