Quickstart
Set up your first conversation with a LiveAvatar.
This guide assumes you're developing with both a backend server and a managed frontend client.
1. Create a Session Token
Before starting a session, generate a session token on your backend server. This token defines the configuration for the LiveAvatar session and also serves as a short-lived access token, allowing your frontend client to manage the session once it starts.
You can find your API token on the LiveAvatar settings page.
See the example curl command below to generate a session token for FULL mode.
curl --request POST \
--url https://api.liveavatar.com/v1/sessions/token \
--header 'X-API-KEY: <API Token>' \
--header 'accept: application/json' \
--header 'content-type: application/json'
--data '{
"mode": "FULL",
"avatar_id": <avatar_id>,
"avatar_persona": {
"voice_id": <voice_id>,
"context_id": <context_id>,
"language": "en"
}
}' When successful, you'll receive both a session_id and session_id.
{
"session_id": <new_session_id>,
"session_token": <your_session_token>,
}
2. Start the Session
Once you have access to a session token, you're ready to start the session. This can be done via a quick call via the newly generated session_token.
curl --request POST \
--url https://api.liveavatar.com/v1/sessions \
--header 'accept: application/json' \
--header 'authorization: Bearer <session_token>'With this, we return a LiveKit room url along with the room token. We stream all the relevant information about the room user.
3. Join the Live Kit room
On your frontend client, have your user join the LiveKit room. Connecting to the room requires both the livekit_urland the room_tokenexposed by the previous API call.
Once you join the room, you should now be chatting with a LiveAvatar!
Building your own experience
After starting up, you'll need to now start building the user experience out. If you're building with npm, we recommend using our own npm package to help to abstract away the session management of LiveKit. Also check out our existing demos to get additional inspiration.
- Examples - https://github.com/heygen-com/liveavatar-web-sdk
- NPM - https://www.npmjs.com/package/@heygen/liveavatar-web-sdk?activeTab=versions
Updated 10 days ago
Check out our Sessions APIs to learn more on how to start a session. Otherwise, learn more about the LiveAvatar Session Lifecycle to build responsive real-time apps.