Qwen-Omni-Realtime WebSocket access
Qwen-Omni-Realtime WebSocket access
Scope
This document is intended for Qwen-Omni-Realtime. The example model is qwen3.8-omni-flash-realtime; configurations for qwen3.5-omni-plus-realtime and qwen3.5-omni-flash-realtime can be found in the event reference. Parameters for legacy models qwen3-omni-flash-realtime-2025-09-15 are detailed in Python SDK.
- Use the API Key and Workspace ID corresponding to your selected region and workspace.
- Beijing domain:
{WorkspaceId}.cn-beijing.maas.aliyuncs.com. - Long-term API keys are stored on the server and should not be placed in browsers or mobile applications.
Addresses and Authentication
wss://WorkspaceId.cn-beijing.maas.aliyuncs.com/api-ws/v1/realtime?model=qwen3.8-omni-flash-realtimeqwen3.8-omni-flash-realtime must use the workspace–specific domain name. Older models may continue to use their original domains: Beijing uses wss://dashscope.aliyuncs.com, and Singapore uses wss://dashscope-intl.aliyuncs.com. For details, see Python SDK.
Set Authorization: Bearer <API_KEY> in the WebSocket handshake request header. Replace the workspace ID and the actual model name; do not place long-term API keys in browsers or mobile apps.
An optional user-agent request header is used to identify the client. General WebSocket integration documentation also lists X-DashScope-WorkSpace (workspace ID) and X-DashScope-DataInspection (data compliance check configuration), which are used as required by the model.
For instructions on generating temporary API keys and their permissions, see Generate Temporary API Key.
These workspace URLs use qwen3.5-omni-plus-realtime as the example model.
- China (Beijing)
wss://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api-ws/v1/realtime?model=qwen3.5-omni-plus-realtime - Singapore
wss://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api-ws/v1/realtime?model=qwen3.5-omni-plus-realtime
Replace {WorkspaceId} with the workspace ID for the selected region.
Session Configuration
Send session.update after establishing the connection and receiving session.created. Send input only after receiving session.updated confirmation; handle errors via error events.
The following examples correspond to qwen3.8-omni-flash-realtime; other versions should use the configurations from their respective event references, without mixing field levels.
{
"type": "session.update",
"session": {
"modalities": [
"text",
"audio"
],
"voice": "Tina",
"turn_detection": {
"type": "server_vad"
}
}
}
Input, Results, and Termination
Audio is sent via input_audio_buffer.append; input formats, submission conditions, and image input limits are described in Client Events. Process the results, status, and errors in Server Events; do not consider connection establishment as completion of the business request.
The timing for automatic rounds, Manual mode, Function Calling, and MCP is outlined in Interaction Flow. After receiving the required results, close the WebSocket connection.
Interaction flow
VAD mode
To enable VAD mode, set the session.turn_detection.type parameter of the client event to "server_vad". In this mode, the server performs Voice Activity Detection (VAD) on incoming audio and responds when it detects speech. This mode is the default and is designed for scenarios where the client continuously sends audio to the server.
- The server sends the
input_audio_buffer.speech_startedevent when it detects the start of speech. - The client can append audio to the buffer at any time by sending an
input_audio_buffer.appendevent. - The server sends the
input_audio_buffer.speech_stoppedevent when it detects the end of speech. - The server commits the input audio buffer by sending an
input_audio_buffer.committedevent. - The server sends a
conversation.item.createdevent, which contains the user message item created from the audio buffer.
Function Calling flow
In VAD mode, when a response requires the client to execute a Function Calling tool, use this flow:
- After detecting the end of speech and generating a response, the server determines that a tool call is required.
- The server sends a
response.function_call_arguments.deltaevent, which contains incremental data for the tool call arguments. - The server sends a
response.function_call_arguments.doneevent to indicate that all tool call arguments have been sent. - The client executes the tool call and obtains the result.
- The client sends a
conversation.item.createevent that contains the tool call result. - The client sends a
response.createevent to trigger a response based on the tool call result.
Manual mode
To enable Manual mode, set the session.turn_detection parameter of the client event to null. In this mode, the client requests a server response by explicitly sending input_audio_buffer.commit and response.create events. This mode is suitable for push-to-talk scenarios, such as sending voice messages in chat applications.
- The client can append audio to the buffer by sending an
input_audio_buffer.appendevent. - The client commits the input audio buffer by sending an
input_audio_buffer.commitevent. This commit creates a new user message item in the conversation. - The server responds by sending an
input_audio_buffer.committedevent. - The client sends a
response.createevent to trigger the model to generate the final response. - The server responds by sending a
conversation.item.createdevent.
Function Calling flow
In Manual mode, when a response requires the client to execute a Function Calling tool, use this flow:
- After the client sends a
response.createevent, the server generates a response and detects that a tool call is required. - The server sends a
response.function_call_arguments.deltaevent, which contains incremental data for the tool call arguments. - The server sends a
response.function_call_arguments.doneevent to indicate that the transfer of tool call arguments is complete. - The client executes the tool call and obtains the result.
- The client sends the tool call result using a
conversation.item.createevent. - The client sends a
response.createevent to trigger the model to generate the final response. - The server generates a response based on the tool call result and sends it to the client using
response.audio.deltaorresponse.text.deltaevents.
MCP tool calls
The following flow applies to Qwen3.8-Omni-Flash-Realtime and can be used together with the VAD or Manual modes described above.
Function Calling and MCP can be configured together in session.tools for the same session. They cannot be used together with web search (enable_search). Model Studio does not charge an additional MCP tool invocation fee. Model inference remains subject to model pricing.
MCP tools are executed by the server, whereas the Function Calling flows above are executed by the client, so the two differ in how their results are returned.
Tool discovery
After the client configures MCP servers with session.update, the Realtime service discovers their tools asynchronously. The interaction flow is as follows:
In the sequence diagrams in this section, opt indicates execution when a condition is met, alt indicates alternative branches selected by condition, and par indicates parallel processing.
session.updatedonly indicates that the MCP configuration has been accepted, not that the tools are already available.mcp_list_tools.in_progressmay arrive earlier thansession.updated.- The client can continue to send audio or
response.createbefore tool discovery completes, but only Responses created after discovery is complete can use the corresponding MCP tools. - When tool discovery succeeds, the server first sends a
conversation.item.createdevent containing the final tool list, and then sendsmcp_list_tools.completed. - When tool discovery fails, the server first sends a
conversation.item.createdevent containing an error, and then sendsmcp_list_tools.failed.
MCP calls and continuation
When the model selects an MCP tool, the Realtime service executes the tool call. When approval is required, the client first replies with the approval result. The interaction flow is as follows:
Approval rejection or timeout directly triggers response.mcp_call.failed without executing the tool and without going through response.mcp_call.in_progress. When no approval is required or approval is granted, the typical event sequence is as follows:
response.output_item.added (mcp_call)
→ response.mcp_call_arguments.delta
→ Optional: conversation.item.created (mcp_approval_request)
→ Optional: conversation.item.create (mcp_approval_response)
→ response.mcp_call.in_progress
→ response.mcp_call.completed or response.mcp_call.failed
→ response.output_item.done (final mcp_call)
→ response.done (parent Response)
The server sends response.done after all MCP items of the same parent Response reach a terminal state. Its response.output already contains the final mcp_call snapshots: successful items are completed and contain output; failed items are failed and contain error.
If you want the model to continue generating an answer based on the MCP results, the client should send one response.create without MCP results attached after receiving the parent response.done.
See client MCP configuration, approval replies, MCP server events, and MCP conversation items.
Usage limits
The following default MCP constraints apply to each session:
| Item | Default value |
|---|---|
| MCP servers | 8 |
| MCP tools | 128 |
| Tool discovery timeout | 30 seconds |
| Approval timeout | 60 seconds |
| Tool execution timeout | 30 seconds |
| Single upstream response size | 2 MB |
| Cumulative tool result size | 8 MB |
| Cumulative tool calls | 256 |
Error Handling
When a handshake fails, verify the domain name, region, workspace, API Key, model name, and model activation status and permissions. After the connection is established, locate the issue based on the error event, and refer to Error Codes. Retain the event ID for troubleshooting; do not assume protocol support is lacking simply because there is no response.
FAQ
How can I insert a pause of an exact duration in Qwen-Omni-Realtime speech?
To leave two seconds between “I’m from Example Company” and “How are you?”, generate each line as a separate audio segment. Play the first segment, insert two seconds of silence on the client, then play the second. The PCM chunks returned over WebSocket have no per-word timestamps, so chunk boundaries alone cannot tell you where a particular word ends.
In session.update, silence_duration_ms controls how long the server waits for silence before detecting the end of the user’s turn (200–6,000 ms, default 800 ms). This setting prevents a brief pause in the user’s speech from triggering a response too early. The playback pause lasts as long as the silence you insert on the client.