Connect to the Qwen-TTS real-time speech synthesis service over WebSocket. Covers the service endpoint, request headers, and interaction flow.
For model overview and selection guidance, see Real-time speech synthesis
The Qwen-TTS Realtime API uses the WebSocket protocol. Java and Python applications can use the DashScope SDK to skip WebSocket handling. Other languages can connect with a WebSocket library directly.
Use the following URL. Set the model with the
Set the following request headers:
For detailed descriptions of client events and server events, see Client events and Server events.
The API supports two modes:
Key steps:
Service endpoint
Use the following URL. Set the model with the model query parameter:
- Singapore
- China (Beijing)
WebSocket URL:
wss://dashscope-intl.aliyuncs.com/api-ws/v1/realtime?model=qwen3-tts-flash-realtimeRequest headers
Set the following request headers:
Parameter | Type | Required | Description |
|---|---|---|---|
Authorization | string | Yes | Format: |
user-agent | string | No | Client identifier for server-side source tracking. |
X-DashScope-WorkSpace | string | No | The Alibaba Cloud Model Studio workspace ID. |
Interaction flow
For detailed descriptions of client events and server events, see Client events and Server events.
The API supports two modes:
- ServerCommit mode: The server determines text segmentation and synthesis timing automatically.
- Commit mode: The client controls when to submit each text segment. Call
input_text_buffer.commitexplicitly to trigger synthesis.
Mode details
- In ServerCommit mode, call
input_text_buffer.appendto buffer text. The system determines synthesis timing automatically. - Calling
input_text_buffer.commitin ServerCommit mode synthesizes the current buffer immediately. The session then resumes ServerCommit mode. - In Commit mode,
input_text_buffer.appendalone does not trigger synthesis. Callinput_text_buffer.committo start synthesis.
-
Connection: The client opens a WebSocket connection. The server returns
session.createdwhen ready. -
Session configuration: The client sends
session.updateto configure voice, format, and mode. -
Text input: The client sends
input_text_buffer.appendto add text to the buffer. -
Synthesis trigger:
- In ServerCommit mode, synthesis starts automatically. The client can call
input_text_buffer.committo force immediate synthesis. - In Commit mode, only
input_text_buffer.committriggers synthesis.
- In ServerCommit mode, synthesis starts automatically. The client can call
-
Audio generation: The server sends
response.created, then streams base64-encoded audio asresponse.audio.deltaevents untilresponse.audio.done. -
Session termination: The client sends
session.finishto release resources. The server returnssession.finishedand closes the connection.
session.created event: