BetaRealtime Class
BetaRealtime streaming entry point, exposed as client.beta.voice_agents.realtime.
Follows the OpenAI Python realtime surface: obtain it from the HTTP client and open a connection with connect:
from azure.ai.projects import AIProjectClient
from azure.identity import DefaultAzureCredential
client = AIProjectClient(endpoint, DefaultAzureCredential())
with client.beta.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
BetaRealtime(*args: Any, **kwargs: Any)
Parameters
| Name | Description |
|---|---|
|
client
Required
|
The object whose endpoint and credential are reused for the realtime
handshake – the |
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, 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) -> BetaRealtimeConnectionManager
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
|
|
structured_inputs
|
A mapping of structured-input names to their values for this session (see structured_inputs for the analogous shape used elsewhere). Serialized to JSON on the wire. Default value is None. 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. Pass
Default value: None
|
Returns
| Type | Description |
|---|---|
|
<xref:azure.ai.projects.BetaRealtimeConnectionManager>
|
A context manager yielding a BetaRealtimeConnection. |