pub struct Agent<'a>(/* private fields */);Expand description
Sub-client for the Voice Agent.
Construct via Deepgram::agent. Exposes Agent::start /
Agent::start_at_url for opening a live agent WebSocket session.
Implementations§
Source§impl Agent<'_>
impl Agent<'_>
Sourcepub async fn start(
&self,
) -> Result<(AgentHandle, AgentEventStream), DeepgramError>
pub async fn start( &self, ) -> Result<(AgentHandle, AgentEventStream), DeepgramError>
Open a new Voice Agent WebSocket session at the SaaS endpoint
(wss://agent.deepgram.com/v1/agent/converse).
Returns a handle for sending messages and a stream of incoming
events. The first message you typically send is a
SettingsMessage via AgentHandle::send_settings.
The session terminates when AgentHandle::close is called, when
the underlying handle is dropped, or when the server closes the
connection.
Sourcepub async fn start_at_url(
&self,
url: &str,
) -> Result<(AgentHandle, AgentEventStream), DeepgramError>
pub async fn start_at_url( &self, url: &str, ) -> Result<(AgentHandle, AgentEventStream), DeepgramError>
Open a session at a custom WebSocket URL.
§TLS is required
The Deepgram credential (API key or temporary token) is sent in the
handshake’s Authorization header, so the URL must use TLS
(wss://). The single exception is a loopback host —
localhost, 127.0.0.0/8, or [::1] — where plain ws:// is
accepted so integration tests can target a local mock server. Any
other ws:// URL is rejected before a connection is attempted
with DeepgramError::InsecureAgentUrl, which carries an
InsecureAgentUrl, so the credential is never transmitted in
cleartext. Schemes other than ws/wss return
DeepgramError::InvalidUrl.
Use cases:
- Self-hosted agent deployments — point at your own
wss://agent.your-domain.example/...host. - Integration tests — point at a local mock server (e.g.
ws://127.0.0.1:NNNN/...).
The Host header is built from the URL’s full authority: host plus
any non-default port, with IPv6 literals bracketed (e.g.
127.0.0.1:NNNN, [::1]:NNNN, agent.deepgram.com). All other
behavior matches Agent::start: same auth headers, same
handshake, same returned types.