
The D-ID Agents SDK embeds an agent you built in D-ID Studio or with the Agents API into a web application. Create an AgentManager for the agent, connect(), then chat() to have the agent answer with its own LLM or speak() to have it say exactly what you give it. The SDK opens the video session (WebRTC, or LiveKit for Expressive agents), keeps the chat transcript and retries a failed connection.
Please note: This SDK is designed for front-end development only. The creation of Agents and Knowledge bases should be handled through the Agents API or directly within the D-ID Studio.
Version 3.0 is a breaking release. Upgrading from 2.x? Read the migration guide.
npm i @d-id/client-sdk
You need an agent id and a client key. Both come from the agent's </> Embed snippet in the D-ID Studio agents gallery, which is also where you list the domains the agent may be used from — see Getting started.
import * as sdk from '@d-id/client-sdk';
const videoElement = document.getElementById('agent-video') as HTMLVideoElement;
const agentManager = await sdk.createAgentManager('agt_fumf1234', {
auth: { type: 'key', clientKey: 'YOUR_CLIENT_KEY' },
callbacks: {
onSrcObjectReady: stream => (videoElement.srcObject = stream),
onNewMessage: messages => console.log(messages[messages.length - 1]?.content),
},
});
await agentManager.connect();
await agentManager.speak({ type: 'text', input: "Hi! I'm Alice!" });
await agentManager.chat('What is the distance to the moon?');
// Both resolve when the request is accepted, not when the agent has spoken.
window.addEventListener('beforeunload', () => void agentManager.disconnect());
The full API reference — every method, callback, option and type, generated from the source on each release — is at sdk.d-id.com. Start with createAgentManager(), AgentManager, AgentManagerCallbacks and, on Talks (V2) and Clips (V3) agents, StreamOptions.
The guides:
chat() and speak(), disconnecting.onError, and what to log.A working sample project in Vanilla JavaScript and Vite is in the demo repository.
<video> element you provide.import resolves to the ES module; require and a <script> tag resolve to the UMD bundle.@types to install.createAgentManager() needs a browser.Questions, bug reports and documentation issues are welcome as GitHub issues. The product documentation lives at docs.d-id.com.