HeyGen LiveAvatar
HeyGen LiveAvatar provides real-time, interactive avatar streaming with high-quality lip-sync.
Setup
1. Get API Access
- Go to HeyGen
- Sign up for an API plan (starts at $99/mo)
- Navigate to API Settings
- Copy your API key
2. Select an Avatar
- In HeyGen dashboard, go to Avatars
- Choose a public avatar or create custom
- Copy the Avatar ID
3. Select a Voice
- Navigate to Voices
- Choose a voice that matches your avatar
- Copy the Voice ID
4. Configure Environment
LIVEAVATAR_API_KEY=your-heygen-api-key
NEXT_PUBLIC_AVATAR_ID=Pedro_Blue_Shirt_public
NEXT_PUBLIC_VOICE_ID=your-voice-id
Configuration Options
# Required
LIVEAVATAR_API_KEY=...
NEXT_PUBLIC_AVATAR_ID=...
NEXT_PUBLIC_VOICE_ID=...
# Optional
NEXT_PUBLIC_CONTEXT_ID=... # For conversation context
Pricing
HeyGen uses a credit-based system:
| Tier | Credit Cost | Effective $/min |
|---|---|---|
| Pro | $0.99/credit | $0.198/min |
| Scale | $0.50/credit | $0.10/min |
1 credit = 5 minutes of streaming (API mode)
Session Costs
| Duration | Pro Tier | Scale Tier |
|---|---|---|
| 30 sec (min) | $0.099 | $0.05 |
| 1 minute | $0.198 | $0.10 |
| 3 minutes | $0.594 | $0.30 |
| 5 minutes | $0.99 | $0.50 |
Minimum Charge
Sessions have a 30-second minimum charge. After that, billing is per-second.
Avatar Options
Public Avatars
Pre-made professional avatars available immediately:
- Various appearances (gender, ethnicity, attire)
- Professional settings (office, studio)
- Free to use with API
Custom Avatars
Create from your own footage:
- Upload video of a person speaking
- HeyGen creates a digital clone
- Additional cost may apply
Photo Avatars
Generate from a still image:
- Upload a high-quality photo
- AI generates movement and lip-sync
- Quick setup, lower quality than video
Best Practices
Optimize Session Usage
// End session when user is done
await endSession(sessionId);
Handle Network Issues
- Implement reconnection logic
- Cache partial responses
- Graceful degradation to text
Monitor Usage
- Track session duration in analytics
- Set alerts for unusual usage
- Review monthly spend
Troubleshooting
"Invalid API key"
- Verify key at HeyGen dashboard
- Check for plan/quota limits
- Ensure key has API permissions
Avatar not loading
- Check network connectivity
- Verify avatar ID is correct
- Check browser console for errors
Audio/video sync issues
- Usually network-related
- Try reducing video quality
- Check client bandwidth
Session Architecture
SmarterAvatar uses a hybrid approach:
- Server creates session and gets token
- Client connects directly to HeyGen with token
- Server sends text to be spoken
- Client receives video stream
This keeps API keys secure while enabling real-time streaming.