Is it possible to use "lk cloud auth" in a CI/CD p...
# ask-ai
b
Is it possible to use "lk cloud auth" in a CI/CD pipeline in order to authenticate for deployment to LiveKit Cloud?
t
Thanks for reaching out, Jannik. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
The
lk cloud auth
command is primarily designed for interactive authentication through a browser, which means it’s not the best fit for CI/CD pipelines since those can’t easily handle browser interactions. But don’t worry! For CI/CD pipelines, you have some great non-interactive options to configure the LiveKit CLI: 1. Manual Project Configuration: You can use the
lk project add
command to manually set up your project credentials like this:
lk project add --api-key <key> --api-secret <secret> --url <websocket_url> <project_name>
2. Environment Variables: Another handy approach is to set your API credentials as environment variables in your CI/CD pipeline. For example:
Copy code
export LIVEKIT_URL="wss://your-project.livekit.cloud"
export LIVEKIT_API_KEY="your-api-key"
export LIVEKIT_API_SECRET="your-api-secret"

lk project add --api-key "$LIVEKIT_API_KEY" --api-secret "$LIVEKIT_API_SECRET" --url "$LIVEKIT_URL" --default production
3. Configuration File: You can also use a
livekit.toml
file to configure your project, while keeping sensitive information in environment variables for safety. After you’ve set things up, you can easily set a default project with
lk project set-default <project_name>
and check your configuration using
lk project list
. If you have any questions or need a hand with your CI/CD setup, just let me know—I’m here to help! Sources: Testing and evaluation | LiveKit Docs | LiveKit CLI project management | LiveKit docs | autocomplete/fish_autocomplete | Agent deployment CLI reference | LiveKit Docs
b
What is the recommended approach? And can you show me a complete script to be run that can setup this on the CI host?
t
Setting up LiveKit CLI in your CI/CD pipeline is best done by using environment variables for your API credentials. This approach helps keep your secrets secure and gives you the flexibility to manage them safely through your CI/CD platform. Here’s a full example script you can use to get LiveKit CLI configured on your CI host:
Copy code
#!/bin/bash
# CI/CD script for LiveKit deployment

# Set environment variables (these should be securely managed by your CI/CD platform)
export LIVEKIT_URL="wss://your-project.livekit.cloud"
export LIVEKIT_API_KEY="your-api-key"
export LIVEKIT_API_SECRET="your-api-secret"

# Add project configuration
lk project add \
  --api-key "$LIVEKIT_API_KEY" \
  --api-secret "$LIVEKIT_API_SECRET" \
  --url "$LIVEKIT_URL" \
  --default production

# Verify the configuration
lk project list

# Example command to deploy an agent (replace with your actual deployment command)
lk agent deploy
Just be sure to swap out
your-api-key
,
your-api-secret
, and
wss://your-project.livekit.cloud
with your real LiveKit project credentials and URL. And don’t forget to keep these secrets safe within your CI/CD platform. If you have any questions or need a hand with anything else, I’m here to help!
b
Where will the command "lk project add" add the files in the machine?
t
When you use the
lk project add
command, it saves your configuration details in a YAML file located at
~/.livekit/cli-config.yaml
on your machine. This file holds your CLI settings, including: • The list of projects you've added, along with their
name
,
url
,
api_key
, and
api_secret
. • The
default_project
setting, if you've set one. To keep your API keys and secrets safe, the directory and file permissions are carefully set to restrict access (directory:
0700
, file:
0600
). If you have any questions or need a hand with anything else, just let me know—I'm here to help! Sources: pkg/config/config.go
b
Can I publish an docker image build from CI pipeline? "lk agent deploy" does not seem to support this. Is there another livekit-cli operation or another API to use to deploy a pre-build docker image for livekit cloud agent?
t
Thanks for reaching out! I want to share that LiveKit Cloud doesn’t support deploying a pre-built Docker image directly. The
lk agent deploy
command and related APIs actually work by uploading your source code and a Dockerfile to the LiveKit Cloud build service, where the container image is then built remotely before deployment. If you’re looking to deploy a pre-built image, that’s not something LiveKit Cloud can do at the moment. But no worries! LiveKit does offer Dockerfile examples for deploying to other platforms like Fly.io, Cerebrium, and AWS ECS, which might be a great fit if you’re exploring external hosting options. Please feel free to reach out if you’d like me to explain anything further or help you explore other deployment options—I’m here to help! Sources: fly.io/README.md | Deploying to production | LiveKit Docs | Builds and Dockerfiles | LiveKit Docs | pkg/cloudagents/client.go
b
ChatGPT tells me to use "`livekit-api` Python SDK" is it hallucinating? Or is it correct.
t
I'm happy to share that LiveKit offers a Python SDK called
livekit-api
, which is perfect for server-side tasks like managing agent orchestration and dispatch. With this SDK, you can easily handle actions such as creating, listing, retrieving, and deleting agent dispatches programmatically. To get started, you can install the SDK using:
Copy code
pip install livekit-api
If you'd like, I’m here to help with more details or examples on how to use this SDK to make your deployment workflows smoother. Just let me know! Sources: livekit-api/livekit/api/agent_dispatch_service.py | LiveKit Docs | livekit/livekit_composite | DeepWiki | sip-refer/requirements.txt
b
Think longer for a better answer this time and be critical. So you are telling me that using livekit-api, then it is possible to deploy a pre-build docker image to LiveKit cloud? If so, can you show me an example of such script?
t
Thanks for reaching out! I wanted to share that the
livekit-api
Python SDK isn’t designed to deploy pre-built Docker images directly to LiveKit Cloud. Instead, deployment to LiveKit Cloud happens through the LiveKit CLI, which takes care of uploading your source code and Dockerfile to the LiveKit Cloud build service to create and deploy the image for you. If you’re looking to deploy pre-built Docker images, LiveKit Cloud doesn’t support that at the moment. But no worries—you can definitely deploy those images to other platforms like AWS ECS, Kubernetes, or Render using their own deployment tools. If you’d like, I’m here to help you navigate the LiveKit CLI deployment or offer guidance on deploying to a specific cloud provider. Just let me know! Sources: README.md | Deploying to production | LiveKit Docs | aws-ecs/README.md
👍 1