lively-coat-10905
07/22/2025, 5:25 AMtall-airline-16756
07/22/2025, 5:25 AMtall-airline-16756
07/22/2025, 5:25 AMfrom livekit import api
from livekit.agents import get_job_context
async def hangup_call():
ctx = get_job_context()
if ctx is None:
# Not running in a job context
return
await ctx.api.room.delete_room(
api.DeleteRoomRequest(
room=ctx.room.name,
)
)
If you only want to remove a specific participant from the call, you can use the remove_participant method instead:
async def hangup(self):
try:
await self.api.room.remove_participant(api.RoomParticipantIdentity(
room=self.room.name,
identity=self.participant.identity,
))
except Exception as e:
# It’s possible the user has already hung up
<http://logger.info|logger.info>(f"received error while ending call: {e}")
For a complete call termination, deleting the room is the preferred approach as it ensures all participants are disconnected.
Sources: Making calls using SIP | LiveKit Docslively-coat-10905
07/22/2025, 5:29 AMtall-airline-16756
07/22/2025, 5:30 AM