Install LiveKit CLI
Install the LiveKit CLI with Homebrew:
brew install livekit-cli
lk
is LiveKit's suite of CLI utilities. It lets you conveniently access server APIs, create tokens, and generate test traffic all from your command line. For more details, refer to the docs in the livekit-cli
GitHub repo.
Add a project
You must link a LiveKit project to the LiveKit CLI to use it. This can be a project with LiveKit Cloud or a self-hosted LiveKit server instance.
To link a LiveKit Cloud project, run the following command then follow the instructions in your browser to authenticate.
lk cloud auth
To add a different project, see the Project management guide.
Generate access token
A participant creating or joining a LiveKit room needs an access token to do so. For now, let’s generate one via CLI:
lk token create \--api-key <PROJECT_KEY> --api-secret <PROJECT_SECRET> \--join --room test_room --identity test_user \--valid-for 24h
Alternatively, you can generate tokens from your project's dashboard.
Test with LiveKit Meet
If you're testing a LiveKit Cloud instance, you can find your Project URL
(it starts with wss://
) in the project settings.
Use a sample app, LiveKit Meet, to preview your new LiveKit instance. Enter the token you previously generated in the "Custom" tab. Once connected, your microphone and camera will be streamed in realtime to your new LiveKit instance (and any other participant who connects to the same room)!
If interested, here's the full source for this example app.
Simulating another publisher
One way to test a multi-user session is by generating a second token (ensure --identity
is unique), opening our example app in another browser tab and connecting to the same room.
Another way is to use the CLI as a simulated participant and publish a prerecorded video to the room. Here's how:
lk room join \--url <PROJECT_SECURE_WEBSOCKET_ADDRESS> \--api-key <PROJECT_API_KEY> --api-secret <PROJECT_SECRET_KEY> \--publish-demo --identity bot_user \my_first_room
This command publishes a looped demo video to my-first-room
. Due to how the file was encoded, expect a short delay before your browser has sufficient data to render frames.