All Products
Search
Document Center

Alibaba Cloud Model Studio:WebSocket API for Qwen-TTS real-time synthesis

Last Updated:Jul 07, 2026

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.

Service endpoint

Use the following URL. Set the model with the model query parameter:

Singapore

WebSocket URL: wss://dashscope-intl.aliyuncs.com/api-ws/v1/realtime?model=qwen3-tts-flash-realtime

China (Beijing)

WebSocket URL: wss://dashscope-intl.aliyuncs.com/api-ws/v1/realtime?model=qwen3-tts-flash-realtime

Important

The URL must use the wss:// protocol. Set the Authorization header (see Request headers) and specify the model using the model query parameter.

Request headers

Set the following request headers:

Parameter

Type

Required

Description

Authorization

string

Yes

Format: Bearer <your_api_key>. Replace <your_api_key> with your API key.

user-agent

string

No

Client identifier for server-side source tracking.

X-DashScope-WorkSpace

string

No

The Alibaba Cloud Model Studio workspace ID.

Important

Authorization is verified during the WebSocket handshake. An invalid or missing API key causes the handshake to fail with HTTP 401/403.

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.commit explicitly to trigger synthesis.

Mode details

  • In ServerCommit mode, call input_text_buffer.append to buffer text. The system determines synthesis timing automatically.

  • Calling input_text_buffer.commit in ServerCommit mode synthesizes the current buffer immediately. The session then resumes ServerCommit mode.

  • In Commit mode, input_text_buffer.append alone does not trigger synthesis. Call input_text_buffer.commit to start synthesis.

qwen-tts

Key steps:

  1. Connection: The client opens a WebSocket connection. The server returns session.created when ready.

  2. Session configuration: The client sends session.update to configure voice, format, and mode.

  3. Text input: The client sends input_text_buffer.append to add text to the buffer.

  4. Synthesis trigger:

    • In ServerCommit mode, synthesis starts automatically. The client can call input_text_buffer.commit to force immediate synthesis.

    • In Commit mode, only input_text_buffer.commit triggers synthesis.

  5. Audio generation: The server sends response.created, then streams base64-encoded audio as response.audio.delta events until response.audio.done.

  6. Session termination: The client sends session.finish to release resources. The server returns session.finished and closes the connection.

After connection, the server returns this session.created event:

{
    "event_id": "event_xxx",
    "type": "session.created",
    "session": {
        "object": "realtime.session",
        "mode": "server_commit",
        "model": "qwen3-tts-flash-realtime",
        "voice": "Cherry",
        "response_format": "pcm",
        "sample_rate": 24000,
        "id": "sess_xxx"
    }
}