Items marked preview in this article are currently in preview. This preview is provided without a service-level agreement, and Microsoft doesn’t recommend it for production workloads. Certain features might not be supported or might have constrained capabilities. For more information, see Supplemental Terms of Use for Microsoft Azure Previews.
Both paths use the same voice client and follow this flow:
Prerequisites
- Access to voice agents and hosted agents in the selected Azure subscription and region.
- A microphone and speakers or a headset.
- For the CLI deployment path, Azure Developer CLI version 1.32.0 or later and the Foundry extensions. Check that the extension exposes the public-preview voice CLI options.
- For the CLI deployment path, an authenticated
azdsession. Runazd auth loginbefore initialization. - For the CLI deployment path, the Azure permissions needed to provision Foundry resources. Confirm model availability and sufficient quota for the sample’s
gpt-5.4-minideployment. - For the SDK creation path, an existing Foundry project and a deployed hosted text agent. The target must expose
invocations_wsand implement Voice Live Bridge Protocol 1.0. Have its agent name and, optionally, the version to use. - For the SDK creation path, the Foundry User role on the project, or equivalent permissions to create and invoke agents.
- For the Python SDK examples, Python 3.10 or later and the Azure CLI, signed in with
az login.
The Foundry RBAC roles were recently renamed. Foundry User, Foundry Owner, Foundry Account Owner, and Foundry Project Manager were previously named Azure AI User, Azure AI Owner, Azure AI Account Owner, and Azure AI Project Manager. You might still see the previous names in some places while the rename rolls out. The role IDs and core permissions are unchanged by the rename.
voice extra and the audio dependencies:
voice extra installs the realtime transport dependencies, including aiohttp for asynchronous sessions. Your code uses the SDK instead of importing the transport libraries directly.
PyAudio requires PortAudio. If the
pyaudio installation fails, install the PortAudio development package for your operating system, and then run the pip install command again.Deploy both agents with the Azure Developer CLI
Use the Voice Live Bridge basic Python sample to deploy the hosted target and voice wrapper together. Itsazure.yaml defines both agents and configures a Python 3.13 runtime for the hosted target.
This path creates a new Foundry project. To reuse an existing project and model deployment, follow the sample’s existing-project instructions instead. Don’t run the new-project provisioning steps below against a shared project.
Initialize the sample
In PowerShell, create an empty directory and initialize from the public sample manifest:azure.yaml by running Set-Location voice-live-bridge-basic-python.
Review the target and voice wrapper
The sample declares twoazure.ai.agent services:
The wrapper includes these fields under
services in azure.yaml. Keep the sample’s existing audio and greeting settings:
uses dependency deploys the target before the wrapper. In azure.yaml, conversationEngine.name is the hosted target’s service name. The optional conversationEngine.version defaults to deployed, which pins the wrapper to the target version deployed by the current azd environment.
The wrapper and hosted target must have different Foundry agent names. Keep their name values distinct if you rename the sample’s services.
Keep model calls, instructions, and tools in the hosted target. Configure audio, voice output, and the greeting on the wrapper. Don’t use the older modelType: hosted_agent or targetAgent settings.
The target must declare invocations_ws version 1.0.0, with voiceLiveCompatible: "true" and bridgeProtocolVersion: "1.0" in its metadata. The sample already supplies these settings. The Bridge Protocol version is distinct from the invocations_ws transport version.
This workflow doesn’t replace custom audio pipelines hosted through invocations_ws. The hosted target exchanges text and control events with Voice Live rather than processing caller audio itself.
Provision and deploy both agents
From the generated project directory, provision the new Foundry project and the model declared inazure.yaml:
azd deploys both the target and the wrapper:
voice-live-bridge-basic-python-voice. Don’t run the SDK creation example next: the CLI already created the voice wrapper.
Create the voice-based agent
Use this alternative when you already have a compatible hosted text agent and want to create its voice wrapper with the SDK. If you deployed both agents with the CLI, skip to Use the voice-based agent. Create the voice-based agent by usingAIProjectClient and the project endpoint. Set conversation_engine to a VoiceHostedAgentConversationEngine, and use name to identify the deployed hosted agent in that project. The SDK sets the engine’s type to hosted_agent.
Set allow_preview=True on AIProjectClient to create voice-agent definitions. The SDK adds the required Foundry-Features: VoiceAgents=V1Preview header.
Replace the project endpoint, hosted agent name, and optional hosted agent version with your project values. Keep VOICE_AGENT_NAME different from HOSTED_AGENT_NAME. The example enables conversation storage with store=True, which persists transcripts and audio. Use store=False if you don’t need persistence.
create_version creates a new immutable version.
To use the hosted agent’s latest version instead of pinning a version, set HOSTED_AGENT_VERSION to an empty string. The example then omits version from the conversation engine. Unlike the CLI’s conversationEngine.version: deployed setting, the SDK accepts an actual agent version, not the literal value deployed.
The conversation_engine object supports the following properties:
For this type of voice-based agent, don’t specify
model_type or model. Exactly one conversation selection form is allowed: a model-backed definition or an engine-backed definition. The presence of conversation_engine selects the engine-backed form.
The hosted agent owns the conversation logic. Therefore, don’t configure instructions, reasoning_effort, tools, tool_choice, subagent_config, or handoff on the voice wrapper. You can configure voice-surface properties, including audio, avatar, output_modalities, greeting, structured_inputs, store, and rai_config.
The create_version operation validates the conversation engine configuration but doesn’t verify the referenced hosted agent. The service resolves the target agent and checks its Voice Live and Bridge Protocol compatibility when a voice session starts.
Use the voice-based agent
Connect to the voice-based agent withproject_client.beta.voice_agents.realtime.connect(). The SDK handles authentication, the voice WebSocket endpoint, and event serialization. The following Python sample captures 24-kHz PCM audio from your microphone, sends it to the agent, and plays the agent’s audio responses.
The voice agent owns its audio configuration and turn detection, so the client doesn’t send a session.update event. The SDK accepts raw PCM bytes for microphone input and returns decoded audio bytes in typed server events.
Connect to the voice wrapper, not to the hosted text target. Copy the project endpoint from the Overview page of your project in the Foundry portal. Set VOICE_AGENT_NAME in the following script to the wrapper you created:
The CLI sample uses
store: false; the SDK creation example uses store=True. This client works with either setting and doesn’t require a persisted conversation ID.
Replace the project endpoint and voice-based agent name with your values:
Test the voice wrapper
Use the preceding client or the Foundry voice playground where available:- Ask a short question to exercise the target’s model deployment.
- Confirm that the client prints your input transcription and the agent’s response text, and that you hear the response.
- Speak while the agent responds, and check that playback stops and the agent handles your new turn.
/help through the Bridge Protocol without calling a model. This check verifies the target’s protocol handling, not the managed voice audio path.
azd ai agent invoke doesn’t generate Voice Live conversations. Selecting the voice wrapper returns portal guidance, not a voice session.
Troubleshoot
Clean up resources
For the new project created by the CLI deployment path, run the following command from its generated project directory:project_client.agents.delete(agent_name=VOICE_AGENT_NAME) with an authenticated AIProjectClient. Keep any pre-existing hosted target, model deployment, and shared project.