Skip to main content
Qwen-Audio-Live

Qwen-Audio-Live server-side events

Read session status, voice responses, and task execution results.

Receive JSON events over the control WebSocket. When using WebRTC or AOQ, wait for session.updated on that WebSocket. Once the media connection is ready, you can also receive server events over the WebRTC DataChannel or the AOQ data track. Handle events according to type. The client_event_id in the acknowledgment corresponds to the event_id in the request. The event_id of each server-side event uniquely identifies that event.

session.created

After the connection is established, the service returns default session information. After sending session.update, wait for session.updated to confirm that the configuration has taken effect. type (string, Required) Event type; fixed value: session.created. event_id (string, Required) Server-side event ID. session (object, Required) Default session information.
id (string, Required)Business session ID. AOQ Relay uses an independent sid.object (string, Required)Compatible object name, e.g., realtime.session.model (string, Required)Deployed default frontend voice model.modalities (array, Returned per model)Output modality.voice (string, Returned per model)Default voice style.turn_detection (object, Returned per model)Default turn detection configuration. The detection settings below are returned when type is server_vad.
type (string)Turn detection type.threshold (number)Voice activity detection threshold.prefix_padding_ms (integer)Length of audio retained before the detected speech start, in milliseconds.silence_duration_ms (integer)Duration of silence required to detect the end of speech, in milliseconds.create_response (boolean)Whether to generate a reply automatically when speech ends.interrupt_response (boolean)Whether to interrupt an ongoing reply when the user starts speaking.
input_audio_transcription (object, Returned per model)Audio transcription capability and its default configuration.
model (string)Model used to transcribe input audio.
model_inference (boolean, Required)The service supports integration with models. Inference and interaction begin only after the session configuration takes effect.
{
  "type": "session.created",
  "event_id": "evt_created",
  "session": {
    "id": "sess_demo",
    "object": "realtime.session",
    "model": "<default frontend model ID>",
    "modalities": [
      "text",
      "audio"
    ],
    "turn_detection": {
      "type": "server_vad"
    },
    "input_audio_transcription": {
      "model": "<transcription model ID>"
    },
    "model_inference": true
  }
}

session.updated

The session configuration has taken effect. Use the returned configuration. type (string, Required) Event type; fixed value: session.updated. event_id (string, Required) Server-side event ID. session (object, Required) Effective session configuration, including session metadata and task mode.
id (string, Required)Business session ID.model (string, Required)Effective frontend voice model.object (string, Returned per configuration)Session object type.modalities (array, Returned per configuration)Effective output modality.delegation (object, Required)Task mode.
type (string, Required)client or responses.
transport (object, Returned per configuration)Returns connection information for the selected transmission method.
type (string, Returned per configuration)When using WebRTC, the value is rtc.sdp (string, Returned per configuration)When using WebRTC, returns the Answer SDP. The client sets it as the remote description. For details, see WebRTC access.aoq (object, Returned per configuration)When using AOQ, returns temporary connection information. Use the returned sid and temporary credentials to initiate the AOQ connection within 5 minutes of receiving session.updated. For steps to connect, see AOQ access.
sid (string)AOQ session ID.aoqTokenForClient (string)Temporary token that the client uses to connect to the Relay.clientRelayCertFingerprint (string)Fingerprint of the Relay’s TLS certificate.clientRelayEndpoints (array)List of Relay addresses for the connection.
endpoint (string)Relay address.port (integer)Relay port.route_index (integer)Relay route index.
extraInfo (object)Additional connection information.
workspaceIdHash (string)Hash of the workspace.
  • WebSocket
  • WebRTC (excerpt)
  • AOQ (excerpt)
{
  "type": "session.updated",
  "event_id": "evt_updated",
  "session": {
    "id": "sess_demo",
    "object": "realtime.session",
    "model": "qwen-audio-4.0-realtime-preview",
    "modalities": [
      "text",
      "audio"
    ],
    "delegation": {
      "type": "client"
    }
  }
}

session.input_audio.muted

Input is muted. type (string, Required) Event type; fixed value: session.input_audio.muted. event_id (string, Required) Server-side event ID. client_event_id (string, Optional) Corresponds to the client’s requested event_id.
{
  "type": "session.input_audio.muted",
  "event_id": "evt_muted",
  "client_event_id": "evt_mute"
}

session.input_audio.unmuted

Input is unmuted. type (string, Required) Event type; fixed value: session.input_audio.unmuted. event_id (string, Required) Server-side event ID. client_event_id (string, Optional) Corresponds to the client’s requested event_id.
{
  "type": "session.input_audio.unmuted",
  "event_id": "evt_unmuted",
  "client_event_id": "evt_unmute"
}

session.input_transcript.delta

Receives the transcription of user speech. type (string, Required) Event type; fixed value: session.input_transcript.delta. event_id (string, Required) Server-side event ID. delta (string, Required) The transcription text returned in this response. start_ms (number, Required) Start time on the session timeline, in milliseconds. end_ms (number, Required) End time on the session timeline, in milliseconds.
{
  "type": "session.input_transcript.delta",
  "event_id": "evt_input_transcript",
  "delta": "帮我查库存。",
  "start_ms": 1600,
  "end_ms": 1600
}

session.output_transcript.delta

Receives subtitles for the frontend voice reply. Subtitle timestamps are used to locate positions on the session timeline. type (string, Required) Event type; fixed value: session.output_transcript.delta. event_id (string, Required) Server-side event ID. delta (string, Required) The reply text returned in this response. start_ms (number, Required) Start time on the session timeline, in milliseconds. end_ms (number, Required) End time on the session timeline, in milliseconds.
{
  "type": "session.output_transcript.delta",
  "event_id": "evt_output_transcript",
  "delta": "库存还有七把雨伞。",
  "start_ms": 5400,
  "end_ms": 5400
}

session.output_audio.delta

Receives an audio chunk from the frontend voice. type (string, Required) Event type; fixed value: session.output_audio.delta. event_id (string, Optional) Server-side event ID. delta (string, Required) Base64-encoded 24 kHz mono PCM16LE raw audio. After decoding, the byte count is even. The audio has no WAV file header. start_ms (number, Required) Start time on the session timeline, in milliseconds. end_ms (number, Required) End time on the session timeline, in milliseconds.
{
  "type": "session.output_audio.delta",
  "delta": "AAAAAA==",
  "start_ms": 5400,
  "end_ms": 5420
}

session.delegation.created

The frontend model dispatches a task. This event is received in both Client mode and Responses mode. When returning the task result, use the delegation_id from the corresponding task event. type (string, Required) Event type; fixed value: session.delegation.created. event_id (string, Required) Server-side event ID. offset_ms (number, Required) The offset of this dispatch on the session timeline, in milliseconds. delegation_id (string, Required) The task ID associated with this dispatch. task_id (string, Optional) Task ID. Used in the return payload as delegation_id. summary (string, Returned upon task dispatch) Summary of the dispatched task in this response. context (object, Returned upon task dispatch) Context snapshot at the time the task is accepted.
summary (string, Required)Context summary.messages (array[object], Returned upon task dispatch)Context messages.
seq (integer)Sequence number of the message in the context.item_id (string)Message item ID.role (string)Role of the message sender.source (string)Source of the message.audio_start_ms (integer)Start offset of the audio on the session timeline, in milliseconds.audio_end_ms (integer)End offset of the audio on the session timeline, in milliseconds.playback (string)Audio playback status.content (string)Message text.
incomplete (boolean)Whether the context snapshot is incomplete.truncated (boolean)Whether the context snapshot was truncated.
supplements (array, Returned per task) Additional content accepted in this batch and their respective contexts.
summary (string, Required)Supplementary content summary.context (object, Returned upon task dispatch)Context snapshot at the time the task is accepted.
summary (string, Required)Context summary.messages (array, Returned upon task dispatch)Context messages.
arguments (string, Optional) Compatible field. A JSON string that may contain summary.
{
  "type": "session.delegation.created",
  "event_id": "evt_delegation",
  "offset_ms": 3600,
  "delegation_id": "task_stock",
  "task_id": "task_stock",
  "summary": "查询雨伞库存。",
  "context": {
    "summary": "",
    "messages": [
      {
        "seq": 1,
        "item_id": "item_stock_001",
        "role": "user",
        "audio_start_ms": 900,
        "audio_end_ms": 3600,
        "content": "查询雨伞库存。"
      }
    ],
    "incomplete": false,
    "truncated": false
  },
  "supplements": [
    {
      "summary": "查询雨伞库存。",
      "context": {
        "summary": "",
        "messages": []
      }
    }
  ],
  "arguments": "{\"summary\":\"查询雨伞库存。\"}"
}

session.event

Receives frontend function calls. Uses call_id to correlate results. type (string, Required) Event type; fixed value: session.event. event_id (string, Required) Server-side event ID. client_event_id (string, Optional) Corresponds to the client’s requested event_id. event (object, Required) Frontend model function call event.
type (string, Required)Inner event name.item (object, Returns per event.)Function call item.
type (string, Required)The function call item is function_call.name (string, Required)Function name.call_id (string, Required)Call ID.arguments (string, Required)Function arguments in JSON string format.id (string, Returns per event.)Call item ID.status (string, Returns per event.)Call item status.
output_index (number, Returns per event.)Output location of the call item.response_id (string, Returns per event.)Frontend response ID.
{
  "type": "session.event",
  "event_id": "evt_frontend_tool",
  "event": {
    "type": "response.output_item.added",
    "item": {
      "type": "function_call",
      "name": "lookup_stock",
      "call_id": "call_stock",
      "arguments": "{\"item\":\"雨伞\"}",
      "id": "item_stock",
      "status": "completed"
    },
    "output_index": 0,
    "response_id": "resp_frontend"
  }
}

response.event

Receives backend generation or task events. The inner response.completed indicates the end of backend generation. Frontend voice responses have their own subtitle and audio events. type (string, Required) Event type; fixed value: response.event. event_id (string, Required) Server-side event ID. delegation_id (string, Returns per event.) Associated task ID. client_event_id (string, Optional) Corresponds to the client’s requested event_id. event (object, Required) Backend native event or task event.
type (string, Required)Inner event name.response (object, Returns per event.)Backend response. Fields vary by event.
id (string, Returns per event.)Backend response ID.usage (object, Optional)Backend model token usage.
input_tokens (integer, Returns per event.)Number of input tokens consumed by the backend model.output_tokens (integer, Returns per event.)Number of output tokens generated by the backend model.total_tokens (integer, Returns per event.)Total number of input and output tokens.
{
  "type": "response.event",
  "event_id": "evt_backend_completed",
  "delegation_id": "task_calc",
  "event": {
    "type": "response.completed",
    "response": {
      "id": "resp_calc",
      "usage": {
        "input_tokens": 28,
        "output_tokens": 12,
        "total_tokens": 40
      }
    }
  }
}

session.thinking.appended

Service has accepted the task progress. For request session.thinking.append, the acknowledgment can be matched using the associated field. type (string, Required) Event type; fixed value: session.thinking.appended. event_id (string, Required) Server-side event ID. start_ms (number, Required) Start time on the session timeline, in milliseconds. end_ms (number, Required) End time on the session timeline, in milliseconds. client_event_id (string, Optional) Corresponds to the client’s requested event_id.
{
  "type": "session.thinking.appended",
  "event_id": "evt_ack",
  "start_ms": 2000,
  "end_ms": 2000,
  "client_event_id": "evt_client_request"
}

session.instructions.appended

Service has accepted the follow-up content. For request session.instruction.append, the acknowledgment can be matched using the associated field. type (string, Required) Event type; fixed value: session.instructions.appended. event_id (string, Required) Server-side event ID. start_ms (number, Required) Start time on the session timeline, in milliseconds. end_ms (number, Required) End time on the session timeline, in milliseconds. client_event_id (string, Optional) Corresponds to the client’s requested event_id.
{
  "type": "session.instructions.appended",
  "event_id": "evt_ack",
  "start_ms": 2000,
  "end_ms": 2000,
  "client_event_id": "evt_client_request"
}

session.commentary.appended

Service has accepted the result or text. For request session.commentary.append, the acknowledgment can be matched using the associated field. type (string, Required) Event type; fixed value: session.commentary.appended. event_id (string, Required) Server-side event ID. start_ms (number, Required) Start time on the session timeline, in milliseconds. end_ms (number, Required) End time on the session timeline, in milliseconds. client_event_id (string, Optional) Corresponds to the client’s requested event_id.
{
  "type": "session.commentary.appended",
  "event_id": "evt_ack",
  "start_ms": 2000,
  "end_ms": 2000,
  "client_event_id": "evt_client_request"
}

session.usage.updated

After session activation, the service reports cumulative billing duration every 5 seconds; reports are also sent during idle periods. The current value takes the latest usage.seconds, and the final value is read from session.closed. Backend model token usage is available in response.event. type (string, Required) Event type; fixed value: session.usage.updated. event_id (string, Required) Server-side event ID. usage (object, Required) Session usage.
seconds (number, Required)Cumulative billing duration for the session (in seconds). This is the greater of 3 seconds and the elapsed session duration.
context_window (object, Optional) Context usage.
usage_ratio (number, Optional)Token usage divided by the context limit. Results may be delayed.
{
  "type": "session.usage.updated",
  "event_id": "evt_usage",
  "usage": {
    "seconds": 32.5
  },
  "context_window": {
    "usage_ratio": 0.12
  }
}

session.closed

The session has ended. Stop sending events and release resources. To continue the conversation, establish a new connection and initialize a new session. type (string, Required) Event type; fixed value: session.closed. event_id (string, Required) Server-side event ID. reason (string, Required) Reason for closure. Possible values are close_requested, expired, content, remote_hangup, or connection_lost. session (object, Required) Configuration snapshot returned when the session closes.
id (string, Returned with the snapshot.)Business session ID.object (string, Returned with the snapshot.)Session object type.status (string, Returned with the snapshot.)The status in the snapshot may still show active. Use the session.closed event to determine that the session has closed.model (string, Returned with the snapshot.)Frontend speech model used for the session.
usage (object, Required) Final usage metrics at session termination.
seconds (number, Required)Cumulative billing duration for the session (in seconds). This is the greater of 3 seconds and the elapsed session duration.
{
  "type": "session.closed",
  "event_id": "evt_closed",
  "reason": "close_requested",
  "session": {
    "id": "sess_demo",
    "object": "realtime.session",
    "status": "active",
    "model": "qwen-audio-4.0-realtime-preview"
  },
  "usage": {
    "seconds": 45.8
  }
}

error

Check the request and session status based on the error code. After receiving a close event, reestablish the connection. type (string, Required) Event type; fixed value: error. event_id (string, Required) Server-side event ID. error (object, Required) Error details.
type (string, Required)invalid_request_error or server_error.code (string, Required)Error code. For example, invalid_session_configuration or invalid_event_state.message (string, Required)Error description.event_id (string, Optional)Corresponds to the client’s requested event_id.
{
  "type": "error",
  "event_id": "evt_server_error",
  "error": {
    "type": "invalid_request_error",
    "code": "invalid_session_configuration",
    "message": "Invalid session configuration",
    "event_id": "evt_update_client"
  }
}