> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vivix.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 服务端事件

服务端事件是服务通过 Streaming Avatar WSS 连接（`control.url`，指向 `/v1/realtime-avatar/control`）发送的 JSON 消息。每个事件都包含 `event_id` 和 `type`。错误事件还可能包含导致失败的客户端事件 `event_id`。

**向前兼容性。** Vivix 可能会逐步添加新的事件类型和字段。客户端必须忽略无法识别的事件类型和字段，不能因收到未知数据而断开连接。

## 我应该监听哪个事件？

| 如果你需要 | 监听 |
| - | - |
| 确认响应已被接受并获取其 ID | `response.created` |
| 显示实时文本或字幕 | `response.output_text.delta` |
| 显示流式文本项的最终文本 | `response.output_text.done` |
| 接收最终输出项，包括已完成的函数调用 | `response.output_item.done` |
| 检查响应的最终状态 | `response.done` |
| 跟踪角色媒体何时开始或停止通过 RTC 渲染 | `response.render.started` 和 `response.render.stopped` |
| 跟踪用户语音活动和转录 | `input_audio.speech_started`，`input_audio.speech_stopped` 和 `conversation.item.input_audio_transcription.*` |

## 错误事件

| 事件 | 作用 |
| - | - |
| [`error`](https://docs.vivix.ai/cn/streaming-avatar/api-references/server-events/error) | 客户端或服务端处理失败时发送。 |

## 会话事件

| 事件 | 作用 |
| - | - |
| [`session.closed`](https://docs.vivix.ai/cn/streaming-avatar/api-references/server-events/session-closed) | 当会话关闭时，服务尝试在断开剩余控制连接之前发送此事件。 |
| [`session.updated`](https://docs.vivix.ai/cn/streaming-avatar/api-references/server-events/session-updated) | 在应用更新后返回会话设置。 |
| [`session.update.done`](https://docs.vivix.ai/cn/streaming-avatar/api-references/server-events/session-update-done) | 返回已接受的 `session.update` 的最终处理结果。 |
| [`session.bootstrap.opening.done`](https://docs.vivix.ai/cn/streaming-avatar/api-references/server-events/session-bootstrap-opening-done) | 会话初始化的最终事件可能会向新的控制连接重放。 |

## 注册事件

| 事件 | 作用 |
| - | - |
| [`asset.added`](https://docs.vivix.ai/cn/streaming-avatar/api-references/server-events/asset-added) | 确认图像引用和可重用脚本资产的注册。 |
| [`avatar.added`](https://docs.vivix.ai/cn/streaming-avatar/api-references/server-events/avatar-added) | 确认 `avatar.add` 事件已被接受，新角色可通过 `session.update` 选择。 |

## 对话事件

| 事件 | 作用 |
| - | - |
| [`conversation.item.created`](https://docs.vivix.ai/cn/streaming-avatar/api-references/server-events/conversation-item-created) | 报告由客户端创建或在生成响应时创建的新对话项。 |
| [`conversation.item.retrieved`](https://docs.vivix.ai/cn/streaming-avatar/api-references/server-events/conversation-item-retrieved) | 返回通过 `conversation.item.retrieve` 请求的对话项。 |
| [`conversation.item.deleted`](https://docs.vivix.ai/cn/streaming-avatar/api-references/server-events/conversation-item-deleted) | 确认已删除对话项。 |

## 音频事件

| 事件 | 作用 |
| - | - |
| [`input_audio.speech_started`](https://docs.vivix.ai/cn/streaming-avatar/api-references/server-events/input-audio-speech-started) | 服务在输入音频流中检测到用户开始说话时发送。 |
| [`input_audio.speech_stopped`](https://docs.vivix.ai/cn/streaming-avatar/api-references/server-events/input-audio-speech-stopped) | 服务检测到用户停止说话时发送。 |

## 转录事件

| 事件 | 作用 |
| - | - |
| [`conversation.item.input_audio_transcription.delta`](https://docs.vivix.ai/cn/streaming-avatar/api-references/server-events/conversation-item-input-audio-transcription-delta) | 启用转录后，流式返回用户音频项的部分转录文本。 |
| [`conversation.item.input_audio_transcription.completed`](https://docs.vivix.ai/cn/streaming-avatar/api-references/server-events/conversation-item-input-audio-transcription-completed) | 返回用户音频项的最终转录文本。 |
| [`conversation.item.input_audio_transcription.failed`](https://docs.vivix.ai/cn/streaming-avatar/api-references/server-events/conversation-item-input-audio-transcription-failed) | 报告特定用户音频项的转录失败。 |

## 响应事件

**生命周期的区别。** `response.created` 和 `response.done` 描述响应资源及其逻辑输出流。`response.render.started` 和 `response.render.stopped` 描述可见或可听的角色内容通过 RTC 渲染的过程。对于进入角色渲染阶段的响应，`response.render.stopped` 会先于 `response.done` 发送。无需渲染的响应（例如仅包含工具调用的响应）会直接进入 `response.done`。

| 事件 | 作用 |
| - | - |
| [`response.created`](https://docs.vivix.ai/cn/streaming-avatar/api-references/server-events/response-created) | 确认创建了响应并返回其 ID。 |
| [`response.done`](https://docs.vivix.ai/cn/streaming-avatar/api-references/server-events/response-done) | 响应进入最终状态时发送。 |
| [`response.render.started`](https://docs.vivix.ai/cn/streaming-avatar/api-references/server-events/response-render-started) | 归属于某个响应的角色输出开始通过 RTC 渲染时返回。 |
| [`response.render.stopped`](https://docs.vivix.ai/cn/streaming-avatar/api-references/server-events/response-render-stopped) | 归属于某个响应的角色输出停止通过 RTC 渲染时返回。 |
| [`response.output_item.done`](https://docs.vivix.ai/cn/streaming-avatar/api-references/server-events/response-output-item-done) | 输出项完成流式传输时返回。 |
| [`response.output_text.delta`](https://docs.vivix.ai/cn/streaming-avatar/api-references/server-events/response-output-text-delta) | 流式返回增量的助手文本，包括与 RTC 语音媒体关联的文本。 |
| [`response.output_text.done`](https://docs.vivix.ai/cn/streaming-avatar/api-references/server-events/response-output-text-done) | 返回最终的助手文本，包括与 RTC 语音媒体关联的文本。 |

## 继续阅读

[Persona](https://docs.vivix.ai/cn/streaming-avatar/character/persona.md) · [语音识别](https://docs.vivix.ai/cn/streaming-avatar/integrate/speech-recognition.md) · [文本模型](https://docs.vivix.ai/cn/streaming-avatar/integrate/dialogue-model.md) · [文本转语音](https://docs.vivix.ai/cn/streaming-avatar/integrate/speech-synthesis.md) · [短语音提示](https://docs.vivix.ai/cn/streaming-avatar/interaction/acknowledgement.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.