Skip to main content

Qwen-Audio-Live WebSocket access

Use WebSocket to establish a session, transmit audio, and handle task events.

Request URL

Qwen-Audio-Live supports only workspace-specific domains. Enter the Workspace ID for Singapore.
WebSocketwss://WorkspaceId.ap-southeast-1.maas.aliyuncs.com/api-ws/v1/realtime?model=qwen-audio-3.1-live

Request Headers

AuthorizationStringRequired
Format: Bearer <API Key>. Obtain the API Key for the corresponding workspace in Singapore’s API Key Management.

Query Parameters

The model=qwen-audio-3.1-live in the URL selects the service endpoint for Qwen-Audio-Live. After establishing the connection, select a frontend speech model via session.update’s session.model. Valid values are listed in session.update.

Establish a Session and Exchange Audio

  1. Establish the connection and send session.update; then wait for session.updated.
  2. Omit transport in the session configuration and use the same WebSocket connection for both audio transmission and reception. Upload Base64-encoded PCM audio frame-by-frame via session.input_audio.append: 16 kHz, 16-bit, mono. Decode the Base64 data in session.output_audio.delta into 24 kHz, 16-bit, mono PCM audio.
  3. Read input transcription and output subtitles separately via session.input_transcript.delta and session.output_transcript.delta.
  4. Send session.close and release resources upon receiving session.closed.

Task Processing

ModeTask Interaction
ClientExecute the task upon receiving session.delegation.created and return results via session.commentary.append. The frontend model may continue responding via voice.
ResponsesRead backend events from response.event. The inner response.completed indicates that backend generation has completed. Receive frontend voice replies via session.output_audio.delta.
When the frontend model requests a function call, the application receives session.event. After execution, send session.item.create to return the result. Event formats are detailed in Client Events and Server Events. For a recording demo, see Quickstart. For production integration, see Task Delegation and Tools. For independent media connections to exchange audio, see WebRTC access or AOQ access.

Error Handling

Upon receiving error, verify the request using the error code. Upon receiving session.closed, stop sending events. To resume the conversation, establish a new connection and reconfigure the session.