This page documents client-to-server events for the Qwen-ASR Realtime WebSocket API. Each section covers an event type, its parameters, and server responses.
User guide: For the model overview, features, and complete sample code, see Real-time speech recognition
session.update
Used to update the session configuration. We recommend sending this event first after the WebSocket connection is established. We recommend sending this event immediately after the WebSocket connection is successfully established, as the first step of the interaction. If it is not sent, the system uses the default configuration.
After successfully processing this event, the server sends a 服务端事件 event as a confirmation.
Parameter | Type | Required | Description |
|---|
type | string | Yes | The event type. Fixed to session_update. | event_id | string | Yes | The event ID. | session | object | Yes | The object that contains the session configuration. | session.input_audio_format | string | No | Audio format. Supports pcm and opus. Default: pcm. | session.sample_rate | integer | No | Audio sample rate (Hz). Supports 16000 and 8000. Default: 16000. When set to 8000, the server first upsamples the audio to 16,000 Hz before recognition, which may introduce slight latency. We recommend using it only when the source audio is 8,000 Hz (such as telephone lines). | session.input_audio_transcription | object | No | Speech recognition-related configuration. | session.input_audio_transcription.language | string | No | The source language of the audio. | session.turn_detection | object | No | VAD (Voice Activity Detection) configuration. It is the switch that enables/disables VAD mode: if it is set to null, VAD mode is disabled and Manual mode is enabled; otherwise, the opposite. | session.turn_detection.type | string | No, required when turn_dection is present | Fixed to server_vad. | session.turn_detection.threshold | float | No | VAD detection threshold. We recommend setting this value to 0.0. Default: 0.2. Valid range: [-1, 1]. A lower threshold increases the sensitivity of the VAD and may misclassify background noise as speech. A higher threshold reduces the sensitivity, which helps reduce false triggers in noisy environments. | session.turn_detection.silence_duration_ms | integer | No | VAD utterance-break detection threshold (ms). Silence lasting longer than this threshold is considered the end of an utterance. We recommend setting this value to 400. Default: 800. Valid range: [200, 6000]. A lower value (such as 300 ms) allows the model to respond faster, but may cause unreasonable utterance breaks at natural pauses. A higher value (such as 1,200 ms) better handles pauses within long utterances, but increases the overall response latency. |
| {
"event_id": "event_123",
"type": "session.update",
"session": {
"input_audio_format": "pcm",
"sample_rate": 16000,
"input_audio_transcription": {
"language": "zh"
},
"turn_detection": {
"type": "server_vad",
"threshold": 0.0,
"silence_duration_ms": 400
}
}
}
|
Appends an audio data chunk to the server's input buffer. This is the core event for streaming audio.
Differences in different scenarios:
- VAD mode: The audio buffer is used for voice activity detection, and the server automatically decides when to commit audio for recognition.
- Non-VAD mode: The client can control the amount of audio data in each event. The
audio field of a single input_audio_buffer.append event can contain up to 15 MiB. We recommend streaming smaller audio chunks for faster responses.
Important note: The server does not send any confirmation response for input_audio_buffer.append events.
Parameter | Type | Required | Description |
|---|
type | string | Yes | The event type. Fixed to input_audio_buffer.append. | event_id | string | Yes | The event ID. | audio | string | Yes | Base64-encoded audio data. |
| {
"event_id": "event_2728",
"type": "input_audio_buffer.append",
"audio": "<audio> by base64"
}
|
In non-VAD mode, this event manually triggers recognition. It notifies the server that the client has finished sending a complete utterance, so that all audio data in the current buffer is recognized as a whole.
Disabled scenarios: VAD mode.
After successful processing, the server sends an input_audio_buffer.committed event as a confirmation response.
Parameter | Type | Required | Description |
|---|
type | string | Yes | The event type. Fixed to input_audio_buffer.commit. | event_id | string | Yes | The event ID. |
| {
"event_id": "event_789",
"type": "input_audio_buffer.commit"
}
|
session.finish
Ends the current session.
Server response flow:
- Speech detected: After the server completes the final speech recognition, it sends a
conversation.item.input_audio_transcription.completed event containing the recognition result, followed by a session.finished event to mark the end of the session.
- No speech detected: The server sends the
session.finished event directly.
After the client receives the session.finished event, it must actively disconnect.
Parameter | Type | Required | Description |
|---|
type | string | Yes | The event type. Fixed to session_finish. | event_id | string | Yes | The event ID. |
| {
"event_id": "event_341",
"type": "session.finish",
}
|