LiveKit Agents 接入 D-ID 实时虚拟形象

该指南说明如何在 LiveKit Agents 的语音会话中集成 D-ID 实时虚拟形象插件,涵盖 Python 与 Node.js 的安装、API 密钥配置、会话启动顺序,以及仅支持 expressive 类型 v4 形象的创建方式。

LiveKit docs › 建設代理 › 型号 › 虚拟造型 › D-ID --- # D- ID 实时神通集成指南 > 如何为LiveKit Agents使用D-ID虚拟异形插件. 可在下列网址查阅: - [x] 节点.js - [x] Python 键 ## 概览 [D-ID's](https://www.d-id.com/) 实时Avatars允许您创建自己的可参与直播,交互式对话的Avatar. 您可以在您的语音AI app中使用开源 D- ID 集成 LiveKit Agents. [视频:阿凡达:米娅体育](https://static.livekit.io/video/docs-avatar-demos/demo-did-expressive.mp4) ### 安装 **Python 键**: ```shell uv add "livekit-agents[did]~=1.8" ``` --- **节点.js**: ```shell pnpm add @livekit/agents-plugin-did ``` ### 认证 D- ID 插件需要有一个 [D- ID API 键](https://docs.d-id.com/reference/basic-authentication). 设定 `DID_API_KEY` 在您的帐号中 `.env` 文档。 ### 使用量 使用插件在一个 `AgentSession`。例如,您可以在 [语音 AI 快速启动](https://docs.livekit.io/agents/start/voice-ai.md). **Python 键**: ```python from livekit import agents from livekit.agents import AgentServer, AgentSession from livekit.plugins import did server = AgentServer() @server.rtc_session(agent_name="my-agent") async def my_agent(ctx: agents.JobContext): session = AgentSession( # ... stt, llm, tts, etc. ) avatar = did.AvatarSession( agent_id="...", # ID of the D-ID avatar to use. See "Avatar setup" for details. ) # Start the avatar and wait for it to join await avatar.start(session, room=ctx.room) # Start your agent session with the user await session.start( # ... room, agent, room_options, etc.... ) ``` --- **节点.js**: ```typescript import { voice } from '@livekit/agents'; import * as did from '@livekit/agents-plugin-did'; const session = new voice.AgentSession({ // ... stt, llm, tts, etc. }); const avatar = new did.AvatarSession({ agentId: "...", // ID of the D-ID avatar to use. See "Avatar setup" for details. }); // Start the avatar and wait for it to join await avatar.start(session, room); // Start your agent session with the user await session.start( // ... room, agent, room_options, etc. ); ``` 预览图像 。 [代理主控台](https://docs.livekit.io/testing/agent-console.md) 或前端 [启动程序](https://docs.livekit.io/agents/start/frontend.md#starter-apps) 即你建造的。 ### 阿凡达设置 此插件只支持 v4 avatars( 类型: expressive) 。 要获取代理 ID, 请创建新代理 : ```shell curl -X POST https://api.d-id.com/agents \ -H "Authorization: Basic <YOUR_API_KEY>" \ -H "Content-Type: application/json" \ -d '{ "presenter": { "type": "expressive", "presenter_id": "public_mia_elegant@avt_TJ0Tq5" }, "preview_name": "My Expressive Agent" }' ``` 使用来自响应的代理 ID 作为 `agent_id` 参数在插件中。 ### 参数 本节介绍一些可用的参数。 [插件引用](https://docs.livekit.io/reference/python/livekit/plugins/did/index.html.md#livekit.plugins.did.AvatarSession) 用于完整列出所有可用的参数。 - **`agent_id`** _(字符串)_: D- ID avatar 的 ID 要使用. 见 [阿凡达设置](#avatar-setup) 详细情况。 - **`avatar_participant_name`** _(字符串)_(可选) - 默认 : `d-id-avatar-agent`:用于阿凡达的参与者名称. ## 追加资源 以下资源提供更多信息,介绍使用D-ID与LiveKit Agents. - **[D - ID API 文档](https://docs.d-id.com/docs/quickstart)**: D- ID的API文档. - **[代理主控台](https://docs.livekit.io/testing/agent-console.md)**:一个测试您的阿凡达代理的虚拟工作台. - **[前端启动程序](https://docs.livekit.io/agents/start/frontend.md#starter-apps)**: 备用前端应用,并有Avatar支持. --- 此文件在2026 - 12-01T06:20:17.019Z. 本文件的最新版本见: [https://docs.livekit.io/agents/models/avatar/plugins/did.md](https://docs.livekit.io/agents/models/avatar/plugins/did.md). 要探索所有 LiveKit 文档,请参见 [页:1](https://docs.livekit.io/llms.txt).

查看原始来源