- Exchange your API key for a short-lived session token on the server side.
- Return the token to the client and use it in place of the API key.
Getting a Session Token
Session tokens are valid for 5 minutes by default. Request a new token per user session rather than caching them long-term.Fetching a Session Token on Your Server
From your server (Python, Node, Go — anything), call TruGen’s/v1/auth/conversation endpoint with your API key and the target agent ID.
token field, plus the conversationId, the LiveKit url, and the avatar metadata.
Using the Token in Your Desktop App
Once your app receives the token from your backend, use it in place of acreate_session() call by connecting to LiveKit with the returned token/URL directly.
The Python SDK’s
TruGenClient.create_session() currently expects an API key. For a token-based flow in Python, contact support@trugen.ai for the recommended pattern for your deployment shape.User Identity Configuration
When generating a session token, you can optionally supply details about the user connecting:userName— Display name (defaults to"JS SDK"if omitted; safe to override).userId— Unique user identifier. If omitted, TruGen auto-generates a timestamp-based ID.
https://api.trugen.ai/v1/auth/conversation.
Example Request Body
Common Error Responses
Next steps
Authentication
Full two-tier authentication overview.
Basic Usage
Full SDK reference for initializing, streaming, and disconnecting.