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

# 快速开始

使用一张图片创建会话，并将同一个会话连接到浏览器播放器。完成后，你将看到角色的实时视频。

## 1. 开始之前

准备好 Vivix API 密钥和 Node.js 22。在启动会产生费用的会话之前，请先按照 [TRTC 浏览器播放器](https://docs.vivix.ai/cn/streaming-avatar/integrate/trtc.md)的说明准备并构建文件，但暂时不要启动服务器。播放器将直接使用下文保存的响应，不会重复创建会话。

## 2. 保存请求

在播放器目录中将以下内容保存为 `session.json`。示例使用一张公开的角色图片、720p 的 9:16 `output`，以及内置语音。请求中设置了起始图片、Persona、输出和语音。请根据你的角色调整 [Persona](https://docs.vivix.ai/cn/streaming-avatar/character/persona.md)。

> [!NOTE]
>
> 该示例刻意要求角色使用英语。若希望角色使用中文，请在实际请求中将 Persona 里的语言要求改为中文。

```json wrap theme={null}
{
  "model": "vivix-a1-stream",
  "output": {
    "aspect_ratio": "9:16",
    "resolution": "720p"
  },
  "avatars": [
    {
      "avatar_id": "host",
      "persona": "You are a warm, curious conversation companion. Speak in relaxed English, keep everyday replies brief, and acknowledge corrections without making excuses. Use small smiles and gentle nods. After a gesture, let your hands rest while listening.",
      "visual": {
        "source_images": [
          {
            "source_image_id": "portrait",
            "url": "https://static.vivi-x.ai/images/2026/08/03/650665979f5d095f.jpg",
            "media_type": "image/jpeg",
            "description": "A young woman with brown hair wears a white off-shoulder top and a pink skirt on a sunlit street beside a flower cart."
          }
        ]
      }
    }
  ],
  "pipeline_config": {
    "tts_config": {
      "tts_voice_id": "longanhuan_v3.6"
    }
  }
}
```

## 3. 创建一个会话

在服务端终端中设置 `VIVIX_API_KEY`，然后运行：

```bash theme={null}
curl https://api.vivix.ai/v1/realtime-avatar/sessions \
  -H "Authorization: Bearer $VIVIX_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary @session.json -o session-response.json
```

检查 `session-response.json`。其中的 `code` 应为 `0`，`data` 应包含 `session_id`、`control` 和 `delivery.media.trtc`。如果创建会话时出现错误，请先解决错误，再启动播放器。

## 4. 播放这个会话

在播放器文件所在目录中，运行 [TRTC 浏览器播放器](https://docs.vivix.ai/cn/streaming-avatar/integrate/trtc.md)提供的完整 `server.mjs`：

```bash theme={null}
SESSION_RESPONSE_FILE=./session-response.json node server.mjs
```

打开 `http://localhost:3000` 并点击 Start。播放器会读取已保存的连接信息并加入这个会话。看到角色视频和“Video playing”即表示播放成功。点击 Stop 可关闭同一个会话。


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