Livekit.Server.Sdk.Dotnet
| Livekit.Rtc.Dotnet
Use this SDK to add realtime video, audio and data features to your .NET app. By connecting to LiveKit 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.
This repository contains two complementary .NET packages for different LiveKit use cases:
Server-side management and authentication SDK for LiveKit. Use it to interact with all LiveKit server APIs, create access tokens, and handle webhooks.
-
Target Framework:
netstandard2.0
Real-time communication SDK for .NET server applications. Use it to connect to LiveKit as a server-side participant, and to publish and subscribe to audio, video, and data.
-
Target Framework:
netstandard2.1 -
Included Native Binaries: Precompiled for Windows, Linux, macOS (x64 & ARM64)
dotnet add package Livekit.Server.Sdk.Dotnetusing Livekit.Server.Sdk.Dotnet;
// Generate access token
var token = new AccessToken("api-key", "api-secret")
.WithIdentity("user-123")
.WithName("John Doe")
.WithGrants(new VideoGrants { RoomJoin = true, Room = "my-room" });
var jwt = token.ToJwt();
// Manage rooms via API
var roomClient = new RoomServiceClient("https://my.livekit.instance", "api-key", "api-secret");
var rooms = await roomClient.ListRooms(new ListRoomsRequest());dotnet add package Livekit.Rtc.Dotnetusing LiveKit.Rtc;
// Connect to room as a participant
var room = new Room();
// Add room event handlers
room.ParticipantConnected += (sender, participant) =>
{
Console.WriteLine($"[ParticipantConnected] {participant.Identity}}");
};
await room.ConnectAsync("wss://my.livekit.instance", token);
// Publish audio track
var audioSource = new AudioSource(48000, 1);
var audioTrack = LocalAudioTrack.Create("audio", audioSource);
await room.LocalParticipant!.PublishTrackAsync(audioTrack);
// Handle events
room.TrackSubscribed += (sender, e) => {
Console.WriteLine($"Subscribed to track: {e.Track.Sid}");
};git clone --recurse-submodules https://github.com/pabloFuente/livekit-server-sdk-dotnet.git
cd livekit-server-sdk-dotnetNote: The
--recurse-submodulesflag is required to clone the necessary LiveKit protocol submodules.
# Build both packages
dotnet build
# Run tests for Server SDK
dotnet test LivekitApi.Tests/LivekitApi.Tests.csproj
# Run tests for RTC SDK
dotnet test LivekitRtc.Tests/LivekitRtc.Tests.csproj
# Build and install both packages locally
./build_local.shReleases are automated through GitHub Actions thanks to the publish workflow. Both packages Livekit.Server.Sdk.Dotnet and Livekit.Rtc.Dotnet can be released independently. Checkout how to do so:
To upgrade the version of the livekit/protocol Git submodule:
cd protocol
git fetch --all
git checkout <COMMIT_HASH/TAG/BRANCH>
cd ..
git add protocol
git commit -m "Update livekit/protocol to <VERSION>"
git pushThen it may be necessary to re-generate the proto files to actually reflect the changes in livekit/protocol:
./generate_proto.shThen try packaging the SDK to test the validity of the changes in the protocol:
dotnet pack -c Debug -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkgThis command may throw an error if there are breaking changes in the protocol, as the SDK is configured in strict mode for package validation. The way to overcome these breaking changes is running the package command with option -p:GenerateCompatibilitySuppressionFile=true to generate file CompatibilitySuppressions.xml:
dotnet pack -c Debug -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg -p:GenerateCompatibilitySuppressionFile=trueThis compatibility suppression file will allow packaging and publishing the SDK even with breaking changes. Once the new version is available in NuGet, the only thing left is to update in file LivekitApi.csproj property <PackageValidationBaselineVersion>X.Y.Z</PackageValidationBaselineVersion> to the new version (so the new reference for breaking changes is this new version), and delete CompatibilitySuppressions.xml (as it is no longer needed). Workflow publish.yml automatically does this as last step.
Built with ❤️ by pabloFuente
| LiveKit Ecosystem | |
|---|---|
| LiveKit SDKs | Browser · iOS/macOS/visionOS · Android · Flutter · React Native · Rust · Node.js · Python · Unity · Unity (WebGL) · ESP32 · .NET (community) |
| Server APIs | Node.js · Golang · Ruby · Java/Kotlin · Python · Rust · PHP (community) · .NET (community) |
| UI Components | React · Android Compose · SwiftUI · Flutter |
| Agents Frameworks | Python · Node.js · Playground |
| Services | LiveKit server · Egress · Ingress · SIP |
| Resources | Docs · Example apps · Cloud · Self-hosting · CLI |