I want any models loaded by the livekit server SDK...
# ask-ai
l
I want any models loaded by the livekit server SDK to save to a specific directory on the local system so that I can then configure that directory to a separate volume (and subsequently a separate hard disk) on the docker container in which it runs. How can I achieve this?
t
Thanks for reaching out, Shashank. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m responding to your request about making any models used by LiveKit save to a specific local directory so you can mount that directory to a separate volume/disk in Docker. Short answer: model files are not managed by the LiveKit Server SDK itself — they are downloaded and cached by the LiveKit Agents/plugins (for example the turn detector which uses Hugging Face). You can control where those models are stored by setting the Hugging Face cache directory and mounting that path into your container. What to do 1. Set HF_HUB_CACHE to the directory you want models saved to on the container. ◦ Example (shell):
Copy code
export HF_HUB_CACHE=/models
• Or set the environment variable in your container runtime. 1. Mount that directory as a Docker volume so it maps to a host path (separate volume/hard disk). ◦ Example Docker Compose snippet:
Copy code
services:
       livekit-agent:
         environment:
           - HF_HUB_CACHE=/models
         volumes:
           - ./local-models:/models
• This maps host
./local-models
(which can be on a separate mounted disk) to
/models
in the container. 1. Ensure file permissions allow the agent process to write to the mounted directory. Notes and clarifications • The LiveKit Server SDK does not download or cache models. The Agents framework and plugins that use external models (Hugging Face, etc.) perform downloads and honor
HF_HUB_CACHE
. • Setting
HF_HUB_CACHE
ensures Hugging Face’s
huggingface_hub
library (used by agents/plugins like the turn detector) writes model files to your chosen path. If you’d like, I can: • Provide a full Dockerfile + docker-compose example tailored to your setup. • Show how to set the environment variable for a single container run (docker run) or for Kubernetes (a ConfigMap/volume mount example). • Help verify the correct path for a specific LiveKit Agent or plugin you’re running — which plugin or agent are you using (for example, turn-detector or another plugin)? Sources: Updating the Turn Detector Model | LiveKit