Configure a session, send audio, and return task results.
Send JSON events by controlling the WebSocket. For connection and authentication, see WebSocket integration.
Configure a session. The service confirms that the configuration has taken effect via
Sends one frame of audio in a pure WebSocket session. Audio is sent via AOQ in AOQ sessions.
Mutes audio input. The service returns
Resumes audio input. The service returns
Input user text or return the result of a frontend function. The application executes the function at most once per
Update task progress. The service returns
Provides questions requiring user input. The service returns
Returns the task result handled by this connection, or submits user text. The service returns
Add backend input in Responses mode. Then send
Initiate a new backend task. The service returns backend events via
Terminate the session. The service returns
session.update
Configure a session. The service confirms that the configuration has taken effect via session.updated. With pure WebSocket integration, audio can be sent immediately after this step. For WebRTC and AOQ, you must wait for their respective media connections to become ready.
type (string, Required)
Event type; fixed value: session.update.
event_id (string, Required)
Client event ID. Non-empty; maximum length: 128 characters.
session (object, Required)
Session configuration.
View child fields
View child fields
model (string, Required)Frontend speech model ID used for the session. Options: qwen-audio-4.0-realtime-preview or qwen-audio-3.1-realtime-flash.For duplex conversations, use qwen-audio-4.0-realtime-preview and set turn_detection.type to duplex.instructions (string, Optional)If you omit session.instructions in the initial session configuration, the frontend model uses its built-in instructions. Providing session.instructions replaces them.modalities (array, Optional)Output modality. Default includes audio and text.voice (string, Optional)System voice ID used by the frontend model. Default value: yunshu.| Voice name | Voice ID |
|---|---|
| 云舒 | yunshu |
| 小满 | xiaoman |
| 晚风 | wanfeng |
| 青柚 | qingyou |
| 破晓 | poxiao |
| 麦芽 | maiya |
| 乌龙 | wulong |
| 雪松 | xuesong |
turn_detection (object, Optional)Turn detection configuration.View child fields
View child fields
type (string, Required)Set to duplex for duplex conversations, and select qwen-audio-4.0-realtime-preview as the frontend model.input_audio_format (string, Optional)Input format. Pure WebSocket uses pcm, defaulting to 16 kHz, mono PCM16LE.output_audio_format (string, Optional)Output format. Pure WebSocket uses pcm, defaulting to 24 kHz, mono PCM16LE.tools (array[object], Optional)Frontend functions executable by the application. Default: empty array.View child fields
View child fields
type (string)Tool type. Use function for a custom function.name (string)Function name.description (string)What the function does.parameters (object)Function parameters defined using JSON Schema.View child fields
View child fields
type (string)Parameter structure. Use object for an object.properties (object)Types and constraints of parameters, keyed by the names defined by your application.required (array[string])Names of the required parameters.additionalProperties (boolean | object)Controls whether undeclared parameters are allowed. Set to false to reject them.delegation (object, Required)Task execution method.View child fields
View child fields
type (string, Required)client: Task executed by the application. responses: Backend Responses model invoked by the service.responses (object, Conditionally required)Required in Responses mode. QwenCloud passes the settings documented here to the backend model. See the Responses API for the tool definition format.View child fields
View child fields
model (string, Required)Backend Responses model ID for handling delegated tasks, e.g., qwen4-max.instructions (string, Optional)Task instructions for the backend model in Responses mode. QwenCloud supplies no built-in backend instructions.tools (array[object], Optional)Declares tools available for the backend model. The structure of each tool depends on its type. The fields below apply to custom functions (type is function).View child fields
View child fields
type (string)Tool type. Use function for a custom function.name (string)Function name.description (string)What the function does.parameters (object)Function parameters defined using JSON Schema.View child fields
View child fields
type (string)Parameter structure. Use object for an object.properties (object)Types and constraints of parameters, keyed by the names defined by your application.required (array[string])Names of the required parameters.additionalProperties (boolean | object)Controls whether undeclared parameters are allowed. Set to false to reject them.transport (object, Optional)Uses WebSocket if omitted or an empty object is passed.View child fields
View child fields
type (string, Conditionally required)Specify the transport method explicitly. websocket uses WebSocket, rtc uses WebRTC, and aoq uses AOQ.sdp (string, Conditionally required)Required when type is rtc. Pass the Offer SDP generated by the client. See WebRTC integration.aoq (object, Optional)AOQ configuration.View child fields
View child fields
ws_audio (boolean, Optional)Whether to deliver downstream audio via WebSocket in addition. Default is false.- Client mode
- Responses mode
session.input_audio.append
Sends one frame of audio in a pure WebSocket session. Audio is sent via AOQ in AOQ sessions.
type (string, Required)
Event type; fixed value: session.input_audio.append.
event_id (string, Optional)
Client event ID. Non-empty; maximum length: 128 characters.
audio (string, Required)
Base64-encoded 16 kHz, 16-bit, mono PCM16LE.
session.input_audio.mute
Mutes audio input. The service returns session.input_audio.muted.
type (string, Required)
Event type; fixed value: session.input_audio.mute.
event_id (string, Optional)
Client event ID. Non-empty; maximum length: 128 characters.
session.input_audio.unmute
Resumes audio input. The service returns session.input_audio.unmuted.
type (string, Required)
Event type; fixed value: session.input_audio.unmute.
event_id (string, Optional)
Client event ID. Non-empty; maximum length: 128 characters.
session.item.create
Input user text or return the result of a frontend function. The application executes the function at most once per call_id.
type (string, Required)
Event type; fixed value: session.item.create.
event_id (string, Optional)
Client event ID. Non-empty; maximum length: 128 characters.
item (object, Fill according to purpose.)
Session content to be written.
View child fields
View child fields
type (string, Required)Enter message or function_call_output.role (string, Fill according to type.)Example for message: user.content (array, Fill according to type.)Content of message.View child fields
View child fields
type (string, Required)Enter input_text for text input.text (string, Required)User text.call_id (string, Fill according to type.)Frontend function call ID corresponding to function_call_output.output (string, Fill according to type.)String result of function_call_output.- Return function result
- Input text
session.thinking.append
Update task progress. The service returns session.thinking.appended.
type (string, Required)
Event type; fixed value: session.thinking.append.
event_id (string, Optional)
Client event ID. Non-empty; maximum length: 128 characters.
delegation_id (string, Required)
Use the ID from session.delegation.created received over the current connection.
content (string, Required)
Task progress.
start_ms (number, Optional)
Start time on the session timeline, in milliseconds.
end_ms (number, Optional)
End time, in milliseconds. Provided in conjunction with start_ms. Both values must be finite and non-negative, and the end time must not precede the start time.
session.instruction.append
Provides questions requiring user input. The service returns session.instructions.appended.
type (string, Required)
Event type; fixed value: session.instruction.append.
event_id (string, Optional)
Client event ID. Non-empty; maximum length: 128 characters.
delegation_id (string, Required)
Use the ID from session.delegation.created received over the current connection.
task_id (string, Optional)
Typically omitted.
content (string, Required)
Information requiring user input.
start_ms (number, Optional)
Start time on the session timeline, in milliseconds.
end_ms (number, Optional)
End time, in milliseconds. Provided in conjunction with start_ms. Both values must be finite and non-negative, and the end time must not precede the start time.
session.commentary.append
Returns the task result handled by this connection, or submits user text. The service returns session.commentary.appended.
type (string, Required)
Event type; fixed value: session.commentary.append.
event_id (string, Optional)
Client event ID. Non-empty; maximum length: 128 characters.
delegation_id (string, Required when returning a task result.)
Use the ID from session.delegation.created received over the current connection.
content (string, Optional)
Task result or user text.
start_ms (number, Optional)
Start time on the session timeline, in milliseconds.
end_ms (number, Optional)
End time, in milliseconds. Provided in conjunction with start_ms. Both values must be finite and non-negative, and the end time must not precede the start time.
error (object, Optional)
Task error message.
- Return task result.
- Input text
response.item.create
Add backend input in Responses mode. Then send response.create to trigger generation.
type (string, Required)
Event type; fixed value: response.item.create.
event_id (string, Optional)
Client event ID. Non-empty; maximum length: 128 characters.
item (object, Required)
Backend input. Supports message and function_call_output.
View child fields
View child fields
type (string, Required)Input item type.role (string, Fill according to type.)Example for message: user.content (array, Fill according to type.)User message content.View child fields
View child fields
type (string, Required)Enter input_text for text input.text (string, Required)User text.call_id (string)Function call ID for function_call_output. Use the call_id returned in the backend event.output (string)Function result as a string for function_call_output.- Input text
- Return a backend function result
response.create
Initiate a new backend task. The service returns backend events via response.event. When explicitly initiated, the service returns backend events directly; only auto-delegated workflows send session.delegation.created.
type (string, Required)
Event type; fixed value: response.create.
event_id (string, Optional)
Client event ID. Non-empty; maximum length: 128 characters.
response (object, Optional)
Pass backend generation configuration. For configuration format, see Responses API.
session.close
Terminate the session. The service returns session.closed.
type (string, Required)
Event type; fixed value: session.close.
event_id (string, Required)
Client event ID. Non-empty; maximum length: 128 characters.