Use WebSocket to establish a session, transmit audio, and handle task events.
Request URL
- Singapore
- China North 2 (Beijing)
wss://ap-southeast-1.maas.qwencloudapi.com/api-ws/v1/realtime?model=qwen-audio-3.1-liveRequest Headers
Authorization (String, Required)
Format: Bearer $DASHSCOPE_API_KEY. Obtain your API Key from 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
- Establish the connection and send
session.update; then wait forsession.updated. - Omit
transportin the session configuration and use the same WebSocket connection for both audio transmission and reception. Upload Base64-encoded PCM audio frame-by-frame viasession.input_audio.append: 16 kHz, 16-bit, mono. Decode the Base64 data insession.output_audio.deltainto 24 kHz, 16-bit, mono PCM audio. - Read input transcription and output subtitles separately via
session.input_transcript.deltaandsession.output_transcript.delta. - Send
session.closeand release resources upon receivingsession.closed.
Task Processing
| Mode | Task Interaction |
|---|---|
| Client | Execute the task upon receiving session.delegation.created and return results via session.commentary.append. The frontend model may continue responding via voice. |
| Responses | Read backend events from response.event. The inner response.completed indicates that backend generation has completed. Receive frontend voice replies via session.output_audio.delta. |
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.