Voice-based agents are in preview. Requests to create a Voice-based agent must include the
Foundry-Features: VoiceAgents=V1Preview header.Prerequisites
- Access to a Microsoft Foundry project.
- A hosted text agent deployed in the Foundry project. The hosted agent must expose the
invocations_wsprotocol and implement Bridge Protocol version 1.0. For an implementation example, see the basic Voice-based target agent sample. - The name of the hosted agent and, optionally, a specific version to use.
Create the voice-based agent
Create the voice-based agent by using the project endpoint. Setconversation_engine.type to hosted_agent, and use name to identify the hosted agent that handles the conversation.
Replace the project endpoint, hosted agent name, and optional hosted agent version with your project values.
HOSTED_AGENT_VERSION to an empty string or remove version from the conversation_engine object.
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 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’s voice WebSocket endpoint to have an interactive conversation. The following Python sample captures 24-kHz PCM audio from your microphone, sends it to the agent, and plays the agent’s audio responses. Install the required packages: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.