how to setup lk commandline to refer local project...
# ask-ai
a
how to setup lk commandline to refer local project/server
t
Thanks for reaching out, Aditya. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm happy to help you set up the LiveKit command-line tool (CLI) to connect to your local project or server. Here are a few friendly ways you can do this: Method 1: Add a Project Configuration • You can use the
lk project add
command to add your local server as a project like this:
Copy code
lk project add my-local-project \
--url http://localhost:7880 \
--api-key <my-api-key> \
--api-secret <my-api-secret> \
--default
This will set your local server as the default project. You can easily check it with:
Copy code
lk project list
Method 2: Use Environment Variables • If you prefer, just set these environment variables in your shell:
Copy code
export LIVEKIT_URL=http://localhost:7880
export LIVEKIT_API_KEY=<your-api-key>
export LIVEKIT_API_SECRET=<your-api-secret>
The CLI will then automatically use these to connect to your local server. Method 3: Use Command-Line Flags • For quick, one-time commands, you can specify the server URL, API key, and secret right in the command:
Copy code
lk room join --url http://localhost:7880 --api-key <key> --api-secret <secret> --identity test-user my-room
Feel free to pick whichever method feels easiest for you. And if you have any questions or need a hand with anything else, just let me know—I’m here to help! Sources: livekit-agents/livekit/agents/cli/cli.py | Development Environment Setup | livekit/livekit_composite | DeepWiki | LiveKit CLI project management | LiveKit Docs | cmd/lk/agent.go | Accepting incoming calls | LiveKit Docs
a
and how to use this in your agent?
t
Thanks for reaching out! Could you help me understand a bit more about what you mean by using the CLI configuration in an agent? Are you looking to integrate the LiveKit CLI with a particular application, script, or maybe an automation process? I’d love to hear more about your use case so I can assist you better.
a
I want to integrate the project to my locallive so that the agents joins the room as the user
t
I'm here to help you integrate your project with LiveKit so your agents can join a room as participants. Let's walk through the steps together: 1. Set up the Agent Worker • Start by creating an agent worker using the LiveKit Agents framework. This worker will register with the LiveKit server and patiently wait for dispatch requests. When a job, like a new room, is created, the worker will launch a subprocess that joins the room as a participant. 2. Configure Agent Dispatch • Automatic Dispatch: Agents will be dispatched automatically to every new room in your LiveKit project, making things seamless. • Explicit Dispatch: If you prefer more control, you can set the
agent_name
in
RoomConfiguration
when generating a participant’s access token. Here’s a friendly example in Node.js:
Copy code
import { RoomAgentDispatch, RoomConfiguration } from '@livekit/protocol';
import { AccessToken } from 'livekit-server-sdk';

const at = new AccessToken();
at.identity = 'my_participant';
at.addGrant({ roomJoin: true, room: 'my-room' });
at.roomConfig = new RoomConfiguration({
  agents: [new RoomAgentDispatch({ agentName: 'groq-agent' })],
});
const token = await at.toJwt();
3. Agent Behavior and Media Processing • Once dispatched, your agent will join the room as a participant. It can process audio and video streams, generate responses using LLMs, and interact with users in real time through SDKs and plugins. It’s quite powerful! 4. Alternative Dispatch Methods • API: You can programmatically dispatch an agent to a room using the
AgentDispatchService
. • CLI: Alternatively, use the
lk dispatch create
command along with
--agent-name
and
--room
flags for quick dispatching. If you have any questions or need a hand with any of these steps, please don’t hesitate to reach out. I’m here to support you every step of the way! Sources: LiveKit Agents | LiveKit Docs | examples/avatar_agents/anam/agent_worker.py | Docs::Agents | AI Agents Framework | livekit/livekit_composite | DeepWiki | Anatomy of an Agent | LiveKit Docs