what is the best practice to deploy the agent to l...
# ask-ai
w
what is the best practice to deploy the agent to livekit cloud. I’ve been testing and running on my local machine but now I’m ready to deploy this
t
Thanks for reaching out, Sumiya. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To help you deploy your agent to LiveKit Cloud smoothly, here are some friendly best practices to follow: 1. Set Up Prerequisites: First, make sure you have the LiveKit CLI (v2.5 or later) installed and a LiveKit Cloud project ready to go. 2. Authenticate: Next, use
lk cloud auth
to authenticate the CLI, and set your default project with
lk project set-default "<project-name>"
. This helps keep things organized. 3. Deploy the Agent: Head over to your project directory and run
lk agent create
. This will register your agent, build a Docker image, and deploy it for you. 4. Manage Secrets: To keep your environment variables like
LIVEKIT_API_KEY
and
LIVEKIT_API_SECRET
safe, use the
--secrets-file
or
--secrets
flags when deploying. 5. Monitor and Update: You can keep an eye on how things are running with
lk agent status
and
lk agent logs
. When you need to update, simply use
lk agent deploy
, and if anything goes sideways,
lk agent rollback
is there to help. 6. Optimize Deployment: For better performance, consider deploying to specific regions using
--regions
to reduce latency. Also, it’s a good idea to keep development and production environments separate. LiveKit Cloud takes care of elastic scaling, load balancing, and session management automatically, so you can focus on what matters most. If you’d like, I’m here to help with any of these steps or answer any questions you have!
w
what does this mean bayarmaaorsoo@Sumiyas-MacBook-Pro nuva-ai-v2 % cd /Users/bayarmaaorsoo/Nuva/nuva-ai-v2/agents/livekit-voice-agent bayarmaaorsoo@Sumiyas-MacBook-Pro livekit-voice-agent % lk project list ┌────────┬───────────────────────────────────┬─────────────────┐ │ Name │ URL │ API Key │ ├────────┼───────────────────────────────────┼─────────────────┤ │ * prod │ wss://test-56p40qg8.livekit.cloud │ APIxSxMpiNzCrcd │ │ test │ wss://test-56p40qg8.livekit.cloud │ APIeN2zfFm6Fya2 │ └────────┴───────────────────────────────────┴─────────────────┘ bayarmaaorsoo@Sumiyas-MacBook-Pro livekit-voice-agent % lk agent create --secrets-file secrets.env Using default project [prod] ┃ Use project [prod] with subdomain [test-56p40qg8] to create agent? do I need to create a subdomain within the project to create a agent ? where does the name test-56p40qp8 come from ?
t
Great question! You actually don’t need to manually create a subdomain within your LiveKit project to set up an agent. The subdomain, like
test-56p40qg8
, is automatically assigned by LiveKit when your project is created. This subdomain is part of your project’s URL (for example,
<https://test-56p40qg8.livekit.cloud>
) and helps identify your project within LiveKit Cloud. When you run
lk agent create
, the CLI smartly pulls the subdomain from the
LIVEKIT_URL
linked to your project, making sure your agent is connected to the right place. You’ll also see this subdomain in the
livekit.toml
configuration file for the agent. If anything feels unclear or you’d like a hand walking through this, just let me know—I’m here to help! Sources: LiveKit | .env.example | autocomplete/fish_autocomplete | Deploying to production | LiveKit Docs