i defined this in .env GLOBAL OPTIONS: --url URL...
# ask-ai
r
i defined this in .env GLOBAL OPTIONS: --url URL URL to LiveKit instance (default: "http://localhost:7880") [$LIVEKIT_URL] --api-key KEY Your KEY [$LIVEKIT_API_KEY] --api-secret SECRET Your SECRET [$LIVEKIT_API_SECRET] but when doing lk room list it's using cloud !
✅ 1
t
Thanks for reaching out, simo.dev. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I can help with that. You're saying you added LIVEKIT vars to a
.env
but
lk room list
still uses LiveKit Cloud. A few likely causes and quick checks: 1.
.env
is not automatically loaded by your shell. Source it or export variables: ◦ Run
source .env
(or
export LIVEKIT_URL=...
etc.), then run
lk room list
. ◦ Or prefix the command:
Copy code
LIVEKIT_URL=http://localhost:7880 LIVEKIT_API_KEY=your-key LIVEKIT_API_SECRET=your-secret lk room list
1. CLI precedence: command flags override environment vars, and environment vars override stored config. If you previously authenticated to Cloud, stored credentials in
~/.livekit/
may be used. To force local: ◦ Use flags:
lk room list --url http://localhost:7880 --api-key your-key --api-secret your-secret
1. Verify what the shell actually sees: ◦
echo $LIVEKIT_URL
◦
echo $LIVEKIT_API_KEY
If those echo the local values and it still hits cloud, tell me: • The outputs of the two echo commands above • Your OS / shell (bash, zsh, fish, Windows) I’ll guide the next step. , with interactive elements
r
all values printed ex
$LIVEKIT_URL ...
t
Thanks — since your environment variables print correctly but the CLI still hits Cloud, let's check a few things that can override them. 1. Confirm the URL scheme: what does
echo $LIVEKIT_URL
show exactly (include protocol, e.g.,
http://
or
ws://
)? 2. Check for higher-priority config: ◦ Do you have a
livekit.toml
in the current directory? ◦ Do you have a
~/.livekit/
config (list it with
ls -la ~/.livekit
)? 1. Try forcing the local instance once to see behavior:
Copy code
lk room list --url http://localhost:7880 --api-key your-key --api-secret your-secret
1. If that works, remove or update stored cloud creds: ◦ Run
lk logout
or rename/remove
~/.livekit/
(e.g.,
mv ~/.livekit ~/.livekit.bak
) and retry. Tell me the exact output of
echo $LIVEKIT_URL
, whether
lk room list --url ...
succeeds, and the results of
ls -la ~/.livekit
. I'll guide the next step. Sources: Troubleshooting 401 Unauthorized and Token Errors | LiveKit, with interactive elements
r
i want to switch the project inside the cmd ex: lk room list Using default project [localhost] for example in this cmd i want to use cloud project
t
Got it — you want to run
lk room list
against the cloud project while your default is localhost. You can do that per command without changing env or config. 1. Run the command with cloud credentials to override the default:
Copy code
lk room list --url wss://your-project.livekit.cloud --api-key YOUR_CLOUD_API_KEY --api-secret YOUR_CLOUD_API_SECRET
1. If you prefer to authenticate once and make the cloud project available as a default, run:
Copy code
lk cloud auth
This links the cloud project to the CLI (it may change your default project). If you want, tell me: • the cloud project's URL (example form:
wss://...livekit.cloud
) or • whether you’d like a short alias/workflow to switch frequently and I’ll suggest a script or shell alias. Sources: Voice AI quickstart | LiveKit Documentation, with interactive elements
r
no i mean like lk room list --project cloud
t
Thanks — I understand you want a simple
--project cloud
-style switch in the
lk
CLI. The CLI does not provide a
--project
flag. To target a different project for a single command you must either: • Pass the project's connection info on the command line:
Copy code
lk room list --url wss://your-project.livekit.cloud --api-key YOUR_CLOUD_API_KEY --api-secret YOUR_CLOUD_API_SECRET
• Or authenticate the cloud project once so it becomes a CLI context:
Copy code
lk cloud auth
(which can change your default project) If you want a shorter workflow, I can help you create: • shell aliases (e.g.,
alias lk-cloud="lk room list --url ... --api-key ... --api-secret ..."
), or • a small script to switch profiles and run
lk
commands. Which option would you like help with (alias, script, or auth flow)? , with interactive elements