> ## 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.

# avatar.add

在会话进行期间注册其他角色。角色只能新增：在 v1 中，已有的 `avatar_id` 不能修改或替换。新增角色不会自动成为当前角色；收到 `avatar.added` 后，使用 `session.update` 选择角色。如果事件中的任一角色无效，则该事件中的所有角色都不会被注册。

## 事件字段

**event\_id** `string`

客户端为本事件生成的 ID。

**type** `string` *required*

事件类型。必须为 `avatar.add`。

**avatars** `array` *required*

需要注册的其他角色定义。使用与创建会话接口中 `avatars[]` 相同的角色对象结构。

**avatars\[].avatar\_id** `string` *required*

调用方定义的角色 ID，在会话中必须唯一。

**avatars\[].persona** `string` *required*

描述角色的身份、说话方式、回应习惯、动作偏好和聆听行为。Vivix 会根据该 Persona 自动准备角色行为。详情请参阅[编写 Persona](https://docs.vivix.ai/cn/streaming-avatar/character/persona.md)。

**avatars\[].voice** `object`

可选的角色级 TTS 配置，适用于省略 `pipeline_config.tts_config` 且不同角色需要不同音色的会话。提供 `provider`、`provider_voice_id` 和 `model`。其他情况请省略该对象；新增角色会使用会话 TTS 配置。

**avatars\[].voice.provider** `string` *required*

TTS 服务商，例如 `qwen-audio-3.0-tts-flash_ws`、`elevenlabs` 或 `qwen3tts`。必须与 `provider_voice_id` 和 `model` 一同提供。

**avatars\[].voice.provider\_voice\_id** `string` *required*

服务商侧的音色或风格 ID。必须与 `provider` 和 `model` 一同提供。

**avatars\[].voice.model** `string` *required*

服务商的 TTS 模型 ID。必须与 `provider` 和 `provider_voice_id` 一同提供。

**avatars\[].voice.speed** `number`

语速倍率。有效范围为 0.7–1.2。

**avatars\[].visual** `object`

角色视频的视觉渲染配置。当角色可在 `video_avatar` 模式中被选中时必填。

**avatars\[].visual.source\_images** `array`

该角色可用的已注册源图像。使用基于图像的角色视频渲染时必填。

**avatars\[].visual.source\_images\[].source\_image\_id** `string` *required*

由调用方定义的源图像 ID，在角色内必须唯一。

**avatars\[].visual.source\_images\[].url** `string` *required*

角色视频源图像的 URL。宽高比应与会话的 `output.aspect_ratio`（`9:16` 或 `16:9`）一致；不匹配的图像会明显降低视频质量。

**avatars\[].visual.source\_images\[].description** `string`

人物、姿势和场景的可选描述。

**avatars\[].visual.source\_images\[].media\_type** `string` *required*

图像媒体类型，例如 `image/png` 或 `image/jpeg`。

**avatars\[].visual.default\_source\_image\_id** `string`

只有一张可用源图像时可以省略。存在多张图像且未显式提供 `source_image_id` 时，使用该字段选择初始图像。

```json avatar.add theme={null}
{
  "event_id": "evt_avatar_add_001",
  "type": "avatar.add",
  "avatars": [
    {
      "avatar_id": "host_c",
      "persona": "You are Host C, a practical product specialist. Give clear, concise answers and use small gestures while explaining. Listen with relaxed eye contact.",
      "visual": {
        "source_images": [
          {
            "source_image_id": "front",
            "url": "https://api.vivix.ai/host-c-front.png",
            "description": "A man facing the camera in a brightly lit studio, front view.",
            "media_type": "image/png"
          }
        ],
        "default_source_image_id": "front"
      }
    }
  ]
}
```


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