Freigeben über


aio Package

Classes

ConnectionClosed

Raised when a WebSocket connection is closed.

ConnectionError

Base exception for Voice Live WebSocket connection errors.

ConversationItemResource

Resource for conversation item management.

Initialize a conversation item resource.

ConversationResource

Resource for conversation management.

Exposes helpers for manipulating items in the active conversation.

Initialize a conversation resource.

InputAudioBufferResource

Resource for input audio buffer management.

Initialize an input audio buffer resource.

OutputAudioBufferResource

Resource for output audio buffer management.

Initialize an output audio buffer resource.

ResponseResource

Resource for response management.

Initialize a response resource.

SessionResource

Resource for session management.

Initialize a session resource.

TranscriptionSessionResource

Resource for transcription session management.

Initialize a transcription session resource.

VoiceLiveConnection

Represents an active asynchronous WebSocket connection to the Azure Voice Live API.

This class exposes resource-specific helpers for interacting with the service:

Instances are yielded by the connect context manager.

Initialize a VoiceLiveConnection instance.

WebsocketConnectionOptions

Transport-agnostic WebSocket connection options for VoiceLive.

These control common WS behaviors (compression, message size limits, timeouts, ping/pong handling). Unless specified, defaults are determined by the underlying WebSocket library.

Functions

connect

Create and manage an asynchronous WebSocket connection to the Azure Voice Live API.

This helper returns an async context manager that:

  • Authenticates with the service using an API key or Azure Active Directory token.
  • Prepares the correct WebSocket URL and query parameters.
  • Establishes the connection and yields a VoiceLiveConnection.
  • Automatically cleans up the connection when the context exits.

Note

Additional keyword arguments can be passed and will be forwarded to the underlying connection.

connect(*, credential: AzureKeyCredential | AsyncTokenCredential, endpoint: str, api_version: str = '2025-10-01', model: str | None = None, query: Mapping[str, Any] | None = None, headers: Mapping[str, Any] | None = None, connection_options: WebsocketConnectionOptions | None = None, **kwargs: Any) -> AbstractAsyncContextManager[VoiceLiveConnection]

Keyword-Only Parameters

Name Description
credential

The credential used to authenticate with the service.

endpoint

Service endpoint, e.g., https://<region>.api.cognitive.microsoft.com.

api_version

The API version to use. Defaults to "2025-10-01".

Default value: 2025-10-01
model
str

Model identifier to use for the session. In most scenarios, this parameter is required. It may be omitted only when connecting through an Agent scenario, in which case the service will use the model associated with the Agent.

Default value: None
query

Optional query parameters to include in the WebSocket URL.

Default value: None
headers

Optional HTTP headers to include in the WebSocket handshake.

Default value: None
connection_options

Optional advanced WebSocket options compatible with aiohttp.

Default value: None

Returns

Type Description
<xref:collections.abc.AsyncContextManager>[VoiceLiveConnection]

An async context manager yielding a connected VoiceLiveConnection.