VoiceAgent
VoiceAgent is an optional high-level runner in
agentduet 1.0.0.
It answers the call, opens a model session, streams PCM both ways, clears the
buffer on barge-in, dispatches tool calls, and cleans up on hangup.
Integrations document the direct PCM bridge with agentduet and the provider
SDK. Use this page when you want the same loop behind a thin adapter
abstraction.
Install
Prefer the second for anything you deploy. [adapters] pulls all four
providers’ SDKs; naming the provider keeps the install to what you use.
Credentials
VoiceAgent.from_env() reads AgentDuet connector credentials only:
Each model adapter reads its provider key separately (from the environment by
default, or pass api_key= to the adapter constructor):
Three-line Gemini agent
Needs AGENTDUET_API_KEY, AGENTDUET_CONNECTOR_UUID, and GEMINI_API_KEY.
from_env() reads connector credentials and defaults sample_rate to 24000
(matching most realtime speech models). The SDK-wide CallAudioConfig default
remains 16000 when you omit call_audio= on SessionManagerConfig.create().
Other adapters
Install the matching extra: agentduet-adapters[grok], [qwen], or [nova-sonic].
OpenAI Realtime is not packaged as an adapter yet. Use the OpenAI Realtime bridge tutorial.
Inbound and outbound
Property: is_serving is True while serve() is running (required for place_call).
Trigger conditions on inbound
VoiceAgent(..., inbound=InboundCallMode.ALL) calls setup_trigger_conditions
on startup with TriggerConditionsBuilder().inbound_call(...).build() (absolute
replace). Message-flow toggles reset to their defaults. Pass inbound=None to
leave the server-side configuration untouched. See
Trigger Conditions and
WhatsApp Messaging.
Tools, transcripts, usage
Custom model adapter
Adapters are protocols. Any object with matching methods works; no base class
required. Writing your own needs only agentduet (not agentduet-adapters):
Events VoiceAgent understands
When to use a full bridge instead
Integrations use a direct PCM bridge with agentduet plus the provider SDK.
Prefer that path when you need custom session lifecycle, OpenAI Agents /
Google ADK shapes, resampling control, or multi-call topology. VoiceAgent is
an optional abstraction over the same loop.
