Model Specifications
The model processes input with these specifications:- Video Frame Rate: 25 FPS
- Video Resolution: 1280x720 (16:9)
- Supported Image Formats: JPEG, PNG, WebP
Realtime API
The realtime API uses WebRTC for low-latency avatar animation. Clients establish a connection with a portrait image, then send audio to receive an animated video stream in return. The connection remains active as long as you maintain it, allowing you to send multiple audio clips and change avatar behavior prompts on-the-fly.Installation
Basic Usage
Advanced Features
Avatar Image Options
You can provide the avatar image in multiple formats:Audio Input Methods
Send audio to animate the avatar using file uploads or microphone recordings:Prompt Management
Control avatar behavior and expressions with prompts. You can set the prompt at connection time or change it after connection:Connection State Management
Complete Example with Error Handling
WebSocket + WebRTC (Vanilla)
For direct WebSocket communication without the SDK:API Reference
Connection Options
| Option | Type | Description |
|---|---|---|
model | Model | The Avatar Live model from models.realtime("live_avatar") |
initialState | { image: Blob | File | string, prompt?: { text: string, enhance?: boolean } } | Initial state with portrait image and optional behavior prompt |
onRemoteStream | (stream: MediaStream) => void | Callback when animated video stream is ready |
Methods
| Method | Parameters | Description |
|---|---|---|
playAudio | audio: Blob | File | ArrayBuffer | Send audio to animate the avatar (returns Promise that resolves when audio finishes) |
setPrompt | prompt: string, options?: { enhance?: boolean } | Set avatar behavior prompt |
isConnected | none | Returns boolean - connection status |
getConnectionState | none | Returns "connecting" | "connected" | "disconnected" |
disconnect | none | Close the connection |
Events
| Event | Payload | Description |
|---|---|---|
connectionChange | "connecting" | "connected" | "disconnected" | Connection state changed |
error | DecartSDKError | An error occurred |