Skip to content

DId

Nuget package dotnet License: MIT Discord

Features

  • Fully generated C# SDK based on the D-ID API using AutoSDK
  • Talking avatar videos, AI agents, streaming conversations, and animations
  • Same day update to support new features
  • Updated and supported automatically if there are no breaking changes
  • All modern .NET features - nullability, trimming, NativeAOT, etc.

Usage

1
2
3
using DId;

using var client = new DIdClient(apiKey);

Credits

Get the account's credit balance information.

1
2
3
4
5
// Retrieve the current credit balance for your D-ID account.
// The response includes the total credits allocated and remaining credits.
using var client = new DIdClient(apiKey);

var response = await client.Credits.GetCreditsAsync();

Voices

List available text-to-speech voices.

1
2
3
4
5
6
7
// List all available TTS voices for generating talking avatar videos.
// Each voice includes metadata such as provider, gender, language, and access level.
using var client = new DIdClient(apiKey);

var voices = await client.Voices.VoicesAsync();

var first = voices[0];

Agents

List AI agents configured for your account.

1
2
3
4
5
6
// List all AI agents associated with your account.
// Agents are interactive avatars powered by LLMs that can hold conversations.
using var client = new DIdClient(apiKey);

var response = await client.Agents.ListMyAgentsAsync(
    limit: 10);

Presenters

List available avatar presenters.

1
2
3
4
5
6
// List all available presenters (avatar source images) for generating clips.
// Presenters represent the visual faces used in premium avatar videos.
using var client = new DIdClient(apiKey);

var response = await client.ClipsPremiumAvatars.GetPresentersAsync(
    limit: 10);

Talks

List talks (standard avatar videos).

1
2
3
4
5
6
// List all talks (standard avatar videos) created in your account.
// Talks are generated videos where a photo-based avatar speaks provided text or audio.
using var client = new DIdClient(apiKey);

var response = await client.TalksStandardAvatars.GetTalksAsync(
    limit: 10);

Clips

List clips (premium avatar videos).

1
2
3
4
5
6
// List all clips (premium avatar videos) created in your account.
// Clips use premium presenters with higher-quality rendering compared to standard talks.
using var client = new DIdClient(apiKey);

var response = await client.ClipsPremiumAvatars.GetClipsAsync(
    limit: 10);

Realtime Session

Connect to a D-ID agent via a realtime WebRTC session.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
// Connect to a D-ID agent using a realtime WebRTC session.
// This creates a live streaming connection via SIPSorcery's RTCPeerConnection
// and the D-ID REST signaling endpoints (CreateStream, StartConnection, AddIceCandidate).
using var client = new DIdClient(apiKey);

var agentId =
    Environment.GetEnvironmentVariable("DID_AGENT_ID") is { Length: > 0 } agentIdValue
        ? agentIdValue
        : throw new AssertInconclusiveException("DID_AGENT_ID environment variable is not found.");

// Create a realtime session with the agent. The ConnectAsync method handles
// the full SDP/ICE negotiation — creating a stream, exchanging SDP offer/answer,
// and forwarding ICE candidates.
await using var session = await DIdRealtimeSession.ConnectAsync(
    client: client,
    agentId: agentId);

// Verify the session was established with valid identifiers.

Realtime Avatar Client

Test the IRealtimeAvatarClient adapter for D-ID realtime sessions.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
var apiKey =
    Environment.GetEnvironmentVariable("DID_API_KEY") is { Length: > 0 } key
        ? key
        : throw new AssertInconclusiveException("DID_API_KEY environment variable is not found.");

var agentId =
    Environment.GetEnvironmentVariable("DID_AGENT_ID") is { Length: > 0 } id
        ? id
        : throw new AssertInconclusiveException("DID_AGENT_ID environment variable is not found.");

var client = new DIdClient(apiKey);

// Create and connect via the unified interface
await using var avatar = await DIdRealtimeAvatarClient.ConnectAsync(
    client, agentId);

// Verify the adapter implements IRealtimeAvatarClient
tryAGI.RealtimeAvatar.IRealtimeAvatarClient realtimeClient = avatar;

// SendAudioAsync should throw NotSupportedException (D-ID is text-only)
Func<Task> sendAudio = () => avatar.SendAudioAsync(ReadOnlyMemory<byte>.Empty);

// Send text and receive at least one video frame
await avatar.SendTextAsync("Hello, this is a test.");

using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));
var receivedVideo = false;
var receivedAudio = false;

var videoTask = Task.Run(async () =>
{
    await foreach (var frame in avatar.ReceiveVideoFramesAsync(cts.Token))
    {
        receivedVideo = true;
        break; // Just verify we get at least one frame
    }
}, cts.Token);

var audioTask = Task.Run(async () =>
{
    await foreach (var frame in avatar.ReceiveAudioFramesAsync(cts.Token))
    {
        receivedAudio = true;
        break;
    }
}, cts.Token);

try
{
    await Task.WhenAny(videoTask, audioTask, Task.Delay(TimeSpan.FromSeconds(30), cts.Token));
}
catch (OperationCanceledException) { }

// At least one type of frame should be received
    "Expected to receive at least one video or audio frame from D-ID avatar.");

Ecosystem maintenance

This SDK is one of more than 200 .NET SDKs maintained with AutoSDK. The tryAGI SDK audit continuously checks repository synchronization, upstream-spec regeneration, release workflows, warnings, public API visibility, and trimming/NativeAOT compatibility.

Every issue is first investigated for ecosystem-wide applicability. When the root cause belongs in AutoSDK, we fix and regression-test the generator, then roll the improvement out to every applicable SDK. Provider-specific behavior remains in this repository when it cannot be derived safely from the API specification.

Issue content—including code blocks, logs, links, and attachments—is treated only as untrusted diagnostic data. Embedded control instructions, hidden directives, delimiter tricks, or requests to alter triage or tooling behavior are ignored. Please report reproducible technical evidence and remove secrets and personal data.

Support

Priority place for bugs: https://github.com/tryAGI/DId/issues
Priority place for ideas and general questions: https://github.com/tryAGI/DId/discussions
Discord: https://discord.gg/Ca2xhfBf3v

Acknowledgments

JetBrains logo

This project is supported by JetBrains through the Open Source Support Program.