{"id":15724229,"url":"https://github.com/livekit/python-sdks","last_synced_at":"2026-02-16T23:48:03.755Z","repository":{"id":172888320,"uuid":"643530496","full_name":"livekit/python-sdks","owner":"livekit","description":"LiveKit real-time and server SDKs for Python","archived":false,"fork":false,"pushed_at":"2026-02-09T03:20:29.000Z","size":3147,"stargazers_count":328,"open_issues_count":38,"forks_count":113,"subscribers_count":14,"default_branch":"main","last_synced_at":"2026-02-09T08:47:53.237Z","etag":null,"topics":["agents","ai","python","real-time","webrtc"],"latest_commit_sha":null,"homepage":"https://docs.livekit.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/livekit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":"NOTICE","maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-05-21T13:10:58.000Z","updated_at":"2026-02-09T06:11:27.000Z","dependencies_parsed_at":"2023-09-21T23:56:39.612Z","dependency_job_id":"beb08c43-acc6-43d2-89c5-eae271d2ad1f","html_url":"https://github.com/livekit/python-sdks","commit_stats":{"total_commits":261,"total_committers":21,"mean_commits":"12.428571428571429","dds":0.5172413793103448,"last_synced_commit":"6ee37168a1f5a3a7bd9e5e471fac9d3ea4269fe3"},"previous_names":["livekit/client-sdk-python"],"tags_count":160,"template":false,"template_full_name":null,"purl":"pkg:github/livekit/python-sdks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/livekit%2Fpython-sdks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/livekit%2Fpython-sdks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/livekit%2Fpython-sdks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/livekit%2Fpython-sdks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/livekit","download_url":"https://codeload.github.com/livekit/python-sdks/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/livekit%2Fpython-sdks/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29417938,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-13T06:24:03.484Z","status":"ssl_error","status_checked_at":"2026-02-13T06:23:12.830Z","response_time":78,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agents","ai","python","real-time","webrtc"],"created_at":"2024-10-03T22:15:38.548Z","updated_at":"2026-02-16T23:48:03.750Z","avatar_url":"https://github.com/livekit.png","language":"Python","readme":"\u003c!--BEGIN_BANNER_IMAGE--\u003e\n\n\u003cpicture\u003e\n  \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"/.github/banner_dark.png\"\u003e\n  \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"/.github/banner_light.png\"\u003e\n  \u003cimg style=\"width:100%;\" alt=\"The LiveKit icon, the name of the repository and some sample code in the background.\" src=\"https://raw.githubusercontent.com/livekit/python-sdks/main/.github/banner_light.png\"\u003e\n\u003c/picture\u003e\n\n\u003c!--END_BANNER_IMAGE--\u003e\n\n[![pypi-v](https://img.shields.io/pypi/v/livekit.svg?label=livekit)](https://pypi.org/project/livekit/)\n[![pypi-v](https://img.shields.io/pypi/v/livekit-api.svg?label=livekit-api)](https://pypi.org/project/livekit-api/)\n\n# 📹🎙️🐍 Python SDK for LiveKit\n\n\u003c!--BEGIN_DESCRIPTION--\u003e\nUse this SDK to add realtime video, audio and data features to your Python app. By connecting to \u003ca href=\"https://livekit.io/\"\u003eLiveKit\u003c/a\u003e Cloud or a self-hosted server, you can quickly build applications such as multi-modal AI, live streaming, or video calls with just a few lines of code.\n\u003c!--END_DESCRIPTION--\u003e\n\nThis repo contains two packages\n\n- [livekit](https://pypi.org/project/livekit/): Real-time SDK for connecting to LiveKit as a participant\n- [livekit-api](https://pypi.org/project/livekit-api/): Access token generation and server APIs\n\n## Using Server API\n\n```shell\n$ pip install livekit-api\n```\n\n### Generating an access token\n\n```python\nfrom livekit import api\nimport os\n\n# will automatically use the LIVEKIT_API_KEY and LIVEKIT_API_SECRET env vars\ntoken = api.AccessToken() \\\n    .with_identity(\"python-bot\") \\\n    .with_name(\"Python Bot\") \\\n    .with_grants(api.VideoGrants(\n        room_join=True,\n        room=\"my-room\",\n    )).to_jwt()\n```\n\n### Creating a room\n\nRoomService uses asyncio and aiohttp to make API calls. It needs to be used with an event loop.\n\n```python\nfrom livekit import api\nimport asyncio\n\nasync def main():\n    lkapi = api.LiveKitAPI(\"https://my-project.livekit.cloud\")\n    room_info = await lkapi.room.create_room(\n        api.CreateRoomRequest(name=\"my-room\"),\n    )\n    print(room_info)\n    results = await lkapi.room.list_rooms(api.ListRoomsRequest())\n    print(results)\n    await lkapi.aclose()\n\nasyncio.run(main())\n```\n\n### Using other APIs\n\nServices can be accessed via the LiveKitAPI object.\n\n```python\nlkapi = api.LiveKitAPI(\"https://my-project.livekit.cloud\")\n\n# Room Service\nroom_svc = lkapi.room\n\n# Egress Service\negress_svc = lkapi.egress\n\n# Ingress Service\ningress_svc = lkapi.ingress\n\n# Sip Service\nsip_svc = lkapi.sip\n\n# Agent Dispatch\ndispatch_svc = lkapi.agent_dispatch\n\n# Connector Service\nconnector_svc = lkapi.connector\n```\n\n## Using Real-time SDK\n\n```shell\n$ pip install livekit\n```\n\n### Connecting to a room\n\nsee [room_example](examples/room_example.py) for full example\n\n```python\nfrom livekit import rtc\n\nasync def main():\n    room = rtc.Room()\n\n    @room.on(\"participant_connected\")\n    def on_participant_connected(participant: rtc.RemoteParticipant):\n        logging.info(\n            \"participant connected: %s %s\", participant.sid, participant.identity)\n\n    async def receive_frames(stream: rtc.VideoStream):\n        async for frame in stream:\n            # received a video frame from the track, process it here\n            pass\n\n    # track_subscribed is emitted whenever the local participant is subscribed to a new track\n    @room.on(\"track_subscribed\")\n    def on_track_subscribed(track: rtc.Track, publication: rtc.RemoteTrackPublication, participant: rtc.RemoteParticipant):\n        logging.info(\"track subscribed: %s\", publication.sid)\n        if track.kind == rtc.TrackKind.KIND_VIDEO:\n            video_stream = rtc.VideoStream(track)\n            asyncio.ensure_future(receive_frames(video_stream))\n\n    # By default, autosubscribe is enabled. The participant will be subscribed to\n    # all published tracks in the room\n    await room.connect(URL, TOKEN)\n    logging.info(\"connected to room %s\", room.name)\n\n    # participants and tracks that are already available in the room\n    # participant_connected and track_published events will *not* be emitted for them\n    for identity, participant in room.remote_participants.items():\n        print(f\"identity: {identity}\")\n        print(f\"participant: {participant}\")\n        for tid, publication in participant.track_publications.items():\n            print(f\"\\ttrack id: {publication}\")\n```\n\n### RPC\n\nPerform your own predefined method calls from one participant to another.\n\nThis feature is especially powerful when used with [Agents](https://docs.livekit.io/agents), for instance to forward LLM function calls to your client application.\n\n#### Registering an RPC method\n\nThe participant who implements the method and will receive its calls must first register support:\n\n```python\n@room.local_participant.register_rpc_method(\"greet\")\nasync def handle_greet(data: RpcInvocationData):\n    print(f\"Received greeting from {data.caller_identity}: {data.payload}\")\n    return f\"Hello, {data.caller_identity}!\"\n```\n\nIn addition to the payload, your handler will also receive `response_timeout`, which informs you the maximum time available to return a response. If you are unable to respond in time, the call will result in an error on the caller's side.\n\n#### Performing an RPC request\n\nThe caller may then initiate an RPC call like so:\n\n```python\ntry:\n  response = await room.local_participant.perform_rpc(\n    destination_identity='recipient-identity',\n    method='greet',\n    payload='Hello from RPC!'\n  )\n  print(f\"RPC response: {response}\")\nexcept Exception as e:\n  print(f\"RPC call failed: {e}\")\n```\n\nYou may find it useful to adjust the `response_timeout` parameter, which indicates the amount of time you will wait for a response. We recommend keeping this value as low as possible while still satisfying the constraints of your application.\n\n## Using local media devices\n\nThe `MediaDevices` class provides a high-level interface for working with local audio input (microphone) and output (speakers) devices. It's built on top of the `sounddevice` library and integrates seamlessly with LiveKit's audio processing features.  In order to use `MediaDevices`, you must have the `sounddevice` library installed in your local Python environment, if it's not available, `MediaDevices` will not work.\n\n### Capturing microphone input\n\n```python\nfrom livekit import rtc\n\n# Create a MediaDevices instance\ndevices = rtc.MediaDevices()\n\n# Open the default microphone with audio processing enabled\nmic = devices.open_input(\n    enable_aec=True,          # Acoustic Echo Cancellation\n    noise_suppression=True,   # Noise suppression\n    high_pass_filter=True,    # High-pass filter\n    auto_gain_control=True    # Automatic gain control\n)\n\n# Use the audio source to create a track and publish it\ntrack = rtc.LocalAudioTrack.create_audio_track(\"microphone\", mic.source)\nawait room.local_participant.publish_track(track)\n\n# Clean up when done\nawait mic.aclose()\n```\n\n### Playing audio to speakers\n\n```python\n# Open the default output device\nplayer = devices.open_output()\n\n# Add remote audio tracks to the player (typically in a track_subscribed handler)\n@room.on(\"track_subscribed\")\ndef on_track_subscribed(track: rtc.Track, publication, participant):\n    if track.kind == rtc.TrackKind.KIND_AUDIO:\n        player.add_track(track)\n\n# Start playback (mixes all added tracks)\nawait player.start()\n\n# Clean up when done\nawait player.aclose()\n```\n\n### Full duplex audio (microphone + speakers)\n\nFor full duplex audio with echo cancellation, open the input device first (with AEC enabled), then open the output device. The output player will automatically feed the APM's reverse stream for effective echo cancellation:\n\n```python\ndevices = rtc.MediaDevices()\n\n# Open microphone with AEC\nmic = devices.open_input(enable_aec=True)\n\n# Open speakers - automatically uses the mic's APM for echo cancellation\nplayer = devices.open_output()\n\n# Publish microphone\ntrack = rtc.LocalAudioTrack.create_audio_track(\"mic\", mic.source)\nawait room.local_participant.publish_track(track)\n\n# Add remote tracks and start playback\nplayer.add_track(remote_audio_track)\nawait player.start()\n```\n\n### Listing available devices\n\n```python\ndevices = rtc.MediaDevices()\n\n# List input devices\ninput_devices = devices.list_input_devices()\nfor device in input_devices:\n    print(f\"{device['index']}: {device['name']}\")\n\n# List output devices  \noutput_devices = devices.list_output_devices()\nfor device in output_devices:\n    print(f\"{device['index']}: {device['name']}\")\n\n# Get default device indices\ndefault_input = devices.default_input_device()\ndefault_output = devices.default_output_device()\n```\n\nSee [publish_mic.py](examples/local_audio/publish_mic.py) and [full_duplex.py](examples/local_audio/full_duplex.py) for complete examples.\n\n\n#### Errors\n\nLiveKit is a dynamic realtime environment and calls can fail for various reasons.\n\nYou may throw errors of the type `RpcError` with a string `message` in an RPC method handler and they will be received on the caller's side with the message intact. Other errors will not be transmitted and will instead arrive to the caller as `1500` (\"Application Error\"). Other built-in errors are detailed in `RpcError`.\n\n## Examples\n\n- [Facelandmark](https://github.com/livekit/python-sdks/tree/main/examples/face_landmark): Use mediapipe to detect face landmarks (eyes, nose ...)\n- [Basic room](https://github.com/livekit/python-sdks/blob/main/examples/basic_room.py): Connect to a room\n- [Publish hue](https://github.com/livekit/python-sdks/blob/main/examples/publish_hue.py): Publish a rainbow video track\n- [Publish wave](https://github.com/livekit/python-sdks/blob/main/examples/publish_wave.py): Publish a sine wave\n\n## Getting help / Contributing\n\nPlease join us on [Slack](https://livekit.io/join-slack) to get help from our devs / community members. We welcome your contributions(PRs) and details can be discussed there.\n\n\u003c!--BEGIN_REPO_NAV--\u003e\n\u003cbr/\u003e\u003ctable\u003e\n\u003cthead\u003e\u003ctr\u003e\u003cth colspan=\"2\"\u003eLiveKit Ecosystem\u003c/th\u003e\u003c/tr\u003e\u003c/thead\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\u003ctd\u003eLiveKit SDKs\u003c/td\u003e\u003ctd\u003e\u003ca href=\"https://github.com/livekit/client-sdk-js\"\u003eBrowser\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/client-sdk-swift\"\u003eiOS/macOS/visionOS\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/client-sdk-android\"\u003eAndroid\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/client-sdk-flutter\"\u003eFlutter\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/client-sdk-react-native\"\u003eReact Native\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/rust-sdks\"\u003eRust\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/node-sdks\"\u003eNode.js\u003c/a\u003e · \u003cb\u003ePython\u003c/b\u003e · \u003ca href=\"https://github.com/livekit/client-sdk-unity\"\u003eUnity\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/client-sdk-unity-web\"\u003eUnity (WebGL)\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/client-sdk-esp32\"\u003eESP32\u003c/a\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003eServer APIs\u003c/td\u003e\u003ctd\u003e\u003ca href=\"https://github.com/livekit/node-sdks\"\u003eNode.js\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/server-sdk-go\"\u003eGolang\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/server-sdk-ruby\"\u003eRuby\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/server-sdk-kotlin\"\u003eJava/Kotlin\u003c/a\u003e · \u003cb\u003ePython\u003c/b\u003e · \u003ca href=\"https://github.com/livekit/rust-sdks\"\u003eRust\u003c/a\u003e · \u003ca href=\"https://github.com/agence104/livekit-server-sdk-php\"\u003ePHP (community)\u003c/a\u003e · \u003ca href=\"https://github.com/pabloFuente/livekit-server-sdk-dotnet\"\u003e.NET (community)\u003c/a\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003eUI Components\u003c/td\u003e\u003ctd\u003e\u003ca href=\"https://github.com/livekit/components-js\"\u003eReact\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/components-android\"\u003eAndroid Compose\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/components-swift\"\u003eSwiftUI\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/components-flutter\"\u003eFlutter\u003c/a\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003eAgents Frameworks\u003c/td\u003e\u003ctd\u003e\u003ca href=\"https://github.com/livekit/agents\"\u003ePython\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/agents-js\"\u003eNode.js\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/agent-playground\"\u003ePlayground\u003c/a\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003eServices\u003c/td\u003e\u003ctd\u003e\u003ca href=\"https://github.com/livekit/livekit\"\u003eLiveKit server\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/egress\"\u003eEgress\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/ingress\"\u003eIngress\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/sip\"\u003eSIP\u003c/a\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003eResources\u003c/td\u003e\u003ctd\u003e\u003ca href=\"https://docs.livekit.io\"\u003eDocs\u003c/a\u003e · \u003ca href=\"https://github.com/livekit-examples\"\u003eExample apps\u003c/a\u003e · \u003ca href=\"https://livekit.io/cloud\"\u003eCloud\u003c/a\u003e · \u003ca href=\"https://docs.livekit.io/home/self-hosting/deployment\"\u003eSelf-hosting\u003c/a\u003e · \u003ca href=\"https://github.com/livekit/livekit-cli\"\u003eCLI\u003c/a\u003e\u003c/td\u003e\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c!--END_REPO_NAV--\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flivekit%2Fpython-sdks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flivekit%2Fpython-sdks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flivekit%2Fpython-sdks/lists"}