Skip to main content

Module agent

Module agent 

Source
Expand description

Voice Agent (/v1/agent/converse) types.

It contains:

  • endpoint::Endpoint — custom LLM/TTS endpoint URL + headers.
  • aws_credentials::AwsCredentials — credential block shared by AWS Bedrock (Think) and AWS Polly (Speak).
  • audio — AudioConfig, AudioInput, AudioOutput, encodings, and container for the audio block on Settings.
  • listen — AgentListenSettings and the V1/V2 Deepgram STT provider sub-types.
  • think — ThinkSettings and the five Think provider variants (OpenAI, Anthropic, AWS Bedrock, Google, Groq).
  • speak — SpeakSettings and the five Speak provider variants (Deepgram, ElevenLabs, Cartesia, OpenAI, AWS Polly).
  • history — HistoryMessage (conversation + function-call history) used by agent.context.messages[] and the server-emitted History event.
  • settings — top-level SettingsMessage and the AgentConfig oneOf (Inline(InlineAgentConfig) vs. Saved(Uuid)).
  • messages — the remaining client-to-server messages (UpdateListen, UpdateSpeak, UpdateThink, UpdatePrompt, InjectUserMessage, InjectAgentMessage, FunctionCallResponse, KeepAlive, ForceEndTurn) plus the ClientMessage discriminated union over all ten.
  • response — every server-emitted JSON event (Welcome, SettingsApplied, ConversationText, UserStartedSpeaking, AgentThinking, FunctionCallRequest, FunctionCallCancelled, AgentStartedSpeaking, AgentAudioDone, Error, Warning, History, LatencyReport, ListenUpdated, PromptUpdated, SpeakUpdated, ThinkUpdated, InjectionRefused, FunctionCallResponse) plus an Unknown catch-all for forward compatibility, all unified under the response::AgentResponse enum. Dispatch is on the event’s type, so AgentResponse::Unknown holds exactly the events this SDK does not model; a recognized event with a malformed payload is an error on the stream, never a silent Unknown. A recognized event carrying an unrecognized value is neither: it stays on the happy path through that value’s own catch-all. A role this release does not name, on ConversationText or History, arrives as ConversationRole::Unknown(String) holding the wire string verbatim, and a history entry matching neither modeled shape as HistoryMessage::Unknown(serde_json::Value). So a new server enum value never ends a session.
  • websocket — the Agent sub-client and live-session primitives (AgentHandle, AgentEventStream, AgentEvent) that connect to wss://agent.deepgram.com/v1/agent/converse. start_at_url requires TLS (wss://) except for loopback hosts.

Debug output for AwsCredentials, Endpoint, and FunctionEndpoint redacts secrets (AWS keys/tokens and header values), so a Settings value can be logged safely.

Wire format matches the AsyncAPI schemas in deepgram-docs under api/specs/asyncapi/schemas/agent/. See the simple_agent and function_calling examples for end-to-end usage.

Re-exports§

pub use audio::AudioConfig;
pub use audio::AudioContainer;
pub use audio::AudioInput;
pub use audio::AudioInputEncoding;
pub use audio::AudioOutput;
pub use audio::AudioOutputEncoding;
pub use aws_credentials::AwsCredentials;
pub use aws_credentials::AwsCredentialsType;
pub use endpoint::Endpoint;
pub use history::ConversationHistoryMessage;
pub use history::ConversationRole;
pub use history::FunctionCallHistoryMessage;
pub use history::HistoryFunctionCall;
pub use history::HistoryMessage;
pub use history::HistoryMessageType;
pub use listen::AgentListenProvider;
pub use listen::AgentListenSettings;
pub use listen::DeepgramListenV1Provider;
pub use listen::DeepgramListenV1Version;
pub use listen::DeepgramListenV2Provider;
pub use listen::DeepgramListenV2Version;
pub use listen::DeepgramProviderType;
pub use messages::ClientMessage;
pub use messages::ForceEndTurnMessage;
pub use messages::ForceEndTurnType;
pub use messages::FunctionCallResponseMessage;
pub use messages::FunctionCallResponseType;
pub use messages::InjectAgentBehavior;
pub use messages::InjectAgentMessageMessage;
pub use messages::InjectAgentMessageType;
pub use messages::InjectUserMessageMessage;
pub use messages::InjectUserMessageType;
pub use messages::KeepAliveMessage;
pub use messages::KeepAliveType;
pub use messages::UpdateListenMessage;
pub use messages::UpdateListenType;
pub use messages::UpdatePromptMessage;
pub use messages::UpdatePromptType;
pub use messages::UpdateSpeakMessage;
pub use messages::UpdateSpeakType;
pub use messages::UpdateThinkMessage;
pub use messages::UpdateThinkType;
pub use response::AgentAudioDoneEvent;
pub use response::AgentAudioDoneType;
pub use response::AgentFunctionCall;
pub use response::AgentResponse;
pub use response::AgentStartedSpeakingEvent;
pub use response::AgentStartedSpeakingType;
pub use response::AgentThinkingEvent;
pub use response::AgentThinkingType;
pub use response::CancelledFunctionCall;
pub use response::ConversationTextEvent;
pub use response::ConversationTextType;
pub use response::ErrorEvent;
pub use response::ErrorType;
pub use response::FunctionCallCancelledEvent;
pub use response::FunctionCallCancelledType;
pub use response::FunctionCallRequestEvent;
pub use response::FunctionCallRequestType;
pub use response::InjectionRefusedEvent;
pub use response::InjectionRefusedType;
pub use response::LatencyReportEvent;
pub use response::LatencyReportType;
pub use response::ListenUpdatedEvent;
pub use response::ListenUpdatedType;
pub use response::PromptUpdatedEvent;
pub use response::PromptUpdatedType;
pub use response::SettingsAppliedEvent;
pub use response::SettingsAppliedType;
pub use response::SpeakUpdatedEvent;
pub use response::SpeakUpdatedType;
pub use response::ThinkUpdatedEvent;
pub use response::ThinkUpdatedType;
pub use response::UserStartedSpeakingEvent;
pub use response::UserStartedSpeakingType;
pub use response::WarningEvent;
pub use response::WarningType;
pub use response::WelcomeEvent;
pub use response::WelcomeType;
pub use settings::AgentConfig;
pub use settings::AgentContext;
pub use settings::InlineAgentConfig;
pub use settings::SettingsFlags;
pub use settings::SettingsMessage;
pub use settings::SettingsMessageType;
pub use speak::SpeakProvider;
pub use speak::SpeakSettings;
pub use think::ContextLength;
pub use think::FunctionEndpoint;
pub use think::ThinkFunction;
pub use think::ThinkProvider;
pub use think::ThinkSettings;
pub use websocket::Agent;
pub use websocket::AgentEvent;
pub use websocket::AgentEventStream;
pub use websocket::AgentHandle;
pub use websocket::InsecureAgentUrl;

Modules§

audio
Audio I/O configuration for the Voice Agent Settings message.
aws_credentials
AWS credentials shared by AWS Bedrock (Think) and AWS Polly (Speak) providers.
endpoint
Custom endpoint configuration for non-Deepgram Think and Speak providers.
history
Conversation history messages used by agent.context.messages[] on the Voice Agent Settings message and emitted by the server as History events during a session.
listen
Agent Listen (speech-to-text) provider settings.
messages
Client-to-server message types for the Voice Agent WebSocket.
response
Server-to-client event types for the Voice Agent WebSocket.
settings
Voice Agent Settings message — the full client-to-server payload that configures an agent session.
speak
Voice Agent Speak (TTS) settings.
think
Voice Agent Think (LLM) settings.
websocket
Voice Agent WebSocket connection — the live session at wss://agent.deepgram.com/v1/agent/converse.