Qwen-Audio-ASR-Message server events
Server event reference for Qwen-Audio-ASR-Message: task startup, recognition results, completion, failure, and corresponding requests.
Event flow
- Send run-task. Wait for task-started before sending audio.
- Continue sending audio while receiving result-generated events.
- During the task, use continue-task to update the conversation context. Continue sending audio through the audio channel.
- After sending all audio, send finish-task and receive results until task-finished arrives. A failed task returns task-failed.
Audio is not sent in run-task: WebSocket uses binary frames, and AOQ uses an Audio Track. For connection setup, authentication, and audio transport, see WebSocket API or AOQ access.
task-started
Indicates that the task has started successfully and the client can begin sending audio.
ImportantWait for task-started before sending audio. run-task only starts and configures the task; it does not carry audio data.
headerobjecttask_idstringThe task ID generated by the client (in UUID format).
eventstringThe event type. This value is always task-started.
attributesobjectAdditional attributes. This value is usually empty.
payloadobjectThis value is always {}.
{
"header": {
"action": "run-task",
"task_id": "ab4f7812-2d71-4e3d-93d3-b68ab80d3755",
"streaming": "duplex"
},
"payload": {
"input": {},
"task_group": "audio",
"task": "asr",
"function": "recognition",
"model": "qwen-audio-3.1-asr-flash-message",
"parameters": {
"format": "pcm",
"sample_rate": 16000
}
}
}
{
"header": {
"task_id": "ab4f7812-2d71-4e3d-93d3-b68ab80d3755",
"task_uuid": "852196dba9d14bea9cf0d6e04ff0b027",
"event": "task-started",
"attributes": {}
},
"payload": {}
}
result-generated
Returns recognition results, including sentence starts, intermediate results, final sentence results, and heartbeats. Intermediate results are disabled by default; set intermediate_result_enabled=true to enable them.
Importantsentence_end=true marks the end of a sentence, not the task. You can skip heartbeat results (heartbeat=true). The task ends when task-finished arrives.
headerobjecttask_idstringThe task ID generated by the client (in UUID format).
eventstringThe event type. This value is always result-generated.
payloadobjectoutputobjectsentenceobjectsentence_idintegerThe sequence identifier of the sentence. In normal recognition results, sentence_id increments from 1. When heartbeat is true (that is, a heartbeat packet), sentence_id is always 0.
begin_timeintegerThe start time of the sentence, in milliseconds.
end_timeintegerThe end time of the sentence, in milliseconds.
May be null in intermediate results or heartbeats.
textstringThe recognized text.
NoteIntermediate text can change as recognition progresses. Update the displayed text for the same sentence_id instead of concatenating intermediate text.
sentence_beginbooleanA value of true indicates the start of a sentence. The text field may be empty at this point.
sentence_endbooleanWhether the sentence has ended (true = final result, false = intermediate result).
heartbeatbooleanIf this value is true, the result is a heartbeat packet and can be ignored.
wordsarray[object]Word-level timestamp information.
begin_timeintegerThe start time of the word, in milliseconds.
end_timeintegerThe end time of the word, in milliseconds.
textstringThe recognized text.
punctuationstringThe punctuation mark.
usageobjectCumulative usage for the current task as of this event.
Noteusage contains cumulative usage for the current task. Do not add usage values across events. After the task completes, use the final cumulative usage in task-finished.
durationintegerCumulative audio duration in seconds, retained for compatibility.
input_tokensintegerCumulative number of input tokens.
output_tokensintegerCumulative number of output tokens.
total_tokensintegerCumulative total number of tokens: the sum of input_tokens and output_tokens.
Sentence start
{
"header": {
"action": "run-task",
"task_id": "ab4f7812-2d71-4e3d-93d3-b68ab80d3755",
"streaming": "duplex"
},
"payload": {
"input": {},
"task_group": "audio",
"task": "asr",
"function": "recognition",
"model": "qwen-audio-3.1-asr-flash-message",
"parameters": {
"format": "pcm",
"sample_rate": 16000
}
}
}
{
"header": {
"task_id": "ab4f7812-2d71-4e3d-93d3-b68ab80d3755",
"event": "result-generated",
"attributes": {}
},
"payload": {
"output": {
"sentence": {
"sentence_id": 1,
"begin_time": 0,
"end_time": null,
"text": "",
"sentence_end": false,
"sentence_begin": true,
"words": []
}
}
}
}
Intermediate result
{
"header": {
"action": "run-task",
"task_id": "5d3db44d-b246-4354-9440-7574e347c163",
"streaming": "duplex"
},
"payload": {
"input": {},
"task_group": "audio",
"task": "asr",
"function": "recognition",
"model": "qwen-audio-3.1-asr-flash-message",
"parameters": {
"format": "pcm",
"sample_rate": 16000,
"intermediate_result_enabled": true
}
}
}
{
"header": {
"task_id": "5d3db44d-b246-4354-9440-7574e347c163",
"event": "result-generated",
"attributes": {}
},
"payload": {
"output": {
"sentence": {
"sentence_id": 1,
"begin_time": 0,
"end_time": null,
"text": "Please",
"sentence_end": false,
"words": [
{
"begin_time": 0,
"end_time": 0,
"text": "Please",
"punctuation": "",
"fixed": false
}
]
}
}
}
}
Final sentence result
{
"header": {
"action": "run-task",
"task_id": "ab4f7812-2d71-4e3d-93d3-b68ab80d3755",
"streaming": "duplex"
},
"payload": {
"input": {},
"task_group": "audio",
"task": "asr",
"function": "recognition",
"model": "qwen-audio-3.1-asr-flash-message",
"parameters": {
"format": "pcm",
"sample_rate": 16000
}
}
}
{
"header": {
"task_id": "ab4f7812-2d71-4e3d-93d3-b68ab80d3755",
"event": "result-generated",
"attributes": {}
},
"payload": {
"output": {
"sentence": {
"sentence_id": 1,
"begin_time": 120,
"end_time": 4040,
"text": "Please send the quarterly project report to Kellera before Friday. ",
"sentence_end": true,
"words": [
{
"begin_time": 120,
"end_time": 320,
"text": "Please",
"punctuation": "",
"fixed": false
},
{
"begin_time": 320,
"end_time": 560,
"text": " send",
"punctuation": "",
"fixed": false
},
{
"begin_time": 560,
"end_time": 760,
"text": " the",
"punctuation": "",
"fixed": false
},
{
"begin_time": 760,
"end_time": 1360,
"text": " quarterly",
"punctuation": "",
"fixed": false
},
{
"begin_time": 1360,
"end_time": 1800,
"text": " project",
"punctuation": "",
"fixed": false
},
{
"begin_time": 1800,
"end_time": 2120,
"text": " report",
"punctuation": "",
"fixed": false
},
{
"begin_time": 2120,
"end_time": 2280,
"text": " to",
"punctuation": "",
"fixed": false
},
{
"begin_time": 2280,
"end_time": 2336,
"text": " ",
"punctuation": "",
"fixed": false
},
{
"begin_time": 2336,
"end_time": 2560,
"text": "Kell",
"punctuation": "",
"fixed": false
},
{
"begin_time": 2560,
"end_time": 2800,
"text": "era",
"punctuation": "",
"fixed": false
},
{
"begin_time": 2800,
"end_time": 3160,
"text": " before",
"punctuation": "",
"fixed": false
},
{
"begin_time": 3160,
"end_time": 4040,
"text": " Friday",
"punctuation": ". ",
"fixed": false
}
],
"stash": {
"sentence_id": 2,
"text": "",
"begin_time": 4040,
"current_time": 4040,
"words": []
}
}
},
"usage": {
"duration": 4,
"input_tokens": 51,
"output_tokens": 13,
"total_tokens": 64
}
}
}
task-finished
Task processing is complete and all recognition results have been returned. The client can close the connection or reuse it to start a new task.
headerobjecttask_idstringThe task ID generated by the client (in UUID format).
eventstringThe event type. This value is always task-finished.
attributesobjectAdditional attributes. This value is usually empty.
payloadobjectContains output (an empty object) and usage (the final cumulative usage for this task). The usage fields have the same definitions as in result-generated.
{
"header": {
"action": "finish-task",
"task_id": "ab4f7812-2d71-4e3d-93d3-b68ab80d3755",
"streaming": "duplex"
},
"payload": {
"input": {}
}
}
{
"header": {
"task_id": "ab4f7812-2d71-4e3d-93d3-b68ab80d3755",
"event": "task-finished",
"attributes": {}
},
"payload": {
"output": {},
"usage": {
"duration": 4,
"input_tokens": 51,
"output_tokens": 13,
"total_tokens": 64
}
}
}
task-failed
Indicates that the task failed. Check error_code and error_message for the cause. After a task fails, the WebSocket connection is closed and cannot be reused.
headerobjecttask_idstringThe task ID generated by the client (in UUID format).
eventstringThe event type. This value is always task-failed.
error_codestringA description of the error type.
error_messagestringThe specific cause of the error.
attributesobjectAdditional attributes. This value is usually empty.
payloadobjectThis value is always {}.
This request uses an unsupported audio format to demonstrate task-failed. The error code and message depend on the cause of failure.
{
"header": {
"action": "run-task",
"task_id": "5927b897-6890-45cd-9b85-bc58bdaaadfb",
"streaming": "duplex"
},
"payload": {
"input": {},
"task_group": "audio",
"task": "asr",
"function": "recognition",
"model": "qwen-audio-3.1-asr-flash-message",
"parameters": {
"format": "invalid-format",
"sample_rate": 16000
}
}
}
{
"header": {
"task_id": "5927b897-6890-45cd-9b85-bc58bdaaadfb",
"event": "task-failed",
"error_code": "UNSUPPORTED_FORMAT",
"error_message": "UNSUPPORTED_FORMAT"
},
"payload": {}
}