Realtime Class
Connect to a voice agent through client.voice_agents.realtime.
Open a connection with connect:
from azure.ai.projects import AIProjectClient
from azure.identity import DefaultAzureCredential
client = AIProjectClient(endpoint, DefaultAzureCredential())
with client.voice_agents.realtime.connect(agent_name="my-agent") as conn:
conn.input_audio_buffer.append(audio=chunk)
conn.input_audio_buffer.commit()
conn.response.create()
for event in conn:
if event.type == RealtimeServerEventType.RESPONSE_DONE:
break
Constructor
Realtime(*args: Any, **kwargs: Any)
Parameters
| Name | Description |
|---|---|
|
client
Required
|
The voice-agent client that supplies the project endpoint and credential. |
Methods
| connect |
Open a realtime WebSocket connection to a voice agent. |
connect
Open a realtime WebSocket connection to a voice agent.
connect(*, agent_name: str, agent_session_id: str | None = None, transport: str | VoiceAgentTransport | None = None, structured_inputs: Mapping[str, Any] | None = None, connection_url: str | None = None, api_version: str | None = None, credential_scopes: List[str] | None = None, extra_query: Mapping[str, str] | None = None, extra_headers: Mapping[str, str] | None = None, **kwargs: Any) -> RealtimeConnectionManager
Keyword-Only Parameters
| Name | Description |
|---|---|
|
agent_name
|
The name of the voice agent to connect to. |
|
agent_session_id
|
An optional identifier used to correlate the voice session. Default value is None. Default value: None
|
|
transport
|
Default value: None
|
|
structured_inputs
|
Values for the agent's structured-input placeholders. Default value: None
|
|
connection_url
|
Full Default value: None
|
|
api_version
|
Overrides the client's API version for the handshake. Default value is None. Default value: None
|
|
credential_scopes
|
Overrides the client's token scopes for the handshake. Default value is None. Default value: None
|
|
extra_query
|
Additional query-string parameters for the handshake. Default value: None
|
|
extra_headers
|
Additional headers for the handshake. Preview voice features
require Default value: None
|
Returns
| Type | Description |
|---|---|
|
A context manager yielding a RealtimeConnection. |
Exceptions
| Type | Description |
|---|---|
|
If |