Event types
Values of type in SSE frames:
| type | Description |
|---|---|
message | Assistant output message; may be streamed in chunks |
reasoning | Assistant thinking process; may be streamed in chunks when event_deltas[]=reasoning is enabled |
tool_call | Built-in tool call request |
tool_call_output | Built-in tool execution result |
tool_approval_request | Tool approval request; whether a tool requires approval is determined by this event; data carries batch_id, call_id, name, arguments, and tool_type |
tool_approval_response | Tool approval decision; a bidirectional event. When a plain interrupt is sent under requires_action, the server issues result=deny for each not-yet-executed call in the batch (including decided-but-not-executed ones), accompanied by the corresponding *_call_output (is_error=true); this pairing is for display and audit only and is best-effort — the pending set is still governed by pending_call_ids |
function_call | Self-hosted function call request; the client must return function_call_output |
function_call_output | Server echo confirming the received function result |
mcp_call | MCP tool call request |
mcp_call_output | MCP tool execution result |
session_status | Session state change, including stop_reason |
type=error is a separate branch: error details live in the top-level error object of the Message (error.code / error.message), not in content[].data.
is_error
Appears only on tool_call_output / mcp_call_output, written at the top level of the Message (not inside content[].data): true means execution failed, was interrupted, or was denied. data remains ToolCallOutput / McpCallOutput, containing at least call_id and output. Read the top-level is_error for success/failure and data.output for the output.
Delta streaming
By default, each event is delivered as a single complete Message (status: "completed") once it finishes generating. To have text-based events (such as message and reasoning) pushed chunk by chunk as they are generated, enable delta streaming for specific event types with the event_deltas[] query parameter at request time. Repeat the parameter to declare multiple types; event types that are not declared are still delivered as a single complete Message.
event_id:
Frame type | Description |
|---|---|
event_start | Event start frame; event.id is the id of the final complete Message for this event, and event.type is the event type (message / reasoning); this frame carries no content; object is message and status is in_progress |
event_delta | Delta frame; event_id matches the event.id from event_start; for message, the newly added chunk is in delta.content; for reasoning, the newly added thinking text is in delta.reasoning; delta.index is the content block index |
message / reasoning | The complete Message emitted when the event finishes (object: "message", status: "completed"); content holds the aggregated full content, identical to the non-delta case |
event_delta frame:
| Field | Description |
|---|---|
type | Always event_delta |
object | Always content |
status | Always in_progress |
event_id | ID of the owning event, equal to event.id from event_start and to the id of the final complete Message; used to merge delta frames into the corresponding event |
delta.type | content_delta for message, reasoning_delta for reasoning |
delta.index | Index of the content block in the content array |
delta.content | The newly added ContentBlock chunk for message, e.g. {"type":"text","text":"…"} |
delta.reasoning | The newly added thinking text chunk for reasoning |
reasoning and message):
event_delta's delta.content (message) or delta.reasoning (reasoning) in order by event_id + delta.index; the complete Message emitted at the end carries the aggregated full content and can be used for validation. If a reasoning event has no event_delta, use the complete Message.Authorizations
DashScope API Key
Header Parameters
固定为 text/event-stream
Path Parameters
Query Parameters
为指定事件类型开启 Delta 增量流,文本内容将在生成过程中逐块推送。可重复传入以声明多个类型(如 message、reasoning);未声明的类型仍以单帧完整 Message 下发。开启后该类型事件先下发 type=event_start 帧(event.id 即最终完整 Message 的 id),随后下发若干 type=event_delta 增量帧(message 的新增片段在 delta.content,reasoning 的新增思考文本在 delta.reasoning,delta.index 为内容块序号),最后下发聚合后的完整 Message;客户端按 event_id + delta.index 顺序累加 delta.content 或 delta.reasoning
Response
恒为 message
事件 ID(前缀 msg_ 或 out_)。客户端用此 ID 在业务层去重
ISO 8601 时间戳
服务端推送事件类型,详见事件类型表。type=error 见独立分支
ContentBlock 数组:含发送侧的 text/image/video/file/data;响应侧另可出现 audio(工具输出附件)与 refusal(模型拒绝)
仅 tool_call_output / mcp_call_output 出现,写在 Message 顶层(不在 content[].data 内):true 表示执行失败/中断/拒绝。读顶层 is_error 判成败,读 data.output 取输出
事件附加信息(如 thread_id、call_id 等)