This topic describes the service endpoint, request headers, and interaction flow for accessing the Qwen-Audio-3.1-ASR-Flash-Message real-time speech recognition service over a WebSocket connection.
Service endpoint
Use the following WebSocket URLs with the wss:// protocol:
wss://ap-southeast-1.maas.qwencloudapi.com/api-ws/v1/inference
The URL above is for Singapore (ap-southeast-1). For another region, replace ap-southeast-1 with the region ID and use an API key from that region. See Regions and endpoints.
Request headers
Add the following information to the request header:
| Parameter | Type | Required | Description |
|---|---|---|---|
| Authorization | string | Yes | Authentication token in the format Bearer $DASHSCOPE_API_KEY. Replace $DASHSCOPE_API_KEY with your actual API key. |
| user-agent | string | No | Client identifier that helps the server track the request source. |
| X-DashScope-WorkSpace | string | No | QwenCloud workspace ID. |
| X-DashScope-DataInspection | string | No | Whether to enable data compliance inspection. This parameter is omitted or set to enable by default. Do not enable this parameter unless necessary. |
Authorization is verified during the WebSocket handshake. If the API key is invalid or missing, the handshake fails and returns an HTTP 401 or 403 error.
Interaction flow
For details about client events and server events, see Client events and Server-side events.
- Establish the connection: The client establishes a WebSocket connection to the server.
- Start the task: The client sends a run-task instruction to start the task and receives a task-started event from the server. This event confirms that the task has started and that you can proceed to the subsequent steps.
- Send the audio stream: The client starts sending binary audio (which must be mono) and simultaneously receives a stream of result-generated events from the server. Each event contains a speech recognition result.
- Notify the server to end the task: The client sends a finish-task instruction to signal the server to end the task and continues to receive result-generated events from the server.
- End the task: The client receives a task-finished event from the server, which indicates that the task has ended.
- Close the connection: The client closes the WebSocket connection.