Skip to main content

Qwen-Audio-Live WebSocket access

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

Endpoint and authentication

China (Beijing)
wss://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api-ws/v1/live?model=qwen-audio-3.1-live
Singapore
wss://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api-ws/v1/live?model=qwen-audio-3.1-live
Qwen-Audio-Live supports only workspace-specific domains. Replace {WorkspaceId} with your workspace ID in the selected region. Set the Authorization header to Bearer <API Key> using an API key from the same region. The model query parameter selects the Qwen-Audio-Live service. Set session.model to the frontend speech model, such as qwen-audio-4.0-realtime-preview for a full-duplex conversation.

Start a session and stream audio

  1. Open the connection and send session.update. To send and receive audio over this connection, omit session.transport from the session configuration. Wait for session.updated.
  2. After confirmation, send audio frame by frame with session.input_audio.append as Base64-encoded 16 kHz, 16-bit, mono PCM. Decode the Base64 data in session.output_audio.delta as 24 kHz, 16-bit, mono PCM.
  3. Read session.input_transcript.delta for input transcription and session.output_transcript.delta for reply captions.
  4. Send session.close and release resources when you receive session.closed.

Handle tasks

ModeTask flow
ClientExecute the task from session.delegation.created and submit the result using session.commentary.append. The frontend model can respond in speech.
ResponsesRead backend progress and results from response.event after the delegation event. Use the frontend audio events to receive the spoken reply.
The frontend model also sends ordinary function calls in session.event. Return the result with session.item.create. See client events, server events, and AOQ access.