Skip to main content

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

  1. Send run-task. Wait for task-started before sending audio.
  2. Continue sending audio while receiving result-generated events.
  3. During the task, use continue-task to update the conversation context. Continue sending audio through the audio channel.
  4. 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.
Wait for task-started before sending audio. run-task only starts and configures the task; it does not carry audio data.
headerobject
task_idstring
The task ID generated by the client (in UUID format).
eventstring
The event type. This value is always task-started.
attributesobject
Additional attributes. This value is usually empty.
payloadobject
This value is always {}.
Request:
{
  "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
    }
  }
}
Response:
{
  "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.
sentence_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.
headerobject
task_idstring
The task ID generated by the client (in UUID format).
eventstring
The event type. This value is always result-generated.
payloadobject
outputobject
sentenceobject
sentence_idinteger
The 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_timeinteger
The start time of the sentence, in milliseconds.
end_timeinteger
The end time of the sentence, in milliseconds.May be null in intermediate results or heartbeats.
textstring
The recognized text.
Intermediate text can change as recognition progresses. Update the displayed text for the same sentence_id instead of concatenating intermediate text.
sentence_beginboolean
A value of true indicates the start of a sentence. The text field may be empty at this point.
sentence_endboolean
Whether the sentence has ended (true = final result, false = intermediate result).
heartbeatboolean
If this value is true, the result is a heartbeat packet and can be ignored.
wordsarray[object]
Word-level timestamp information.
begin_timeinteger
The start time of the word, in milliseconds.
end_timeinteger
The end time of the word, in milliseconds.
textstring
The recognized text.
punctuationstring
The punctuation mark.
usageobject
Cumulative usage for the current task as of this event.
usage 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.
durationinteger
Cumulative audio duration in seconds, retained for compatibility.
input_tokensinteger
Cumulative number of input tokens.
output_tokensinteger
Cumulative number of output tokens.
total_tokensinteger
Cumulative total number of tokens: the sum of input_tokens and output_tokens.
  • Sentence start
  • Intermediate result
  • Final sentence result
Request:
{
  "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
    }
  }
}
Response:
{
  "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": []
      }
    }
  }
}

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.
headerobject
task_idstring
The task ID generated by the client (in UUID format).
eventstring
The event type. This value is always task-finished.
attributesobject
Additional attributes. This value is usually empty.
payloadobject
Contains output (an empty object) and usage (the final cumulative usage for this task). The usage fields have the same definitions as in result-generated.
Request:
{
  "header": {
    "action": "finish-task",
    "task_id": "ab4f7812-2d71-4e3d-93d3-b68ab80d3755",
    "streaming": "duplex"
  },
  "payload": {
    "input": {}
  }
}
Response:
{
  "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.
headerobject
task_idstring
The task ID generated by the client (in UUID format).
eventstring
The event type. This value is always task-failed.
error_codestring
A description of the error type.
error_messagestring
The specific cause of the error.
attributesobject
Additional attributes. This value is usually empty.
payloadobject
This 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.
Request:
{
  "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
    }
  }
}
Response:
{
  "header": {
    "task_id": "5927b897-6890-45cd-9b85-bc58bdaaadfb",
    "event": "task-failed",
    "error_code": "UNSUPPORTED_FORMAT",
    "error_message": "UNSUPPORTED_FORMAT"
  },
  "payload": {}
}