Deepgram

Updated

Use Deepgram for text-to-speech (TTS) in a Conversational AI Platform agent.

Preview documentation

You're reading the Conversational AI Platform (Preview) docs. Switch to Main.

Deepgram provides low-latency text-to-speech with a wide range of voices, optimized for real-time conversational AI applications.

Sample configuration

The following example shows how to configure Deepgram as the agent's TTS when you create or update an agent. For a complete example, see Create an agent and start a session.

Deepgram supports BYOK only. It isn't available in managed mode. Store your Deepgram API key in a secret set, and refer to it from the agent. For details, see Use your own provider keys.

from agora_agent import Agent, DeepgramTTS, secret_ref

# client is your configured Agora client
agent = (
    Agent(client=client)
    .with_stt(...)  # configure your ASR vendor
    .with_llm(...)  # configure your LLM vendor
    .with_tts(
        DeepgramTTS(
            api_key=secret_ref("support_prod", "deepgram"),
            base_url="wss://api.deepgram.com/v1/speak",
            model="aura-2-thalia-en",
            sample_rate=24000,
        )
    )
)
import { Agent, DeepgramTTS, secretRef } from 'agora-agents';

// client is your configured Agora client
const agent = new Agent({ client })
  .withStt(/* configure your ASR vendor */)
  .withLlm(/* configure your LLM vendor */)
  .withTts(
    new DeepgramTTS({
      apiKey: secretRef('support_prod', 'deepgram'),
      baseUrl: 'wss://api.deepgram.com/v1/speak',
      model: 'aura-2-thalia-en',
      sampleRate: 24000,
    }),
  );
// client is your configured Agora client
sampleRate := vendors.SampleRate24kHz
agent := agentkit.NewAgent(client).
	WithStt( /* configure your ASR vendor */ ).
	WithLlm( /* configure your LLM vendor */ ).
	WithTts(vendors.NewDeepgramTTS(vendors.DeepgramTTSOptions{
		APIKey:     agentkit.SecretRef("support_prod", "deepgram"),
		BaseURL:    "wss://api.deepgram.com/v1/speak",
		Model:      "aura-2-thalia-en",
		SampleRate: &sampleRate,
	}))

Set credential.mode to byok and credential.fields.api_key to a reference to your Deepgram API key. In the following example, the key is stored as deepgram in the support_prod set:

"tts": {
  "credential": {
    "mode": "byok",
    "fields": {
      "api_key": "$secrets.support_prod.deepgram"
    }
  },
  "vendor": "deepgram",
  "url": "wss://api.deepgram.com/v1/speak",
  "params": {
    "model": "aura-2-thalia-en",
    "sample_rate": 24000
  }
}

Key parameters

The tts block takes the following fields. In the SDKs, DeepgramTTS sets them from its options.

tts
vendorstring
required

Set to deepgram.

credentialobject
required

Set mode to byok and fields.api_key to a $secrets.<set>.<key> reference to your Deepgram API key. Get your API key from the Deepgram Console.

urlstring
optional

The WebSocket URL for the Deepgram streaming API. Defaults to wss://api.deepgram.com/v1/speak.

paramsobject
required
modelstring
required

The identifier of the TTS model to use. See Deepgram voices and languages.

sample_ratenumber
optional

The audio sampling rate in Hz.

Caution

The parameters listed on this page are validated for use with the Conversational AI Platform. Required parameters must be provided as documented. Any additional parameters in params are passed through directly to Deepgram without validation. For a full list of supported options, refer to the Deepgram TTS documentation.

This integration is fully supported for use with the Conversational AI Platform. While it has completed functional validation, it is newer to the platform, and additional provider-specific edge cases may be identified as usage scales across a broader range of applications and workloads.