steep-balloon-41261
08/24/2025, 7:24 AMtall-airline-16756
08/24/2025, 7:24 AMtall-airline-16756
08/24/2025, 7:25 AMRemoveParticipant method from the RoomServiceClient in LiveKit's server SDKs. This will disconnect the participant and trigger a Disconnected event for them.
Here’s a quick look at how you can do this with different SDKs:
• Node.js: import { RoomServiceClient } from 'livekit-server-sdk';
const roomService = new RoomServiceClient(
<LIVEKIT_SERVER_URL>,
<API_KEY>,
<API_SECRET>
);
await roomService.removeParticipant('room-name', 'participant-identity');
• Python: from livekit.api import RoomService, RoomParticipantIdentity
room_service = RoomService(
url=<LIVEKIT_SERVER_URL>,
api_key=<API_KEY>,
api_secret=<API_SECRET>
)
await room_service.remove_participant(
Remove: RoomParticipantIdentity(
room='room-name',
identity='participant-identity'
)
)
• Go: package main
import (
"context"
"github.com/livekit/server-sdk-go"
"github.com/livekit/protocol/livekit"
)
client := lksdk.NewRoomServiceClient(<LIVEKIT_SERVER_URL>, <API_KEY>, <API_SECRET>)
_, err := client.RemoveParticipant(context.Background(), &livekit.RoomParticipantIdentity{
Room: "room-name",
Identity: "participant-identity",
})
You can also remove a participant using the LiveKit CLI like this:
lk room participants remove PARTICIPANT_ID --room ROOM_NAME
Just a heads up: removing a participant doesn’t invalidate their access token, so if their token is still valid, they could join again. To keep them out, you might want to generate tokens with a shorter TTL or avoid issuing new tokens for that participant.
Sources: Managing participants | LiveKit Docs | packages/livekit-server-sdk/src/RoomServiceClient.tscreamy-match-85520
08/24/2025, 7:26 AMtall-airline-16756
08/24/2025, 7:26 AMRemoveParticipant API, which you can call programmatically within your agent logic. For instance, in the livepaint agent, there's a method like _kick_player that uses self._lkapi.room.remove_participant to gently disconnect a participant by sending them a graceful disconnect RPC before removing them.
The RemoveParticipant API is available in several server SDKs, including:
• Kotlin SDK: RoomServiceClient.removeParticipant(roomName, identity)
• Node.js SDK: RoomServiceClient.removeParticipant(room, identity)
When you remove someone using this API, they’ll be disconnected from the room, and a Disconnected event will fire with the reason PARTICIPANT_REMOVED. Keep in mind, they can rejoin the room unless you add extra restrictions.
Just a heads-up: this action needs roomAdmin permissions and is usually done from a trusted backend service or agent.
Sources: src/main/kotlin/io/livekit/server/RoomServiceClient.kt | packages/livekit-server-sdk/src/RoomServiceClient.ts | agent/game_host.py | Connecting to LiveKit | LiveKit Docs | protobufs/livekit_room.protocreamy-match-85520
08/24/2025, 7:26 AMtall-airline-16756
08/24/2025, 7:27 AM_lkapi isn’t directly explained in the docs. But usually, it’s a private or internal variable that points to an instance of the LiveKitAPI class from the LiveKit Python SDK. This class is your go-to for working with LiveKit services like room management, egress, ingress, SIP, and agent dispatch.
For example, you’d typically see lkapi set up like this:
from livekit import api
lkapi = api.LiveKitAPI("https://my-project.livekit.cloud")
If _lkapi is meant to be something else, just let me know! A bit more context would help clear things up.
Sources: livekit-api/livekit/api/agent_dispatch_service.pycreamy-match-85520
08/24/2025, 7:28 AMtall-airline-16756
08/24/2025, 7:29 AMListParticipants API method from the RoomServiceClient. Just a heads-up, you’ll need roomAdmin permissions and the room name as input. This method will give you a list of ParticipantInfo objects, which have all the details about each participant in the room.
Here’s a quick rundown on how you can do this with different SDKs:
• Node.js SDK: Use listParticipants(room: string), which returns a Promise that resolves to an array of ParticipantInfo.
• Python SDK: Use list_participants(list: ListParticipantsRequest), which returns a ListParticipantsResponse containing the participants.
• Kotlin SDK: Use listParticipants(roomName: String), which returns a Call object with the list of ParticipantInfo.
• Go SDK: Use ListParticipants(context.Background(), &livekit.ListParticipantsRequest{Room: roomName}).
• Rust SDK: Use list_participants(&self, room: &str), which returns a Result with a vector of ParticipantInfo.
• LiveKit CLI: Use the listParticipants command, which shows participant identity, state, and track count.
The ParticipantInfo includes handy info like identity, session ID (SID), connection state, metadata, join timestamp, and published tracks.
Sources: protobufs/livekit_room.proto | packages/livekit-server-sdk/src/RoomServiceClient.ts | livekit-api/livekit/api/room_service.py | src/main/kotlin/io/livekit/server/RoomServiceClient.kt | Managing participants | LiveKit Docscreamy-match-85520
08/24/2025, 7:30 AMtall-airline-16756
08/24/2025, 7:30 AMlist_participants method from the LiveKit server SDKs. For instance, in a Python agent, you’d use the LiveKitAPI client to call this method. Here’s a simple example to help you out:
response = await self.job_context.api.room.list_participants(
api.ListParticipantsRequest(room=room_name)
)
participants = response.participants
The response gives you details about each participant, including:
• identity: The participant’s unique ID
• name: The name they’re showing
• state: Their current connection status
• joined_at: When they joined the room
• metadata: Any extra info tied to the participant
• sid: Their session ID
Just a heads-up: you’ll need roomAdmin permissions to use this, as it talks to the RoomService API. And if you’re using other SDKs like Go, Node.js, or the LiveKit CLI, you’ll find similar support there too.
Sources: Managing participants | LiveKit Docs | packages/livekit-server-sdk/src/RoomServiceClient.ts | cmd/lk/room.go | livekit-api/livekit/api/room_service.py | telephony/sip_lifecycle.pycreamy-match-85520
08/24/2025, 7:33 AMtall-airline-16756
08/24/2025, 7:33 AMfrom livekit import api
room_service = api.RoomService()
• Node.js: const { RoomServiceClient } = require('livekit-server-sdk');
const roomService = new RoomServiceClient(LIVEKIT_SERVER_URL, API_KEY, API_SECRET);
• Go: import (
"github.com/livekit/server-sdk-go"
)
roomService := lksdk.NewRoomServiceClient(LIVEKIT_SERVER_URL, API_KEY, API_SECRET)
Just swap out LIVEKIT_SERVER_URL, API_KEY, and API_SECRET with your actual LiveKit server URL and credentials. If you hit any bumps or want me to walk you through anything else, just give me a shout—I’m here to help!creamy-match-85520
08/24/2025, 7:41 AMtall-airline-16756
08/24/2025, 7:41 AMRoom object itself doesn’t have a remove_participant method. Instead, you’ll want to use the RoomService API from the LiveKit server SDKs to remove a participant. It’s a bit different, but totally manageable with the RoomService client.
Here’s a little example in Python to help you out:
from livekit import api
room_service = api.RoomService()
await room_service.remove_participant(
api.RoomParticipantIdentity(
room="room-name",
identity="participant-identity"
)
)
Just remember to use the RoomService client instead of the Room object for this task. If anything’s unclear or you want to chat more about it, I’m here to help!
Sources: livekit-api/src/services/room.rs | rpc/participant.pb.go | packages/livekit-server-sdk/src/RoomServiceClient.ts | livekit-api/livekit/api/room_service.py | lib/livekit/room_service_client.rbcreamy-match-85520
08/24/2025, 7:47 AMtall-airline-16756
08/24/2025, 7:47 AMRoomService isn’t directly available as an attribute of livekit.api. Instead, you’ll want to create an instance of the LiveKitAPI class, which then gives you access to the room service to manage rooms and participants.
Here’s a quick example of how to set up and use RoomService the right way:
from livekit import api
# Initialize LiveKitAPI (make sure your environment variables for URL, API key, and secret are set)
lkapi = api.LiveKitAPI()
room_service = lkapi.room # This is how you get the RoomService
After that, you can use room_service to do things like remove participants, list rooms, or update room details. For instance, to remove a participant:
await room_service.remove_participant(
api.RoomParticipantIdentity(
room="room-name",
identity="participant-identity"
)
)
If you have any questions or want me to walk you through more examples, just let me know—I’m here to help!
Sources: examples/api.py | Managing rooms | LiveKit Docscreamy-match-85520
08/24/2025, 7:49 AMtall-airline-16756
08/24/2025, 7:49 AMRuntimeError: no running event loop pops up because there isn’t an active asyncio event loop running at the moment. To fix this, you just need to make sure an event loop is up and running before you create your LiveKitAPI object.
The easiest way to handle this is by using asyncio.run(), which takes care of the event loop for you. Here’s a quick example:
from livekit import api
import asyncio
async def main():
lkapi = api.LiveKitAPI("https://my-project.livekit.cloud")
room_info = await lkapi.room.create_room(api.CreateRoomRequest(name="my-room"))
print(room_info)
await lkapi.aclose()
asyncio.run(main())
This way, the event loop is set up just right for LiveKitAPI to work smoothly. If you want me to walk you through it or have any other questions, just let me know—I’m here to help!
Sources: examples/video-stream/video_play.py | stream_audio.py