Qwen-Audio is an end-to-end large model for realtime voice interaction. It supports low-latency voice conversations and is suitable for scenarios such as voice assistants, intelligent customer service, and AI companions.
Overview
Enables realtime audio-to-speech/text conversion, with support for streaming audio input and streaming speech and text output.
In addition to the WebSocket protocol, this model also supports access through the AOQ and WebRTC protocols. If you are integrating on the client side and prioritize stable latency, interaction capability on weak networks, and real-time full-duplex noise suppression and echo cancellation, AOQ is recommended. For protocol comparison and selection, see the API reference.
- Supports Function Calling for tool calling; the model can autonomously decide whether to call external tools to obtain information
- Supports web search; the model can autonomously decide whether to search based on real-time questions and returns the sources of search results, and it can be enabled together with Function Calling
- Supports conversation context management (creating, querying, and deleting conversation items), allowing you to flexibly inject historical context or clean up irrelevant conversation items
- Highly expressive speech output that dynamically adjusts tone, pace, and emotional expression based on the conversational context
- Supports system voices and voice cloning voices; you can create a dedicated AI voice through voice cloning for voice conversation output
qwen-audio-3.1-realtime-plus, qwen-audio-3.1-realtime-flash, qwen-audio-3.0-realtime-plus, and qwen-audio-3.0-realtime-flash.
- Supports three interaction modes: acoustic VAD (server_vad), smart semantic turn-taking (smart_turn and smart_turn_v2, the latter recommended), and manual control (push-to-talk)
- The smart_turn / smart_turn_v2 modes combine acoustic perception with semantic understanding to determine turn boundaries, so meaningless backchannel sounds (such as "uh" and "ah") will not interrupt the conversation
- Speaker enhancement is supported in smart_turn / smart_turn_v2 modes; after you provide pre-recorded audio of the target user, the model can precisely lock onto the target speaker in full-duplex conversations, effectively blocking out other people's voices and background noise
How it works
Qwen-Audio adopts an event-driven architecture. The client and server send and receive data simultaneously over a persistent connection: the client continuously sends the audio stream captured by the microphone, and the server returns speech and text responses in real time. The entire interaction is driven by client events (such as session.update and input_audio_buffer.append) and server events (such as response.audio.delta and response.done), without polling.
A typical connection lifecycle is: establish a WebSocket connection → send session.update to configure session parameters → continuously send audio and receive responses → actively close the connection.
Audio formats
Direction | Format | Specifications |
|---|---|---|
Input (client → server) | PCM | 16 kHz sample rate, 16-bit bit depth, mono |
Output (server → client) | PCM | 24 kHz sample rate, 16-bit bit depth, mono |
Supported languages
Realtime voice conversation supports the following languages and Chinese dialects:
- Languages (
qwen-audio-3.1-realtime-plus,qwen-audio-3.1-realtime-flash): German (de), English (en), Spanish (es), French (fr), Indonesian (id), Italian (it), Japanese (ja), Korean (ko), Portuguese (pt), Russian (ru), Chinese (zh), Thai (th), Vietnamese (vi), Arabic (ar). - Languages (
qwen-audio-3.0-realtime-plus,qwen-audio-3.0-realtime-flash): German (de), English (en), Spanish (es), French (fr), Indonesian (id), Italian (it), Japanese (ja), Korean (ko), Portuguese (pt), Russian (ru), Chinese (zh). - Chinese and dialects: Mandarin, Cantonese, Chongqing dialect, Northeastern Mandarin, Gansu dialect, Guizhou dialect, Zhejiang dialect, Hebei dialect, Henan dialect, Hubei dialect, Hunan dialect, Jiangxi dialect, Ningbo dialect, Ningxia dialect, Qingdao dialect, Shaanxi dialect, Shanxi dialect, Shandong dialect, Shanghai dialect, Sichuan dialect, Yunnan dialect.
qwen-audio-3.1-realtime-plus or qwen-audio-3.1-realtime-flash, you can use session.input_audio_transcription.language and session.output_audio.language to specify the source language of the input audio and the target language of the output audio, respectively. For the available language codes of the two parameters, see Client events. Note that session.output_audio.language applies to text-to-speech (TTS): it makes the speech output use the target language as much as possible, but this is not guaranteed to take effect, and it does not change the language of the model's text responses.
Context capacity
The model maintains conversation history context. When the number of dialogue turns or the cumulative audio duration exceeds the following limits, earlier history is automatically discarded. The maximum duration refers to the upper limit of cumulative audio duration that can be retained in the model's context.
Model | Maximum audio turns | Maximum audio duration |
|---|---|---|
qwen-audio-3.1-realtime-plus | 50 | 300 seconds |
qwen-audio-3.1-realtime-flash | 50 | 300 seconds |
qwen-audio-3.0-realtime-plus | 50 | 300 seconds |
qwen-audio-3.0-realtime-flash | 50 | 300 seconds |
max_history_turns parameter controls the number of historical QA turns referenced during model inference, with a default value of 20 and a value range of 1-50. For how to adjust it, see History turn control.
For overall model selection recommendations for omni-modal models, see Omni-modal.
Prerequisites
- You have obtained and configured an API Key and configured it as an environment variable.
- If you connect via the AOQ protocol, you need to download and integrate the AOQ client SDK. For more information, see AOQ SDK overview.
QuickStart
The following basic WebSocket example uses qwen-audio-3.1-realtime-plus and explicitly sets the system voice longanqian_v3.1. When migrating from 3.0 Plus, update the URL query parameter model and select a voice that matches the model according to Voice configuration; the WebSocket event protocol remains unchanged.
Follow these steps to quickly experience realtime voice conversations with the Qwen-Audio model.
- Native WebSocket
realtime_quickstart.py:python realtime_quickstart.py and speak into the microphone to have a realtime conversation with the model. The server automatically detects the start and end of speech and triggers responses.Complete exampleThe following complete example adds speech interruption handling, echo suppression, and other features on top of the basic conversation. Create the following two files (they must be in the same directory):B64PCMPlayer.py
B64PCMPlayer.py
realtime_demo.py
realtime_demo.py
websockets version is lower than 11, change additional_headers in the code to extra_headers, or upgrade: pip install --upgrade websockets.python realtime_demo.py and speak into the microphone to have a realtime conversation with the model. The system automatically detects the start and end of speech and triggers responses.Session configuration
Interaction Mode
Qwen-Audio supports three interaction modes: server_vad (acoustic VAD automatically detects the start and end of speech), smart_turn (intelligent semantic turns, combining acoustic and semantic signals; smart_turn_v2 is recommended), and push-to-talk (manual control on the client side). For detailed descriptions of each mode and event interaction sequences (including sequence diagrams), see Interaction Mode.
turn_detection can only be modified before the first audio is sent (in the IDLE state). Switching interaction modes after a session is established requires a reconnection.turn_detection field in the session.update event:
- server_vad:
- smart_turn / smart_turn_v2:
smart_turn_v2 (recommended): builds on smart_turn with enhanced understanding of conversation context to better interpret interaction intent in multi-speaker scenarios. It reduces incorrect responses and incorrect interruptions caused by bystander speech or irrelevant interjections. Setting type to smart_turn still uses the original intelligent turn detection.
- push-to-talk:
manual_realtime.py
manual_realtime.py
System instructions
Use the instructions parameter to define the model's role, response style, and behavioral preferences. This parameter is configured in session.update and applies to the entire session.
- Clearly define the role (for example, "You are an intelligent voice assistant" or "You are an English speaking tutor"). You can add persona details such as name and gender.
- Specify a conversational tone and phrasing style, while emphasizing that a conversational style must not compromise content completeness—details, numbers, and specific recommendations must all be included, just expressed in a relaxed and natural way.
- Require the model to fully consider all constraints in the conversation context (such as budget, preferences, restrictions, and previously reached agreements). When multiple conditions are involved, address them one by one and do not omit key information.
- Control the output format: unless requested by the user, do not output special symbols such as emoji or Markdown formatting. Prefer plain text to ensure natural and smooth TTS narration.
- Define the response strategy: keep casual daily chat and greetings brief and natural; for complex questions involving reasoning and calculation, multiple constraints, recommendation lists, or safety advice, prioritize complete and correct answers, ensure key information (such as prices, locations, and conditions) is complete, and avoid lengthy preliminaries or repetitive rhetoric.
- Set a follow-up question strategy: follow the principle of "first answer the user's current question well, then naturally ask a follow-up question at the end to move the topic forward". Ask only one question at a time, and do not ask consecutive follow-up questions or repeatedly confirm.
- Daidai (sweet and cool companion):
- Aleng (aloof and sharp-tongued):
- Mochen (composed and charming):
- Hannibal (elegant and incisive):
- Heizi (Northeast frenemy):
Voice configuration
Use the voice parameter to set the TTS voice for model responses. Both system voices and voice cloning voices are supported. The default voice for 3.1 Plus/Flash is longanqian_v3.1, and the default voice for 3.0 Plus/Flash is longanqian.
System voices: Select a voice ID based on the model.
| Model | System voice ID |
|---|---|
qwen-audio-3.1-realtime-plus, qwen-audio-3.1-realtime-flash | Available voices include longanqian_v3.1, plus all voices in the qwen-audio-3.1-tts-plus and qwen-audio-3.1-tts-flash voice lists. You can look up voice IDs and preview voices in the lists. |
qwen-audio-3.0-realtime-plus, qwen-audio-3.0-realtime-flash | longanqian, longanlingxin, longanlingxi, longanxiaoxin, longanlufeng |
target_model to qwen-audio-3.1-realtime-plus, qwen-audio-3.1-realtime-flash, qwen-audio-3.0-realtime-plus, or qwen-audio-3.0-realtime-flash when creating it), then fill the voice_id returned by the API into the voice parameter.
Audio output speech rate
Use session.update to set speech_rate in the session object to control the speech rate of model audio output. The value range is [0.5, 2.0], and the default value is 1.0. A smaller value means a slower speech rate, and a larger value means a faster speech rate. This applies to qwen-audio-3.1-realtime-plus, qwen-audio-3.1-realtime-flash, qwen-audio-3.0-realtime-plus, and qwen-audio-3.0-realtime-flash. The following example sets this parameter to 1.2:
Output modality
Use the modalities parameter to control the content type of model output:
["audio", "text"](default): Outputs both audio and text.["text"]: Outputs text only, without generating audio. Suitable for debugging, logging, or scenarios that only require text responses.
response.modalities field of response.create.
VAD configuration
Configure VAD parameters in session.turn_detection. threshold applies to server_vad, smart_turn, and smart_turn_v2. silence_duration_ms applies only to server_vad.
Parameters | Type | Description |
|---|---|---|
| float | VAD sensitivity. A lower value makes the VAD more sensitive, more likely to recognize faint sounds (including background noise) as speech; a higher value makes it less sensitive, requiring clearer and louder speech to trigger. The value range is [-1.0, 1.0], and the default value is 0.5. |
| integer | The minimum silence duration (in milliseconds) that must be maintained after speech ends; when the timeout is reached, the model response is triggered. A lower value leads to faster responses but may cause false triggers during brief pauses. The value range is [200, 6000], and the default value is 800. For conversation scenarios, 400-800 is recommended. |
History turn control
This section applies to qwen-audio-3.1-realtime-plus, qwen-audio-3.1-realtime-flash, qwen-audio-3.0-realtime-plus, and qwen-audio-3.0-realtime-flash.
Use the max_history_turns parameter to control the number of history QA turns the model references during inference. A larger value allows the model to review more conversation history to understand the context, but increases Token consumption and inference latency.
max_history_turns is 1-50, and the default value is 20.
Optimization Suggestions:
- Short conversation scenarios (such as quick Q&A): set it to a smaller value (such as 5-10) to reduce latency.
- Long conversation scenarios (such as multi-turn customer service): set it to a larger value (such as 30-50) to ensure the model understands the full context.
Advanced features
Function Calling
Qwen-Audio supports Function Calling tool invocation, allowing the model to autonomously decide whether to call external tools based on the conversation context.
1. Register tools
Configure tools via session.update:
response.function_call_arguments.done, the client executes the tool function and writes the result back via conversation.item.create:
response.create to trigger the model to continue generating a reply based on the tool result:
function_call items and may also include both regular messages and function calls. The Function Call part is not sent to TTS for playback.realtime_demo.py from the QuickStart. Before running it, make sure B64PCMPlayer.py is in the same directory.
realtime_fc_demo.py
realtime_fc_demo.py
python realtime_fc_demo.py and speak into the microphone to experience a real-time conversation with Function Calling. For example, ask "How is the weather in Hangzhou" or "How much is a train ticket from Beijing to Shanghai", and the model will automatically call the corresponding tool function and reply based on the result.
Web search
When querying real-time information such as weather or news, you can enable web search so that the model retrieves real-time information before generating a reply. Web search is disabled by default; once enabled, the model autonomously decides whether a search is needed, and it is not triggered in every conversation turn.
Web search and Function Calling can be enabled in the same session, and this applies to qwen-audio-3.1-realtime-plus, qwen-audio-3.1-realtime-flash, qwen-audio-3.0-realtime-plus, and qwen-audio-3.0-realtime-flash.
agent policy. For billing information, see Billing Details.session.update event to set the following parameters in session:
enable_search: set it totrueto enable web search.search_options.enable_source: set it totrueto return the sources of search results.
tools tool definitions to the session object above. For how to define tools and fill call results back, see Function Calling.
For parameter details, see session.update.
2. Read search sources and usage
Model responses are still received via text and audio events. After a search is executed, you can read the following from the response object of the response.done event:
search_info.search_results: the list of search result sources, each containing the source indexindex, titletitle, and linkurl.usage.plugins.search.count: the number of searches, which should not be replaced by the number of sources.usage.plugins.search.strategy: the search policy, whose value isagent.
Conversation context management
Qwen-Audio supports managing conversation items in the conversation context via client events, which can be used to inject historical context, supplement text information, or clean up irrelevant conversation items.
-
Create a conversation item (
conversation.item.create): insert a conversation item into the conversation context. The following threeitem.typevalues are supported:message: a regular conversation message. You must specifyrole(system,user,assistant) and thecontentarray; it is suitable for injecting historical conversations or system instructions.function_call: a function call request. You must specifycall_id,name, andarguments(a JSON string). It is usually generated by the server, and the client can also use it to supplement function call records in historical context.function_call_output: the tool execution result. You must specifycall_idandoutput(a JSON string). After receivingfunction_call, the client executes the tool and writes the execution result back with this type.
previous_item_idspecifies after which existing conversation item the new conversation item is inserted, enabling content insertion at any position in the conversation history. If this parameter is not passed, the new conversation item is appended to the end of the conversation by default.- Insert a user message at a specified position:
- Write back the Function Calling execution result:
item.id specified by conversation.item.create already exists in the conversation, an error is returned.- Retrieve a conversation item (
conversation.item.retrieve): retrieve a conversation item stored on the server. For audio-type content, only the transcribed text is returned, not the raw audio data.
- Delete a conversation item (
conversation.item.delete): delete a specified item from the conversation context.
Instant hotwords
Names, product names, or industry terms are easily recognized as homophones. After instant hotwords are configured, the model prioritizes recognizing these words when transcribing input audio. For example, the project name in the same audio clip was transcribed as "7yuan project" before hotwords were configured. After "Qiyuan" is set as a hotword, the transcription result is "Qiyuan project".
The Plus and Flash models of Qwen-Audio-Realtime 3.0 and 3.1 all support instant hotwords, applicable to WebSocket, WebRTC, and AOQ access in the Beijing and Singapore regions. Before sending audio, use the following session.update event to configure hotwords.
session.updated is received. Get the final transcription from the transcript field of the conversation.item.input_audio_transcription.completed event. You can send session.update again during the session to pass in a complete new vocabulary. Setting vocabulary to {} clears the hotwords.
Ambient audio transcription
smart_turn / smart_turn_v2 modes only. When VAD detects voice activity but semantically determines it is not a valid turn (such as noise or meaningless content like "uh" or "ah"), the server does not trigger a conversation turn; instead, it passes the ASR recognition result to the client via the ambient_audio_transcription event. This transcription result is not written into the conversation context.
delta and completed stages. Developers can use this event to implement features such as ambient audio monitoring and conversation scene awareness.
Speaker enhancement
smart_turn / smart_turn_v2 modes only. Pass the URL of audio pre-recorded by the target user in session.update, and the model will precisely lock onto that speaker in duplex conversation, effectively ignoring other voices and background noise, enabling smooth duplex interaction in open scenarios.
Configuration: pass publicly accessible URLs of voiceprint audio in turn_detection.voiceprint_audio_urls of the first session.update.
- A maximum of 5 URLs are supported, and the audio format must be 16kHz PCM or WAV.
- This parameter takes effect only on the first
session.update; subsequent inputs are ignored.
voiceprint_audio_list.in_progress: registration has started, pushed beforesession.updatedis returned, carrying anitem_idthat identifies this task.voiceprint_audio_list.completed: registration succeeded, with theitem_idmatching that ofin_progress.voiceprint_audio_list.failed: registration failed, with areasonfield explaining the cause (for example, the audio URL is inaccessible). A registration failure does not block normal conversation.
Going live
Set up fault tolerance policies
- Client reconnection: The client should implement an automatic reconnection mechanism to handle network jitter. We recommend setting a reconnection signal in the
on_errorcallback and retrying with an exponential backoff policy (for example, wait 1s → 2s → 4s). - Error classification and handling: Client errors (
invalid_request_error) do not interrupt the connection; you only need to log them or adjust parameters. Server errors (server_error) terminate the connection and require reconnection. - Barge-in handling: In server_vad / smart_turn / smart_turn_v2 modes, new user speech automatically interrupts the ongoing model response (
response.donereturnsstatus=cancelled). The client should immediately stop playing buffered audio upon receivinginput_audio_buffer.speech_startedto avoid overlapping speech.
Connection lifecycle
A typical WebSocket session lifecycle is as follows:
- Establish connection: The client initiates a WebSocket connection, and the server returns the
session.createdevent. - Configure: The client sends
session.updateto set parameters such as the interaction mode, voice, and tools. This step must be completed before the first audio is sent. - Interaction: The client continuously sends audio streams (
input_audio_buffer.append), and the server performs inference triggered by VAD detection or manual triggers, returning speech and text in a streaming manner. - Close: The client proactively closes the WebSocket connection. If the connection is idle for too long, the server may also disconnect it proactively.
item_id before closing the connection. response.done only indicates that the model response has finished; the transcription result may be returned later.Latency optimization
- Audio chunk size: We recommend sending 100ms of audio data each time (16kHz × 16bit × mono = 3200 bytes per send), which ensures real-time performance while avoiding overly frequent network requests.
- Streaming playback: Decode and play audio immediately after receiving
response.audio.delta; do not wait forresponse.doneto play the entire segment. - Clear the buffer immediately on barge-in: Upon receiving
input_audio_buffer.speech_started, immediately clear the local playback buffer to prevent stale audio from continuing to play and causing perceived latency.
Supported models and regions
- Singapore
- China (Beijing)
- qwen-audio-3.1-realtime-plus
- qwen-audio-3.1-realtime-flash
- qwen-audio-3.0-realtime-plus
- qwen-audio-3.0-realtime-flash