how download-files work?
# ask-ai
b
how download-files work?
t
Thanks for reaching out, Jupiter. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’ll explain how the
download-files
command works and when to use it. What it does • Pre-downloads ML model weights and other runtime dependencies (VAD, turn detector, noise-cancellation models) so they’re available locally before the agent runs. • Ensures fast startup and avoids on-demand model downloads during calls. How to run it • Python agent:
Copy code
uv run agent.py download-files
• Node.js: add a script in
package.json
like:
Copy code
"scripts": {
    "download-files": "tsc && node agent.js download-files"
  }
then run
pnpm download-files
(or your package manager). When to run it • Run once during project setup or during your Docker image build so containers ship with models included. • Not required on every agent startup. Why it’s required • Plugins such as
livekit-agents[silero]
,
livekit-agents[turn-detector]
, and
livekit-plugins-noise-cancellation
need local model files to operate with low latency. If you’d like, tell me whether you’re using the Python agent, Node.js, or Docker and I’ll give exact commands or a Dockerfile snippet. Sources: examples/bank-ivr | livekit/livekit_composite | DeepWiki | LiveKit turn detector plugin | LiveKit docs | Voice AI quickstart | LiveKit docs | examples/survey | livekit/livekit_composite | DeepWiki | examples/voice_agents | livekit/livekit_composite | DeepWiki
b
if my python file is like this, what will it download:
Copy code
from livekit.agents import AgentSession, Agent, RoomInputOptions, ModelSettings, metrics, MetricsCollectedEvent
from livekit.plugins import (
    openai,
    cartesia,
    elevenlabs,
    deepgram,
    noise_cancellation,
    silero,
)
from livekit.plugins.turn_detector.multilingual import MultilingualModel
from livekit.plugins.turn_detector.english import EnglishModel
t
Thanks — I’m responding to which model files will be downloaded given the imports in your Python file. Based on those imports, download-files will fetch model files required by the plugins that need local models: • noise_cancellation: downloads the noise-cancellation model files used by the
livekit-plugins-noise-cancellation
plugin. • silero: downloads Silero VAD model weights used by
livekit-agents[silero]
. • turn_detector (MultilingualModel and EnglishModel): downloads the turn-detection model files for both the multilingual and English turn-detector implementations used by
livekit-agents[turn-detector]
. The other imported plugins do not require local model weights to be downloaded by `download-files`: • openai, cartesia, elevenlabs, deepgram — these rely on external APIs/SDKs and do not add local ML model downloads. If you want, tell me whether you expect multilingual+English turn models or only one, and I’ll list the exact model filenames and a sample command to download them.
b
I want both multilingual+English turn models, give me a python code
t
You're asking for a Python file that will cause the download of both the multilingual and English turn-detection models when you run the download step. Below is a concise example that imports and references both models so
uv run agent.py download-files
will fetch them (plus Silero VAD and noise-cancellation if those plugins are present). Save as agent.py:
Copy code
# agent.py
from livekit.agents import AgentSession
from livekit.plugins.turn_detector import MultilingualModel, EnglishModel
from livekit.plugins import silero, noise_cancellation

# Reference both models so download-files will include them
multilingual_model = MultilingualModel()
english_model = EnglishModel()

# Optional: configure an AgentSession that uses one of the models at runtime
session = AgentSession(
    turn_detection=multilingual_model,  # use multilingual at runtime (recommended)
    vad=silero.VAD.load(),              # ensures Silero VAD model is referenced
    # add other components (stt, tts, llm) as needed
)

if __name__ == "__main__":
    print("Agent module loaded. Run `uv run agent.py download-files` to download models.")
Then run:
Copy code
uv run agent.py download-files
This will download the multilingual and English turn-detector models as well as any models required by
silero
and
noise_cancellation
plugins referenced in the file. Sources: Improved End-of-Turn Model Cuts Voice AI Interruptions 39% | Building the all-in-one platform for voice AI agents | LiveKit turn detector plugin | LiveKit docs | Voice AI quickstart | LiveKit docs
b
do I have to initialize like this:
Copy code
multilingual_model = MultilingualModel()
english_model = EnglishModel()
t
Good question — short answer: no, you don't strictly have to initialize both with
MultilingualModel()
and
EnglishModel()
just to trigger downloads. Details: •
uv run agent.py download-files
downloads model files for plugins you import and reference. Explicitly instantiating a model (e.g.,
MultilingualModel()
) ensures that model is referenced and its weights are included. • The multilingual model largely replaces the English model and is recommended. If you only need multilingual at runtime, instantiating just
MultilingualModel()
is sufficient for runtime use;
download-files
may still fetch both models if the turn-detector plugin registers them as available. • Best practice: explicitly reference any model you definitely want downloaded. If you want both multilingual and English files present, instantiate both as you showed. If you only need multilingual, instantiate only that one.
b
are you sure I just have to import?
t
Short answer: importing alone is not guaranteed to download the model files. Explanation and recommendation: • The
download-files
step downloads files for plugins and models that are actually referenced by your code. Simply importing a module may not register the specific model class for download. • To be certain a model's weights are fetched, explicitly reference or instantiate it (e.g.,
MultilingualModel()
and/or
EnglishModel()
), or otherwise use the class in your code so the download step can detect it. • If you want both multilingual and English turn models present, instantiate both before running:
Copy code
multilingual_model = MultilingualModel()
english_model = EnglishModel()
If you tell me whether you prefer only multilingual at runtime (but still want both downloaded) or you want both active, I’ll give the minimal code snippet for that case.