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.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 theagentId 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