用途:在 JavaScript/TypeScript 项目中构建交互式语音助手,实现用户说话、智能体思考并以语音回应的全双工对话。Deepgram 负责托管 STT、思考(LLM)与 TTS 的编排。仅需转写可用 deepgram-js-speech-to-text;仅需合成可用 deepgram-js-text-to-speech。
主要能力:通过 client.agent.v1.createConnection() 建立连接,connect() 并 waitForOpen() 后需首先发送 sendSettings({ type: "Settings", ... }),配置 audio 输入输出编码与采样率、agent 的 language、listen/think/speak 提供方及 greeting。支持运行时更新:sendUpdatePrompt、sendUpdateThink、sendUpdateSpeak、sendInjectUserMessage、sendInjectAgentMessage、sendFunctionCallResponse、sendKeepAlive、sendMedia。入站事件包括 Welcome、SettingsApplied、ConversationText、UserStartedSpeaking、AgentThinking、FunctionCallRequest、AgentStartedSpeaking、AgentAudioDone、Warning、Error 及音频数据。
使用方式:认证使用 DeepgramClient 并设置 environment: DeepgramEnvironment.Agent。示例见 examples/09-voice-agent.ts 等;可用 client.agent.v1.settings.think.models.list() 发现支持的 think 模型。
适用场景:需要实时语音对话、对话内函数/工具调用、由 Deepgram 托管完整语音编排的应用。
限制:设置消息必须最先发送;音频与 JSON 事件共用一个消息流,需按 typeof data 与 data.type 分支处理;长时间会话需定期发送 KeepAlive(示例为每 5 秒);编码与采样率两端需一致;函数调用请求以数组到达,需检查 data.functions[] 后用 sendFunctionCallResponse 回复;当前 SDK 未暴露持久化 Voice Agent 配置的 CRUD 接口,需要存储配置时须使用原始 HTTP 或其他 SDK 表面。
跨语言产品知识可安装 npx skills add deepgram/skills。