aloof-ability-9744
12/31/2025, 10:59 AMtall-airline-16756
12/31/2025, 10:59 AMtall-airline-16756
12/31/2025, 11:00 AMaloof-ability-9744
12/31/2025, 11:00 AMtall-airline-16756
12/31/2025, 11:00 AMpip install livekit-api livekit
Step 2 — Generate a room token (server-side)
1. Use livekit-api.AccessToken to create a JWT. Keep api_secret only on the server.
from livekit.api import AccessToken, VideoGrants
api_key = "your-api-key"
api_secret = "your-api-secret"
room_name = "my-room"
identity = "user-123" # unique participant id
token = (
AccessToken(api_key, api_secret)
.with_identity(identity)
.with_grants(
VideoGrants(
room_join=True,
room=room_name,
can_publish=True,
can_subscribe=True,
can_publish_data=True,
)
)
)
jwt_token = token.to_jwt()
print("Generated token:", jwt_token)
Send jwt_token securely to the client (e.g., via HTTPS endpoint).
Step 3 — Join the room (client-side, Python)
1. Use the livekit client to connect with the token.
from livekit import Room
import asyncio
async def main():
room = Room()
websocket_url = "<wss://your-livekit-instance.com>" # replace with your LiveKit URL
await room.connect(websocket_url, jwt_token)
print("Connected to room:", room.name)
# Optionally create and publish local tracks (camera/mic)
# from livekit.room import RoomUtils
# local_tracks = await RoomUtils.create_local_tracks(video=True, audio=True)
# await room.local_participant.publish_track(local_tracks[0]) # video
# await room.local_participant.publish_track(local_tracks[1]) # audio
await asyncio.Event().wait() # keep running
asyncio.run(main())
Notes and tips
• Never expose api_secret to clients. Generate tokens server-side and return only the JWT.
• Use unique identity per participant.
• Adjust grant flags (can_publish, can_subscribe, room) to control permissions.
• Replace <wss://your-livekit-instance.com> with your LiveKit server URL (cloud or self-hosted).
If you want, tell me:
• whether you’re using LiveKit Cloud or a self-hosted instance, and
• whether the client is a desktop Python client or embedding this in a web app
and I’ll give the exact connection URL and any small changes you’ll need.
Sources: Python SDKs | livekit/livekit_composite | DeepWiki | An open source stack for real-time multimodal AIaloof-ability-9744
12/31/2025, 11:06 AMtall-airline-16756
12/31/2025, 11:06 AMtoken and calls LiveKit client connect with it. Only use for short-lived tokens and trusted recipients.
If you want, tell me:
• which platform you’re targeting (web, Python desktop, iOS, Android), and
• whether you prefer the page-to-request-token model or an embedded-token link,
and I’ll give a concrete example (server endpoint and client code) you can copy.aloof-ability-9744
01/02/2026, 11:23 AMtall-airline-16756
01/02/2026, 11:24 AMaloof-ability-9744
01/02/2026, 11:25 AMtall-airline-16756
01/02/2026, 11:25 AMaloof-ability-9744
01/02/2026, 11:27 AMtall-airline-16756
01/02/2026, 11:27 AMaloof-ability-9744
01/02/2026, 11:27 AMtall-airline-16756
01/02/2026, 11:27 AM