Installation
Install the SDK in your project using npm:Browser Requirements
The Anam SDK uses WebRTC for real-time video and audio streaming. Ensure your target browsers support:- WebRTC (Chrome 56+, Firefox 44+, Safari 11+, Edge 79+)
- MediaDevices API for microphone access
HTML Setup
This example requires a video element to display the persona:autoplay starts the stream when the page loads. playsinline prevents
fullscreen mode on mobile devices.Basic Usage
To keep your API key secure, exchange it for a short-lived session token on your server before initializing the client. See Usage in Production for detailed session token information.Initialize the Client
UsecreateClient with your session token:
Start Streaming
Stream the persona to your video element:Listen for Events
Handle connection lifecycle events:Stopping a Stream
To stop an active session and release resources:Client Options
ThecreateClient function accepts an optional second parameter for configuration:
Troubleshooting
| Issue | Solution |
|---|---|
| Video not appearing | Verify the video element ID matches and has autoplay playsinline attributes |
| No microphone access | Ensure HTTPS (required for getUserMedia) and user has granted permission |
| Connection fails | Check browser console for errors; verify session token is valid and not expired |
Next Steps
Talk Commands
Control persona output using talk commands
Audio Control
Control audio input and streaming behavior
User Messages
Send messages programmatically on behalf of the user
Events
Handle connection and conversation events
