Skip to main content

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

Use createClient 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

The createClient function accepts an optional second parameter for configuration:
Forcing TURN relayrtcConfiguration is passed directly to the browser’s RTCPeerConnection, so you can set any native WebRTC option. The most common is iceTransportPolicy: "relay", which routes all media through Anam’s TURN servers on networks that block direct or UDP connectivity. See Network Configuration. ICE-server precedence (highest to lowest): the top-level iceServers option, then rtcConfiguration.iceServers, then Anam’s server-provided defaults. The resolved iceServers always takes the iceServers field, so combining both options is safe.

Troubleshooting

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
Last modified on June 1, 2026