how can i have different env vars when running the...
# ask-ai
o
how can i have different env vars when running the agent on dev mode and deploying to livekit cloud?
t
Thanks for reaching out, fernando. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Managing different environment variables for development and LiveKit Cloud deployment can feel a bit tricky, but I’m here to help you through it! Here’s a simple way to approach it: • Use Environment-Specific Files: For development, you can create local files like
.env
or
.env.local
to hold your dev-specific settings. Just make sure these files are added to
.gitignore
so your secrets stay safe and private. • Separate LiveKit Projects: It’s a great idea to have separate LiveKit Cloud projects for dev, staging, and production. That way, each one has its own
LIVEKIT_URL
,
LIVEKIT_API_KEY
, and
LIVEKIT_API_SECRET
, keeping everything nicely organized. • Environment Flags: You can use a custom variable like
DEV=1
in your development environment. This helps your app know when it’s in dev mode, so you can tweak things like agent names or behaviors accordingly. • LiveKit CLI for Deployment: When it’s time to deploy to LiveKit Cloud, the LiveKit CLI is your friend! It lets you securely inject environment variables and manage secrets without any hassle. Following these steps will help keep your configurations secure and well-separated across environments. If you’d like me to walk you through any part in more detail, just let me know—I’m happy to help! Sources: README.md | Secrets management | LiveKit Docs | Deploying to custom environments | LiveKit Docs | complex-agents/role-playing/role_playing_frontend/.env.example
o
what command do i need to use? lk agent deploy
t
I'm happy to help you with deploying an agent using the LiveKit CLI! The correct command to use is:
Copy code
lk agent deploy [options] [working-dir]
Here are a few examples to guide you through: • To deploy from your current directory:
lk agent deploy
• To deploy from a subdirectory called `./agent`:
lk agent deploy ./agent
• If you want to deploy with inline secrets:
lk agent deploy --secrets OPENAI_API_KEY=sk-xxx,GOOGLE_API_KEY=ya29.xxx
• Or deploy using secrets from a file:
lk agent deploy --secrets-file ./secrets.env
• You can also deploy with both inline secrets and a secrets file (just a heads-up, inline secrets will take precedence):
lk agent deploy --secrets OPENAI_API_KEY=sk-xxx --secrets-file ./secrets.env
Just make sure your working directory includes a
livekit.toml
and a
Dockerfile
. If you run into any bumps or want me to walk you through any step, please don’t hesitate to ask—I’m here to help! Sources: Agent deployment CLI reference | LiveKit docs | Voice AI quickstart | LiveKit docs