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

# 设计音色

> 根据文本描述创建音色，无需参考音频。启动会话时，将返回的 `voice_id` 传给 `pipeline_config.tts_config.tts_voice_id`。

> [accordion] 创建会话时使用音色
>
> ```json theme={null}
> {
>   "pipeline_config": {
>     "tts_config": {
>       "tts_voice_id": "voice_8f2c1a4e"
>     }
>   }
> }
> ```
>
> 只需提供 `tts_voice_id`：服务会为该音色填充 `tts_provider` 和 `tts_model_id`。

> [accordion] 这与克隆音色有什么区别？
>
> 两个端点以相同结构返回可用音色，区别在于音色的来源：
>
> | | 克隆音色 | 设计音色 |
> | - | - | - |
> | 输入 | 参考音频（`file_id`） | 文本描述（`instruction`） |
> | 是否需要先录制音频 | 是 | 否 |
> | 额外响应字段 | — | `preview_audio_url` |
> | 是否计入 `max_voices` | 是 | 是，共用同一配额 |
>
> 两者共用一个音色配额，因此设计音色与克隆音色一样，会计入 `max_voices` 上限。

> [accordion] 编写 `instruction`
>
> `instruction` 描述音色，而不是要说的内容。应具体描述表达方式：
>
> ```text wrap theme={null}
> A warm female narrator in her thirties, slightly husky, unhurried pace, gentle emphasis on the ends of sentences.
> ```

> [accordion] 预览音频
>
> `preview_audio_url` 是长期有效、无需鉴权的 WAV（单声道、16 kHz），可以直接在 `<audio>` 元素中播放或下载。
>
> 无法生成预览时，该字段会**缺失**。缺少预览并不表示音色创建失败——音色仍可用于会话。无需轮询状态字段：接口返回响应即表示音色已经可用。

> [accordion] 错误
>
> 错误响应使用相同的 `{code, message, data}` 封装；非零 `code` 表示具体错误。
>
> | 情况 | 错误码 |
> | - | - |
> | 缺少 `instruction` 或 `name` | `20003 missing required parameter` |
> | `language` 不是 `zh` 或 `en`，且缺少 `sample_text` | `20003 missing required parameter` |
> | `instruction` 或 `sample_text` 超过 1500 个字符 | `20004 invalid parameter` |
> | `name` 超过 100 个字符 | `20004 invalid parameter` |
> | `language` 无效 | `20004 invalid parameter` |
> | 达到音色配额 `max_voices`（HTTP 403） | `30010 voice clone quota exceeded` |
> | 设计服务商调用失败（HTTP 502） | `30007 voice clone provider failed` |
> | API 密钥缺失或无效 | `10001 missing api key` 或 `10003 invalid api key` |


## OpenAPI

````yaml cn/streaming-avatar/api-references/openapi.json POST /v1/voices/design
openapi: 3.1.0
info:
  title: Vivix Streaming Avatar API 中文参考
  version: 1.0.0
  description: Streaming Avatar 会话、音色和角色的 REST 接口。
servers:
  - url: https://api.vivix.ai
security:
  - bearerAuth: []
paths:
  /v1/voices/design:
    post:
      summary: 设计音色
      description: >-
        根据文本描述创建音色，无需参考音频。启动会话时，将返回的 `voice_id` 传给
        `pipeline_config.tts_config.tts_voice_id`。
      operationId: designVoice
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                instruction:
                  type: string
                  description: 描述要合成的音色，包括音色、年龄、说话风格和语速。最多 1500 个字符。必填。
                name:
                  type: string
                  description: 显示名称，最多 100 个字符。必填。
                sample_text:
                  type: string
                  description: >-
                    生成的音色预览中要朗读的文本。最多 1500 个字符。当 `language` 既不是中文也不是英语时必填；`zh` 和
                    `en` 可选，此时服务会提供默认文本。
                language:
                  type: string
                  description: >-
                    `sample_text`
                    的语言：`zh`（中文）、`en`（英语）、`fr`（法语）、`de`（德语）、`ja`（日语）、`ko`（韩语）、`ru`（俄语）、`pt`（葡萄牙语）、`th`（泰语）、`id`（印度尼西亚语）、`vi`（越南语）、`it`（意大利语）、`es`（西班牙语）、`ms`（马来语）、`fil`（菲律宾语）、`ar`（阿拉伯语）。
              required:
                - instruction
                - name
            example:
              instruction: A mature male news anchor with a deep, steady voice
              sample_text: Welcome to tonight's broadcast.
              language: zh
              name: Studio Anchor
      responses:
        '200':
          description: 成功
          content:
            application/json:
              schema:
                type: object
                required:
                  - code
                  - message
                  - data
                properties:
                  code:
                    type: integer
                    description: 成功时为 `0`；其他值均为错误码。
                  message:
                    type: string
                    description: '`success`，或英文错误说明。'
                  data:
                    type: object
                    properties:
                      voice_id:
                        type: string
                        description: 音色 ID（格式类似 `voice_…`）。请原样作为 `tts_voice_id` 传入。
                      name:
                        type: string
                        description: 显示名称。
                      language:
                        type: string
                        description: 创建时传入的语言；省略时为空字符串。
                      preview_audio_url:
                        type: string
                        description: >-
                          生成的预览音频的公共 URL，可直接在 `<audio>` 元素中播放。格式为 WAV（单声道、16
                          kHz）。仅在成功生成预览时提供；即使没有此字段，音色仍然可用。
                    required:
                      - voice_id
                      - name
                      - language
              example:
                code: 0
                message: success
                data:
                  voice_id: voice_8f2c1a4e-5d67-4b03-a9f1-2e6c7b0d5a94
                  name: Studio Anchor
                  language: zh
                  preview_audio_url: >-
                    https://static.vivi-x.ai/voice_preview/2026/10/13/8f2c1a4e5d674b03/a9f12e6c7b0d5a94.wav
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 你的 Vivix API 密钥。请仅保存在服务端。

````

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