Tier 1: API Key
Your API key authenticates 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 let clients 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 using your API key and agent ID.
2
Token Generation
TruGen generates a temporary JWT tied to that specific agent configuration.
3
Client Connection
Your Python client uses the session token to establish the WebRTC connection.
4
Real-time Communication
Once connected, the client streams video/audio and receives events.
Development vs. production
There are two accepted patterns depending on where your Python code runs.Development / trusted environment
For local development, backend jobs, and any environment that already trusts the machine, pass your API key directly toTruGenClient. The SDK handles the token exchange internally on every create_session() call.
Production / shipped desktop apps
If you’re shipping a Python desktop application to end users (Windows/Mac/Linux binaries), do not embed your API key in the binary. Instead:- Run a small server-side endpoint that holds the API key.
- Have your desktop app request a short-lived session token from your server.
- Use the token to authenticate — see Usage in Production for the full pattern.
Environment configuration
Set your credentials in a.env file (loaded via python-dotenv) or export them directly:
Next steps
Usage in Production
Ship desktop apps securely with server-side session tokens.
Basic Usage
Full SDK reference for initializing, streaming, and disconnecting.