Prerequisites
- A TruGen API key (get one here)
- A TruGen Agent ID (create and get one here)
- A modern web browser with microphone access
- A local web server (we’ll show you how to start one below)
Create Your First Avatar
1
Create the HTML Structure
Create a new file called
index.html and add this basic layout to display the avatar video and session status:2
Add the JavaScript SDK
Add the script that will automatically authenticate and start your session. Add this
<script> tag just before the closing </body> tag:3
Configure Credentials
Replace
your-api-key-here and your-agent-id-here in the script block with your actual TruGen credentials.4
Start a Local Server
To serve your HTML file, start a local web server in the directory containing
index.html:5
Open and Test
- Navigate to
http://localhost:8000(or the port specified by your local server) in your browser. - Allow microphone access when prompted.
- The avatar will load, connect, and start speaking automatically!
What just happened?
- Session Token — Your API key was exchanged for a temporary session token that enables the avatar connection.
- WebRTC Stream — The TruGen SDK established a real-time WebRTC video/audio stream with the TruGen server.
- Voice Interaction — Your avatar starts listening to your microphone input and automatically responds with natural real-time dialogue and expressions.
What’s Next?
Authentication
Learn how to secure your API key using server-side session tokens.
Basic JavaScript Example
Full example with a Node.js backend and clean connect/disconnect flow.
Basic Usage
SDK reference for initializing, streaming, and disconnecting.
Event Handling
Listen to connection, speaking, and transcript events in real time.