Skip to main content
TruGen AI uses a two-tier authentication system: API keys for server-side requests and session tokens for client-side connections.

Tier 1: API Key

Your API key is used to authenticate server-side requests to the TruGen AI API. API keys can be created and managed from the TruGen AI Dashboard.

Creating an API Key

From the API Keys page, click Create API Key, give it a name, and click Create. Copy and store it securely — you will not be able to view it again.
Never expose your API key on the client side. Store and use it only on your server. If you lose your API key, you will need to create a new one — they cannot be recovered.

Tier 2: Session Tokens

Session tokens are temporary JWT credentials (valid for 5 minutes) that allow client applications to connect to TruGen’s streaming infrastructure without exposing your API key.

How Session Tokens Work

1

Token Request

Your server requests a session token from TruGen AI using your API key and agent configuration.
2

Token Generation

TruGen AI generates a temporary JWT token (valid for 5 minutes) tied to your specific agent configuration.
3

Client Connection

Your client uses the session token with the TruGen SDK to establish a direct WebRTC connection.
4

Real-time Communication

Once connected, the client can send messages and receive video/audio streams directly.

Creating Session Tokens

Below is a basic Express server that exposes an endpoint for creating session tokens.

Client-Side Usage

Once your server creates and returns the session token, pass it to your client application to initialize the SDK and start streaming. See the Basic JavaScript Example and Basic Usage guides for client-side integration examples.

Dynamic Agent Configuration

Instead of using the same agent for all users, you can pass the agentId dynamically from the client:

User-based Agent Selection

Client-side — passing agentId dynamically

Environment Setup

Store your configuration securely in a .env file on your backend server:
.env