livekit/rust-sdks

LiveKit realtime and server SDKs for Rust

📹🦀 LiveKit Rust SDK – Real‑time Video, Audio & Data for Rust Apps

What it is – A native Rust client library that talks to the LiveKit server (cloud‑hosted or self‑hosted) using WebRTC. It lets you add low‑latency video calls, audio streams, and arbitrary data channels to any Rust program – from desktop tools to mobile apps and embedded devices.

Key capabilities

  • Connect to a LiveKit room and publish/subscribe to audio, video and data tracks.
  • Support for modern codecs and features: simulcast, SVC (AV1/VP9), hardware‑accelerated H.264/H.265 (VideoToolbox on macOS/iOS, NVENC on Nvidia GPUs, AMD on Linux, Jetson support).
  • Dynacast (only send video when there are subscribers) and optional adaptive streaming.
  • Cross‑platform: Windows, macOS, Linux, iOS, Android.
  • Built on top of Tokio for async operation.

Crates in the repo

Crate Purpose
livekit-api Server‑side REST APIs and JWT token generation.
livekit The main real‑time client SDK (WebRTC handling, track management, events).
livekit-ffi Internal helper for generating language bindings (e.g., for other SDKs).
livekit-protocol Auto‑generated protocol definitions used by the client and server.

Typical workflow

  1. Generate an access token (JWT) with your LiveKit API key/secret using livekit_api::access_token.
  2. Create or join a room via the Room Service API or directly with Room::connect.
  3. Publish tracks – attach a microphone, camera, or file source to the room.
  4. Subscribe to remote tracks – receive audio/video frames via NativeAudioStream / NativeVideoStream and process them asynchronously.
  5. Use data channels for chat, signaling, or custom binary payloads.

Sample code snippets

// 1️⃣ Create a JWT token
let token = livekit_api::access_token::AccessToken::with_api_key(&api_key, &api_secret)
    .with_identity("rust-bot")
    .with_grants(livekit_api::access_token::VideoGrants { room_join: true, room: "my-room".into(), ..Default::default() })
    .to_jwt()?;

// 2️⃣ Connect to a room
let (room, mut events) = livekit::Room::connect(&url, &token).await?;
while let Some(ev) = events.recv().await {
    match ev {
        livekit::RoomEvent::TrackSubscribed { track, .. } => {
            // handle audio/video frames here
        }
        _ => {}
    }
}

Why it matters for AI / agents – The README highlights the LiveKit Agents ecosystem (Python/Node) that bundles speech‑to‑text, large language models, text‑to‑speech, turn detection, etc. The Rust SDK can serve as the transport layer for voice‑AI agents written in Rust, feeding audio into STT models or receiving generated speech via TTS, all in real time.

Getting started

  • Add livekit = "<latest>" (or the specific crate you need) to your Cargo.toml.
  • Ensure the required rustflags from .cargo/config.toml are set (needed for linking the native WebRTC library).
  • Install platform‑specific build tools (e.g., clang‑21 on Ubuntu, -ObjC linker flag on macOS) as described in the Building section.
  • Run one of the example projects (examples/basic_room, examples/play_from_disk, etc.) to see a live video call in action.

Ecosystem links

  • LiveKit server (open‑source WebRTC signaling & media server).
  • Other client SDKs (JS, Swift, Android, Flutter, Unity, C++, Python, Node).
  • Agent SDKs for building voice assistants.
  • Documentation, CLI, and community resources.

Bottom line – If you need real‑time, low‑latency media in a Rust application—whether for video conferencing, live streaming, or powering AI voice agents—the LiveKit Rust SDK provides a production‑grade, cross‑platform foundation built on WebRTC and Tokio.

Related

  • Project
  • Project
  • Project
  • Project
  • Project