busy-spoon-62776
07/14/2025, 7:04 AMtall-airline-16756
07/14/2025, 7:04 AMbusy-spoon-62776
07/14/2025, 7:05 AMtall-airline-16756
07/14/2025, 7:05 AMpip install livekit-api
2. Configure your credentials. Either set the following environment variables:Or pass credentials directly when initializing the API object.
◦ `LIVEKIT_API_KEY`: your API key
◦ `LIVEKIT_API_SECRET`: your API secret
◦ `LIVEKIT_URL`: your server URL (e.g., <https://your-project.livekit.cloud>
or <wss://your-project.livekit.cloud>
)
1. Connect to the server and perform actions, such as creating a room, with code like:`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())`
The Server API uses asyncio
and functions must be called in an async context. The SDK can read credentials from the environment or you can supply them programmatically. Be sure to close the client with await lkapi.aclose()
when done.
For more specific usage, let me know which LiveKit service or operation you need to perform.
Sources: livekit-api/livekit/api/livekit_api.py | complex-agents/nova-sonic/nova-sonic-form-agent/.env.exampletall-airline-16756
07/14/2025, 7:05 AMpip install livekit-api
2. Set your environment variables:
◦ `LIVEKIT_API_KEY`: your API key
◦ `LIVEKIT_API_SECRET`: your API secret
◦ `LIVEKIT_URL`: your LiveKit server URL (e.g. <https://your-project.livekit.cloud>
)
1. Create a connection in your Python code:
from livekit import api
lkapi = api.LiveKitAPI("<https://your-project.livekit.cloud>")
2. Use the connection to access LiveKit services, like room or egress management:
# Example: Creating a room
import asyncio
async def main():
room_info = await lkapi.room.create_room(api.CreateRoomRequest(name="my-room"))
print(room_info)
await lkapi.aclose()
asyncio.run(main())
The SDK uses asyncio
, so make sure to run your API calls inside an asynchronous context. The SDK will use your environment variables by default, but you can also pass API credentials directly in your code.
Let me know if you need an example for a specific operation.