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

# 上传音频

> 上传音频文件并返回用于克隆的 `file_id`。文件仅限当前工作区使用。

请求使用 `multipart/form-data`，字段名为 `file`。支持的类型：`audio/wav`、`audio/mpeg`、`audio/mp3`、`audio/mp4`、`audio/ogg`、`audio/webm`。最大 10 MB。

克隆样本要求：16 位 WAV、MP3 或 M4A，采样率不低于 16 kHz，单声道或立体声（仅使用第一个声道）。样本必须是**最长 15 秒**的连续清晰语音。过短的片段（大约短于半秒）可能因服务无法转录而失败，建议至少提供数秒音频。

> [accordion] 错误
>
> 错误响应使用相同的 `{code, message, data}` 封装；非零 `code` 表示具体错误。
>
> | 情况 | 错误码 |
> | - | - |
> | 缺少 `file` 字段 | `20010 missing file field` |
> | 文件为空 | `20006 empty file` |
> | 文件大于 10MB | `20007 file too large` |
> | 不支持的音频类型 | `20008 unsupported media type` |
> | multipart 表单无效 | `20009 invalid multipart form` |


## OpenAPI

````yaml cn/streaming-avatar/api-references/openapi.json POST /v1/files/audios
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/files/audios:
    post:
      summary: 上传音频
      description: >-
        上传音频文件并返回用于克隆的 `file_id`。文件仅限当前工作区使用。


        请求使用 `multipart/form-data`，字段名为
        `file`。支持的类型：`audio/wav`、`audio/mpeg`、`audio/mp3`、`audio/mp4`、`audio/ogg`、`audio/webm`。最大
        10 MB。


        克隆样本要求：16 位 WAV、MP3 或 M4A，采样率不低于 16 kHz，单声道或立体声（仅使用第一个声道）。样本必须是**最长 15
        秒**的连续清晰语音。过短的片段（大约短于半秒）可能因服务无法转录而失败，建议至少提供数秒音频。
      operationId: uploadAudio
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - file
              properties:
                file:
                  type: string
                  contentMediaType: application/octet-stream
                  description: >-
                    音频文件。支持的类型：`audio/wav`、`audio/mpeg`、`audio/mp3`、`audio/mp4`、`audio/ogg`、`audio/webm`。最大
                    10 MB；用于克隆时最长 15 秒。
      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:
                      file_id:
                        type: string
                        description: 文件 ID，格式类似 `file_aud_…`。克隆音色时将其作为 `file_id` 传入。
                      file_type:
                        type: string
                        description: 固定为 `audio`。
                      mime_type:
                        type: string
                        description: 检测到的 MIME 类型。
                      size_bytes:
                        type: integer
                        description: 文件大小。
                      url:
                        type: string
                        description: CDN URL。
                      created_at:
                        type: string
                        format: date-time
                        description: 创建时间。
                    required:
                      - file_id
                      - file_type
                      - mime_type
                      - size_bytes
                      - url
                      - created_at
              example:
                code: 0
                message: success
                data:
                  file_id: file_aud_a1b2c3d4e5f6
                  file_type: audio
                  mime_type: audio/mpeg
                  size_bytes: 335822
                  url: >-
                    https://static.vivi-x.ai/audios/2026/08/02/febd902cac2a6f57.mp3
                  created_at: '2026-08-02T10:00:00Z'
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.