Agent definitions for voice. This page shows how to adapt agents for spoken conversations.
Try it locally
Save this asvoice_demo.py. It starts the packaged browser client on your computer, so you can speak with your agent before you host anything.
- Install the voice extra:
pip install "agency-swarm[voice]". - Set
OPENAI_API_KEY, then runpython voice_demo.py. - Open http://127.0.0.1:8000, click Connect, and allow microphone access.
What you can build
- Phone receptionist — answers calls, routes to specialists, captures caller details.
- Live support triage — gathers context, lets callers interrupt, and escalates to a human or another agent.
- Language coach — listens, corrects pronunciation, and keeps the dialogue short and encouraging.
Prerequisites
- Access to a supported realtime provider:
- OpenAI (
gpt-realtime-2is the Agency Swarm default; see OpenAI’s realtime model catalog for other models and current pricing) - xAI (
grok-voice-think-fast-1.0is the Agency Swarm default; see xAI’s Speech to Speech guide for current model availability)
- OpenAI (
- The voice extra:
Define your agent (same API)
You keep using the standardAgent class—voice agents are regular agents with the same tools, handoffs, and instructions.
voice to any supported realtime token:
- OpenAI voices:
alloy,ash,ballad,cedar,coral,echo,marin,sage,shimmer,verse - xAI voices:
ara,eve,leo,rex,sal
One voice per call
The voice comes from the first place that sets one:- The
voice=you pass torun_realtime()or the demo launcher. - The
voice=on your entry agent—the agent that answers the call. - The provider’s own default when neither is set.
voice= on any other agent is not used for that call. It is still worth setting: that agent uses its own voice whenever it is the one answering.
If you want variety without picking voices by hand, build the agency with randomize_agent_voices=True. Every agent without an explicit voice gets a deterministic random pick from the provider’s list, and the entry agent’s pick becomes the voice for the call. Pass voice_random_seed= to keep the picks stable between runs.
Add handoffs (optional)
Handoffs work exactly as they do in text mode. Register your flows once and they will carry over to voice sessions.marin voice for the rest of the call, so give the specialists a different name or greeting if you want the switch to be obvious.
Next steps
- Try the realtime browser demo
- Deploy your agents for phone calls using Twilio.
- Review OpenAI’s realtime Quickstart and Guide for protocol details—Agency Swarm builds on those primitives.