Install & Compatibility
Where this runs
tested against v1.2.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 30.9MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 4.7s · import 0.000s · 34MB
31MB installed
● package 31MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
RoomServiceClient
✓ from livekit import RoomServiceClient
✗ from livekit.api import RoomServiceClient
This quickstart demonstrates how to create a LiveKit room and generate an access token for a participant using `livekit-api`. It uses environment variables for LiveKit host and credentials for security. The operations are asynchronous and should be run within an asyncio event loop.
import os
import asyncio
from livekit import api
host = os.environ.get("LIVEKIT_HOST", "http://localhost:7880")
api_key = os.environ.get("LIVEKIT_API_KEY", "devkey")
api_secret = os.environ.get("LIVEKIT_API_SECRET", "secret")
async def main():
if not api_key or not api_secret:
print("LIVEKIT_API_KEY and LIVEKIT_API_SECRET must be set.")
return
# Initialize LiveKit client
svc = api.RoomServiceClient(host, api_key, api_secret)
room_name = "my-test-room"
try:
room = await svc.create_room(
api.CreateRoomRequest(
name=room_name,
empty_timeout=60 * 10, # 10 minutes
)
)
print(f"Room '{room.name}' created.")
except api.ApiException as e:
if e.status == 409: # Room already exists
print(f"Room '{room_name}' already exists.")
else:
raise
# Generate an access token for a participant
token = api.AccessToken(api_key, api_secret) \
.with_identity("user1") \
.with_name("Test User") \
.with_grants(api.VideoGrants(room_join=True, room=room_name)) \
.to_jwt()
print(f"Access Token: {token}")
if __name__ == "__main__":
asyncio.run(main())
Debug
Known issues
gotchaThe `livekit-api` library is built on `asyncio`. All service methods return awaitable objects. Calling these methods without `await` or outside an `async` context will lead to runtime errors.fixEnsure all interactions with `livekit-api` services and methods are properly `await`ed within an `async` function, which is then run using `asyncio.run()`.
affects: All versions
gotchaAccess tokens generated by `api.AccessToken` require explicit grants (e.g., `api.VideoGrants`) to define what actions a participant can perform. Incorrectly configured grants are a common cause of 'permission denied' errors.fixAlways review `api.VideoGrants` (or other grant types like `api.RecorderGrants`) when generating tokens. Ensure `room_join=True` and any other necessary permissions (e.g., `can_publish`, `can_subscribe`) are set for the intended participant role.
affects: All versions
gotchaHardcoding `LIVEKIT_HOST`, `LIVEKIT_API_KEY`, and `LIVEKIT_API_SECRET` directly in your code is a significant security risk and makes deployments brittle. These are sensitive credentials.fixAlways retrieve sensitive credentials using environment variables (e.g., `os.environ.get('LIVEKIT_API_KEY')`) or a secure configuration management system. affects: All versions
breakingSignificant changes in the underlying LiveKit server API or protocol can lead to unexpected behavior or API breakage if the `livekit-api` SDK version is not kept reasonably up-to-date with the server version.fixRegularly update `livekit-api` to the latest stable version. Consult the LiveKit server release notes and documentation for any required SDK version compatibility updates.
affects: All versions, especially older SDKs with newer servers
Upgrade
Version history
1.2.1latest on PyPI · released Aug 27, 2026
Audit
Dependencies
No dependency data recorded yet.