This topic describes the service endpoint, request headers, and interaction flow for accessing the Qwen-Audio-3.0-ASR-Flash-Streaming/Fun-ASR-Realtime real-time speech recognition service over a WebSocket connection.
User guide: For model descriptions and selection guidance, see Speech-to-text. For sample code, see Real-time speech recognition.
The DashScope SDK currently supports only Java and Python. For other programming languages, connect to the service directly over a WebSocket connection.
Service endpoint
The WebSocket URL is fixed:
Singapore
wss://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api-ws/v1/inference
Replace {WorkspaceId} with your actual Workspace ID.
China (Beijing)
wss://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api-ws/v1/inference
Replace {WorkspaceId} with your actual Workspace ID.
ImportantAlibaba Cloud Model Studio has released workspace-specific domains for the China (Beijing) and Singapore regions. The new dedicated domains deliver superior performance and higher stability for inference requests. We recommend migrating to the new domains:
- China (Beijing): from
dashscope.aliyuncs.comto{WorkspaceId}.cn-beijing.maas.aliyuncs.com - Singapore: from
dashscope-intl.aliyuncs.comto{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com
Replace {WorkspaceId} with your actual Workspace ID. The existing domains remain fully functional.
ImportantThe URL must use the wss:// protocol and is fixed. Set Authorization in the request header (see Request headers).
Request headers
Add the following information to the request header:
Parameter | Type | Required | Description |
|---|---|---|---|
Authorization | string | Yes | Authentication token in the format |
user-agent | string | No | Client identifier that helps the server track the request source. |
X-DashScope-WorkSpace | string | No | Model Studio workspace ID. |
X-DashScope-DataInspection | string | No | Whether to enable data compliance inspection. This parameter is omitted or set to |
ImportantAuthorization 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.
The client and server interact in the following order:
- 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.