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 using a JavaScript server.

Prerequisites

  • A TruGen API key (get one here)
  • A TruGen Agent ID (create and get one here)
  • Node.js installed on your machine
  • A modern web browser with microphone access

Project Setup

1

Install Dependencies

2

Set Up Project Structure

Create the following directory layout:
3

Add Your Credentials

Create a .env file and add your API key and Agent ID:
Never expose your API key in the browser. The server reads it from .env and returns only a short-lived session token to the client.
4

Create the Server

Create server.js — this keeps your API key on the server and returns a session token to the browser:
5

Create the HTML

Create public/index.html:
6

Run

Navigate to http://localhost:3000 in your browser, allow microphone access when prompted, then click Connect.