how to deploy on livekit cloud
# ask-ai
c
how to deploy on livekit cloud
t
Thanks for reaching out, Arjun. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm here to help you get started with deploying on LiveKit Cloud! Just follow these simple steps: 1. Prerequisites: First, make sure you have the LiveKit CLI installed (version 2.5 or later). You'll also need an active LiveKit Cloud project and a working agent ready—if you’re just starting out, the Voice AI quickstart is a great place to begin. 2. Authenticate: Next, use the CLI to connect your project:
lk cloud auth
If you want, you can set a default project too:
lk project set-default "<project-name>"
3. Deploy Your Agent: Head over to your project directory and run:
lk agent create
This will generate all the necessary files and deploy your agent smoothly. 4. Update Deployments: When you have updates, just push them with:
lk agent deploy
This way, your deployment updates happen seamlessly without interrupting your service. 5. Monitor: Finally, keep an eye on everything using the LiveKit Cloud dashboard, where you can track analytics, logs, and resource usage easily. Just so you know, LiveKit Cloud takes care of automatic scaling, stateful load balancing, and operational observability for you. Each active agent session minute costs $0.01, which covers hosting, data transfer, and analytics. If you have any questions along the way, feel free to ask—I’m here to support you! Sources: Deploying to production | LiveKit Docs | Voice AI quickstart | LiveKit Docs | Deploy and scale agents on LiveKit Cloud
c
Copy code
Try to make sure the download-files part in main.py is kept simple and separate from the full app configuration. For instance, consider using a lightweight script or argument parsing so it can handle downloads without initializing everything.
i don't even have download-files word written in main.py. from where exactly this is being done, can you create a new file and give me it's code
t
I'm happy to help you with the
download-files
functionality! This feature is part of the LiveKit Agents framework and is designed to pre-download model files and dependencies before your agent starts running. If you haven't added this to your
main.py
yet, no worries—you can simply create a new file to manage this. Here's a friendly example for you:
Copy code
import os
import logging
from livekit_agents.cli import register_plugins

def download_files():
    logging.basicConfig(level=logging.INFO)
    logger = logging.getLogger("download-files")

    # Register all plugins
    plugins = register_plugins()

    # Trigger download for each plugin
    for plugin in plugins:
        if hasattr(plugin, "download_files"):
            logger.info(f"Downloading files for plugin: {plugin.name}")
            plugin.download_files()

if __name__ == "__main__":
    download_files()
You can save this as a separate file, like
download_files.py
, and run it with:
Copy code
python download_files.py
This little script sets up logging, registers all your plugins, and calls their
download_files()
methods to make sure everything you need is downloaded. If you have any questions or want me to walk you through it step-by-step, just let me know—I’m here to help! Sources: agent/Dockerfile | Infrastructure & Deployment | livekit/livekit_composite | DeepWiki | livekit-plugins/livekit-plugins-turn-detector/README.md | plugins/livekit/src/hf_utils.ts | rag/README.md
c
what if we remove RUN uv run "main.py" download-files, will the code run?
t
I totally understand why you might consider removing
RUN python main.py download-files
from the Dockerfile. Just a quick heads-up though: if you do that, the necessary model files and dependencies won’t be downloaded during the container build. Here’s what that means: • The files will have to download each time the container starts, which can slow things down quite a bit. • There’s also a chance the download could fail or run into network issues, which might cause problems when running the container. Downloading these files during the build process really helps make container startup faster and more reliable. So, unless you have another way to make sure those files are ready when the container runs, it’s usually best to keep this step in place. I’m here if you want to explore other options or need any help with this! Sources: pkg/agentfs/examples/node.Dockerfile | Agent Deployment & Docker Configuration | livekit/livekit_composite | DeepW... | livekit-plugins/livekit-plugins-turn-detector/README.md | python-agent-example-app/Dockerfile | Builds and Dockerfiles | LiveKit Docs
It looks like the agents have been created, but they haven’t been successfully deployed or built just yet. The
0001-01-01T00:00:00Z
timestamp is just a placeholder, which means no deployment has happened so far, and the
---
version indicates that no version has been assigned yet. To get to the bottom of this, you can check the build logs by running:
Copy code
lk agent logs --log-type=build
This should give you some clues about what might be stopping the deployment. If you need any help interpreting the logs or anything else, just let me know—I’m here to help! Sources: Agent deployment CLI reference | LiveKit Docs | livekit/livekit_cloud_agent.pb.go | src/main/proto/google/protobuf/timestamp.proto
c
how to change out project
t
I'd be happy to help you change the default project in the LiveKit CLI! Just follow these simple steps: 1. First, let's take a look at your projects by listing them:
lk project list
You'll notice the current default project is marked with an asterisk (
*
). 2. Next, you can set a new default project with this command:
lk project set-default PROJECT_NAME
Just replace
PROJECT_NAME
with the name of the project you'd like to make your default. 3. Finally, double-check that the change took effect by listing your projects again:
lk project list
You should see the new default project marked with
*
. If you have any questions or need a hand with anything else, please feel free to ask—I’m here to help! Sources: Docs::Home | cmd/lk/utils.go
It looks like you're seeing the error "maximum number of agents reached," which means your LiveKit Cloud project has hit its limit for active agents. No worries—here’s a friendly guide to help you sort it out: 1. Upgrade or Request a Limit Increase: If you're on the Free/BUILD plan, the default limit is 2 agents. To get more, you can upgrade to a paid plan or simply request a limit increase right from your project settings. 2. Delete Unused Agents: Sometimes, clearing out agents you’re no longer using can free up space. If you’re having trouble deleting them, double-check the agent ID and give this command another try: 3. Monitor Limits: It’s a good idea to keep an eye on your current limits. You can find them easily in the LiveKit Cloud dashboard under Settings > Project. If you’d like, I’m here to help you with managing your agents or walking you through increasing those limits. Just let me know! Sources: Quotas and limits | LiveKit Docs
c
while deleting the agent it says no agent found, but on list command it lists 2 entries, and create command says limit reached
t
I'm sorry to hear you're encountering the "agent not found" error when trying to delete an agent, even though it still shows up in the list. Let's walk through a few common reasons this might happen: 1. Agent Already in Deleting State: Sometimes, the agent is in the middle of being deleted. It might still appear in your list but can't be deleted again just yet. You can check its current status with this command:
lk agent status --id AGENT_ID
2. Agent Already Deleted: There are times when the agent has been successfully deleted, but it lingers in the list briefly. If that's the case, no further steps are needed from your side. 3. Project or Authentication Mismatch: It's important to make sure your CLI is set to the correct project. You can verify your default project by running:
lk project list
and double-check that it matches where the agent was originally created. Please feel free to reach out if you'd like me to help you troubleshoot this further—I'm here to assist! Sources: Agent deployment CLI reference | LiveKit Docs | Agent deployment CLI reference | LiveKit Docs
It looks like the "Setting Up" status means the agent is currently being provisioned and isn’t quite ready yet. Because of this, deletion attempts might be temporarily blocked while the setup is underway. Here’s what you can do to move forward: 1. Give it a little time to finish provisioning or time out. You can keep an eye on the status by running:
lk agent status --id CA_EiGYwx3SwpHY
2. When the status updates to something stable like "Running", "Error", or "Build Failed", you can try deleting the agent again with:
lk agent delete CA_EiGYwx3SwpHY
3. If it seems stuck on "Setting Up" for quite a while, it’s a good idea to check the build logs to see if anything’s causing the hold-up:
lk agent logs --log-type=build
Please don’t hesitate to reach out if you have any questions or need a hand with this—I’m here to help! Sources: autocomplete/fish_autocomplete | Agent deployment CLI reference | LiveKit Docs | livekit/livekit_agent_dispatch.pb.go
c
lk agent logs --log-type=build how to specify agent id here
t
To specify the agent ID for the
lk agent logs
command, you can simply use the
--id
flag followed by the agent's ID. For example:
Copy code
lk agent logs --id CA_EiGYwx3SwpHY --log-type build
If you have a
livekit.toml
file in your working directory, the command will automatically use the agent ID defined there by default. Feel free to reach out if you'd like me to help you with anything else! Sources: Agent deployment CLI reference | LiveKit Docs
I'm sorry you're encountering the error "failed to get logs: failed to get current version." This usually means the CLI is having trouble retrieving the current version of the agent to access its logs. It might happen if the agent is in an error state or if there are some deployment or authentication hiccups. Here’s a friendly step-by-step guide to help you troubleshoot: 1. First, check the agent's status by running:
lk agent status --id CA_EiGYwx3SwpHY
If you see "Error" or "Build Failed," it means the agent isn’t working properly at the moment. 2. Next, confirm the agent has a current version with:
lk agent versions --id CA_EiGYwx3SwpHY
3. Double-check that your API key and secret are correct and have the right permissions. 4. Lastly, take a look at the build logs to spot any deployment issues by running:
lk agent logs --log-type=build --id CA_EiGYwx3SwpHY
If you hit any roadblocks or have questions along the way, please don’t hesitate to reach out—I’m here to help! Sources: Agent deployment CLI reference | LiveKit Docs | Log collection | LiveKit Docs | cmd/lk/agent.go | Log collection | LiveKit Docs
c
is there a script we can write which I can trigger when i push code to github so that a deployment pipeline can run instead of manually running commands each time we push changes
t
I'm happy to help you automate your LiveKit agent deployment pipeline using GitHub Actions! Here's a friendly example workflow that triggers deployments whenever you push code to GitHub:
Copy code
name: Deploy LiveKit Agent

on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Setup LiveKit CLI
        run: |
          curl -s https://get.livekit.io/cli | bash

      - name: Authenticate with LiveKit Cloud
        run: |
          lk cloud auth --api-key ${{ secrets.LIVEKIT_API_KEY }} --api-secret ${{ secrets.LIVEKIT_API_SECRET }}

      - name: Deploy Agent
        run: |
          lk agent deploy
        working-directory: ./your-agent-directory
Here’s how you can get started: 1. First, store your LiveKit API key and secret as GitHub repository secrets (
LIVEKIT_API_KEY
and
LIVEKIT_API_SECRET
). 2. Next, update
./your-agent-directory
to point to where your agent’s code lives. 3. Finally, push this workflow file to
.github/workflows/deploy-agent.yml
in your repository. If you have any questions or need help customizing this to fit your setup, please don’t hesitate to reach out—I’m here to support you! Sources: Deploying to production | LiveKit Docs | Agent deployment CLI reference | LiveKit Docs | cerebrium/README.md | .github/workflows/release.yml | .github/workflows/ci.yml
c
also add commands to set project name
t
To help you set the project name in your GitHub Actions workflow, you can simply add this step right before deploying the agent:
Copy code
- name: Set LiveKit Project
  run: |
    lk project set-default "your-project-name"
Here’s how your updated workflow would look:
Copy code
name: Deploy LiveKit Agent

on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Setup LiveKit CLI
        run: |
          curl -s https://get.livekit.io/cli | bash

      - name: Authenticate with LiveKit Cloud
        run: |
          lk cloud auth --api-key ${{ secrets.LIVEKIT_API_KEY }} --api-secret ${{ secrets.LIVEKIT_API_SECRET }}

      - name: Set LiveKit Project
        run: |
          lk project set-default "your-project-name"

      - name: Deploy Agent
        run: |
          lk agent deploy
        working-directory: ./your-agent-directory
Just be sure to replace
"your-project-name"
with your actual LiveKit project name. If you have any questions or need help tweaking this, feel free to reach out—I’m here to help!
c
also how to handle multiple agent deployments and deployment is being done first time
t
To help you smoothly manage multiple agent deployments as well as first-time deployments, here’s a friendly way to extend your GitHub Actions workflow:
Copy code
name: Deploy Multiple LiveKit Agents

on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Setup LiveKit CLI
        run: |
          curl -s https://get.livekit.io/cli | bash

      - name: Authenticate with LiveKit Cloud
        run: |
          lk cloud auth --api-key ${{ secrets.LIVEKIT_API_KEY }} --api-secret ${{ secrets.LIVEKIT_API_SECRET }}

      - name: Set LiveKit Project
        run: |
          lk project set-default "your-project-name"

      - name: Deploy Agent 1
        run: |
          lk agent create --name "agent-1" || lk agent deploy --id "agent-1"
        working-directory: ./agent-1-directory

      - name: Deploy Agent 2
        run: |
          lk agent create --name "agent-2" || lk agent deploy --id "agent-2"
        working-directory: ./agent-2-directory
### Key Points to keep in mind: • First-Time Deployment: We use
lk agent create
to create the agent if it’s not there yet. If it’s already created, the command gracefully falls back to
lk agent deploy
to update it. • Multiple Agents: You can simply add a step for each agent, making sure to give each a unique name and point to its own directory. Just remember to swap out
"your-project-name"
,
"agent-1"
,
"agent-2"
, and the directory paths with your actual project and agent details. If anything feels unclear or you want to dive deeper, please don’t hesitate to ask—I’m here to help!