⚠️ Before you begin: Please make sure you have completed the Get Started section first to set up all required API keys and environment variables.
Hedra Avatar Setup
1. Using Avatar ID
Web UI
- Use Hedra Studio image generator to create an avatar image.
- Once it’s generated, navigate to your Library and hover over the image you want to use and click the three dots icon
- Click “Copy Asset ID” which can then be used as
avatar_id
.
Hedra API
- Use the Hedra public api to upload an image asset to the platform.
- The
id
in the JSON response is the image asset id which can be used asavatar_id
.
Add to .env
2. Image upload
Alternatively, you may pass an image from your local file system directly using the Livekit Hedra plugin:- You will still need a Hedra account and API key.
- The image will be uploaded to Hedra’s platform where you will be able to view it in your library and get the id using one of the methods detailed above.
Installing Dependencies
1. Install the Livekit Hedra plugin
Note: You might need to use a virtual environment when installing dependencies using pip:
2. Install other dependencies
As detailed in the Livekit docs. The included example uses OpenAI’s realtime model which can be installed with:Avatar Example Setup
- Navigate to
agents/examples/avatar_agents/hedra
. - Move your
.env
file with the necessary environment variables into this directory.
- If you choose to use a local file for your avatar image, you will need to edit the
agent_worker.py
example to pass the image properly:
Avatar Example Run
- From within the
agents/examples/avatar_agents/hedra
directory, run the following to start your agent in production mode:
Note: You may need to install missing dependencies with pip. Consider using a virtual environment:
- Navigate to the Livekit Agents Playground in a browser.
- Connect to the project room that corresponds to the environment variables set in
.env
.
Your session request will not be queued until after a user connects to the room. It may take several seconds for your avatar to load.
Ending Your Avatar Session
1. Inactivity timeout
If the room does not get any user audio input for more than 2 minutes, the session will terminate due to user inactivity.NOTE: this is currently disabled
2. Room disconnect
Clickdisconnect
in the Livekit Playground and your session will stop.
NOTE: if you disconnect this way, you will incur an additional 20-30 seconds of billing charges because the session is designed to prevent immediate termination in the event of disconnects that may occur due to network instability
3. End your example process
End theagent_worker.py
process using your favorite SIGINT, SIGKILL, etc. mechanism.