deepgram-go-voice-agent

โดย deepgram

ใช้เมื่อเขียนหรือตรวจสอบโค้ด Go ใน repo นี้ที่รันเซสชัน Deepgram Voice Agent ผ่าน WebSockets รวมถึงการตั้งค่าระหว่างรันไทม์ การอัปเดตพรอมต์ การพูด...

npx skills add https://github.com/deepgram/deepgram-go-sdk --skill deepgram-go-voice-agent

Using Deepgram Voice Agent from the Go SDK

When to use this product

Use this skill for live Voice Agent runtime flows in pkg/client/agent.

  • open an agent WebSocket session
  • send initial settings
  • stream audio
  • react to agent events and function-call messages
  • update prompt/speak settings during the session

Use a different skill when:

  • you only need STT (deepgram-go-speech-to-text)
  • you only need TTS (deepgram-go-text-to-speech)
  • you need management/admin endpoints (deepgram-go-management-api)

Authentication

Set DEEPGRAM_API_KEY before opening the agent connection.

export DEEPGRAM_API_KEY="your_api_key"

Quick start

package main

import (
	"context"
	"fmt"
	"log"

	agentws "github.com/deepgram/deepgram-go-sdk/v3/pkg/api/agent/v1/websocket"
	agent "github.com/deepgram/deepgram-go-sdk/v3/pkg/client/agent"
)

func main() {
	if err := run(); err != nil {
		log.Fatal(err)
	}
}

func run() error {
	ctx := context.Background()
	settings := agent.NewSettingsConfigurationOptions()
	handler := agentws.NewDefaultChanHandler()

	conn, err := agent.NewWSUsingChanWithDefaults(ctx, settings, handler)
	if err != nil {
		return err
	}
	defer conn.Stop()

	if ok := conn.Connect(); !ok {
		return fmt.Errorf("connect failed")
	}

	conn.Start()

	// The handler receives Welcome, ConversationText, FunctionCallRequest, and audio events.
	// Stream audio frames, watch agent events, and respond to function calls as needed.
	return nil
}

Key parameters

  • constructors
    • agent.NewSettingsConfigurationOptions()
    • agent.NewWSUsingChanWithDefaults(...)
    • agent.NewWSUsingChan(...)
  • runtime methods
    • Connect, Start, ProcessMessage, Stream, Write, KeepAlive
    • reconnect helpers like AttemptReconnect and error handling helpers in the WS client
  • message and event payloads in pkg/api/agent/v1/websocket/interfaces/types.go
    • UpdatePrompt
    • UpdateSpeak
    • InjectAgentMessage
    • InjectUserMessage
    • FunctionCallResponse
    • server events such as WelcomeResponse, ConversationTextResponse, FunctionCallRequestResponse, AgentStartedSpeakingResponse, AgentAudioDoneResponse

API reference (layered)

  1. In-repo reference
    • README.md
    • pkg/client/agent/client.go
    • pkg/client/agent/v1/websocket/client_channel.go
    • pkg/client/agent/v1/websocket/new_using_chan.go
    • pkg/client/interfaces/v1/types-agent.go
    • pkg/api/agent/v1/websocket/interfaces/types.go
  2. OpenAPI
    • https://developers.deepgram.com/openapi.yaml
  3. AsyncAPI
    • https://developers.deepgram.com/asyncapi.yaml
  4. Context7
    • /llmstxt/developers_deepgram_llms_txt
  5. Product docs
    • https://developers.deepgram.com/reference/voice-agent/voice-agent
    • https://developers.deepgram.com/docs/voice-agent
    • https://developers.deepgram.com/docs/configure-voice-agent
    • https://developers.deepgram.com/docs/voice-agent-message-flow

Gotchas

  1. This repo exposes live Voice Agent runtime over WebSockets, not a persisted configuration-management surface.
  2. Keep audio streaming, event handling, and any function-call response loop running concurrently.
  3. Follow the example session setup instead of inventing your own event names; the repo already defines concrete message structs.
  4. Channel-based constructors require an AgentMessageChan handler; events are routed there rather than pulled from the client.
  5. Use defer conn.Stop(), and remember that Connect() returns bool rather than error.

Example files in this repo

  • examples/agent/websocket/simple/main.go
  • examples/agent/websocket/no_mic/main.go
  • examples/agent/websocket/arbitrary_keys/main.go
  • tests/unit_test/agent/agent_speak_test.go

Central product skills

For cross-language Deepgram product knowledge — the consolidated API reference, documentation finder, focused runnable recipes, third-party integration examples, and MCP setup — install the central skills:

npx skills add deepgram/skills

This SDK ships language-idiomatic code skills; deepgram/skills ships cross-language product knowledge (see api, docs, recipes, examples, starters, setup-mcp).

Skills เพิ่มเติมจาก deepgram

deepclaw-voice
deepgram
ตั้งค่าการโทรศัพท์ไปยัง OpenClaw โดยใช้ Deepgram Voice Agent API
official
deepgram-js-audio-intelligence
deepgram
Use when writing or reviewing JavaScript/TypeScript in this repo that calls Deepgram audio analytics overlays on `/v1/listen` - summarize, topics, intents,…
official
deepgram-js-conversational-stt
deepgram
Use when writing or reviewing JavaScript/TypeScript in this repo that calls Deepgram Conversational STT v2 / Flux (`/v2/listen`) for turn-aware streaming…
official
deepgram-dotnet-conversational-stt
deepgram
ใช้เมื่อประเมิน ขยาย หรือเขียนโค้ด C# สำหรับการแปลงคำพูดเป็นข้อความแบบสนทนา การถอดเสียงแบบเรียลไทม์สไตล์ Flux หรือสตรีมมิ่งแบบผลัดกันพูดใน...
official
deepgram-dotnet-management-api
deepgram
ใช้เมื่อเขียนหรือตรวจสอบโค้ด C# ใน repo นี้ที่เรียกใช้ Deepgram Management APIs สำหรับโปรเจกต์ โมเดล คีย์ สมาชิก คำเชิญ การใช้งาน ยอดคงเหลือ และ...
official
deepgram-dotnet-speech-to-text
deepgram
ใช้เมื่อเขียนหรือตรวจสอบโค้ด C# ใน repo นี้ที่เรียกใช้ Deepgram Speech-to-Text สำหรับการถอดเสียงแบบบันทึกไว้หรือแบบสด ครอบคลุม…
official
deepgram-dotnet-text-intelligence
deepgram
Use when writing or reviewing C# code in this repo that calls Deepgram Text Intelligence / Read (`/read`) for sentiment, summarization, topic detection, and…
official
deepgram-dotnet-text-to-speech
deepgram
Use when writing or reviewing C# code in this repo that calls Deepgram Text-to-Speech. Covers `ClientFactory.CreateSpeakRESTClient()` with `ToStream` /…
official