Skip to content

Create Session Token

Creates a Compose session token for WebRTC avatar streaming.

This example assumes using Simli; is in scope and apiKey contains your Simli API key.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
using var client = new SimliClient(apiKey);

// Get available faces first
var faces = await client.GetFacesAsync();

var faceId =
    Environment.GetEnvironmentVariable("SIMLI_FACE_ID") is { Length: > 0 } configuredFaceId
        ? configuredFaceId
        : faces.FirstOrDefault()?.Id.ToString()
            ?? throw new AssertInconclusiveException("SIMLI_FACE_ID is required when the account has no custom faces.");

// Create a Compose session token for realtime avatar streaming
var response = await client.StartAudioToVideoSessionComposeTokenPostAsync(
    faceId: faceId);