Connect to a D-ID agent via a realtime WebRTC session.
This example assumes using DId; is in scope and apiKey contains your DId API key.
1 2 3 4 5 6 7 8 9101112131415161718
// 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).usingvarclient=newDIdClient(apiKey);varagentId=Environment.GetEnvironmentVariable("DID_AGENT_ID")is{Length:>0}agentIdValue?agentIdValue:thrownewAssertInconclusiveException("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.awaitusingvarsession=awaitDIdRealtimeSession.ConnectAsync(client:client,agentId:agentId);// Verify the session was established with valid identifiers.