Skip to main content
The TruGen API provides a simple interface for implementing digital AI avatars within your web applications. This guide will walk you through the process of setting up a minimal example of an interactive AI avatar. By the end, you’ll have a working avatar that can have real-time conversations in your web browser.

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.
This quickstart puts credentials directly in the browser for simplicity. For production deployments, always keep your API key on the server. See Usage in Production for the secure approach.
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

  1. Navigate to http://localhost:8000 (or the port specified by your local server) in your browser.
  2. Allow microphone access when prompted.
  3. 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.