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

# 文本转语音

> 使用 `GLM-TTS` 将文本转换为自然语音，支持多种声音、情感控制和语调调整。点击 **Try it** 按钮可快速试用。



## OpenAPI

````yaml /openapi/openapi.json post /paas/v4/audio/speech
openapi: 3.0.1
info:
  title: ZHIPU AI API
  description: ZHIPU AI 接口提供强大的 AI 能力，包括聊天对话、工具调用和视频生成。
  license:
    name: ZHIPU AI 开发者协议和政策
    url: https://chat.z.ai/legal-agreement/terms-of-service
  version: 1.0.0
  contact:
    name: Z.AI 开发者
    url: https://chat.z.ai/legal-agreement/privacy-policy
    email: user_feedback@z.ai
servers:
  - url: https://open.bigmodel.cn/api/
    description: 开放平台服务
security:
  - bearerAuth: []
tags:
  - name: 模型 API
    description: Chat API
  - name: 工具 API
    description: Web Search API
  - name: Agent API
    description: Agent API
  - name: 文件 API
    description: File API
  - name: 知识库 API
    description: Knowledge API
  - name: 实时 API
    description: Realtime API
  - name: 批处理 API
    description: Batch API
  - name: 助理 API
    description: Assistant API
  - name: 智能体 API（旧）
    description: QingLiu Agent API
  - name: Managed Agents - Agent
    description: Agent 与版本管理。
  - name: Managed Agents - Environment
    description: 声明式执行环境管理。
  - name: Managed Agents - Session
    description: Session、Resource 与事件流。
  - name: Managed Agents - File
    description: Managed Files 上传、读取与删除。
  - name: Managed Agents - Memory
    description: Memory Store、Memory 与版本管理。
  - name: Managed Agents - Vault
    description: Vault 与 Credential 管理。
  - name: Managed Agents - Skill
    description: 自定义 Skill 与版本管理。
  - name: Managed Agents - Deployment
    description: 定时或手动 Deployment 与运行记录。
  - name: Forward Agent - Channel
    description: >-
      在 Managed Agent API 之上提供 Feishu Channel 接入。v0 仅支持
      Create、List、Get、Delete，不提供 Update、enable/disable/reconnect 或二维码接口。


      Channel 使用 inline `template` 固定 Agent version、Environment、Vault 和
      File。它不是可独立查询的 Template 实体。


      `memory_store_enabled=true` 时，Forward 为私聊用户或群创建并挂载长期 Memory Store；群主线与各
      thread 使用独立 Session，但共享群级 Store。关闭时直接创建不挂载 Store 的 Session。


      可通过 `GET /agent/managed/v1/sessions?agent_id=...` 发现 Channel 创建的
      Session。Session metadata 包含
      `source_type=im`、`channel_id`、`channel_type=feishu` 和
      `conversation_type=direct|group|thread`。Managed Session SSE
      仅推送实时事件，重连时应先通过 Events List 补齐历史并按 event ID 去重。


      限流按 customer ID 共享：read customer bucket 为 capacity 100、refill 50/s，Forward
      global 为 1000、500/s；write customer bucket 为 20、10/s，Forward global 为
      400、200/s。429 的 `x-ratelimit-scope: global` 仅表示 global bucket 拒绝。


      Inline template 不接受 MCP、Tools 或 Skills override；Session 完整继承固定 Agent
      Version。若执行进入 `requires_action`，Feishu Channel 不会自动批准，也不会把普通消息伪造成 tool
      result，调用者需通过 Managed Session API 完成交互。
paths:
  /paas/v4/audio/speech:
    post:
      tags:
        - 模型 API
      summary: 文本转语音
      description: 使用 `GLM-TTS` 将文本转换为自然语音，支持多种声音、情感控制和语调调整。点击 **Try it** 按钮可快速试用。
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AudioSpeechRequest'
            examples:
              文本转语音示例:
                value:
                  model: glm-tts
                  input: 你好，今天天气怎么样.
                  voice: tongtong
                  response_format: wav
        required: true
      responses:
        '200':
          description: |-
            业务处理成功 
             - 采样率建议设置为24000
          content:
            audio/wav:
              schema:
                type: string
                format: binary
        default:
          description: 请求失败。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    AudioSpeechRequest:
      type: object
      required:
        - model
        - input
        - voice
      properties:
        model:
          type: string
          enum:
            - glm-tts
          default: glm-tts
          description: 要使用的`TTS`模型
        input:
          type: string
          description: 要转换为语音的文本
          default: 你好，今天天气怎么样
          maxLength: 1024
        voice:
          type: string
          enum:
            - tongtong
            - chuichui
            - xiaochen
            - jam
            - kazi
            - douji
            - luodo
          default: tongtong
          description: |-
            生成音频时使用的音色，支持系统音色以及复刻音色两种类型，其中系统音色如下：
            `tongtong`: 彤彤，默认音色 
            `chuichui`: 锤锤 
            `xiaochen`: 小陈 
            `jam`: 动动动物圈`jam`音色 
            `kazi`: 动动动物圈`kazi`音色 
            `douji`: 动动动物圈`douji`音色 
            `luodo`: 动动动物圈`luodo`音色
        watermark_enabled:
          type: boolean
          description: |-
            控制`AI`生成音频时是否添加水印。去水印操作路径：右上角个人中心-安全管理-去水印管理-打开开关。
             - `true`: 默认启用`AI`生成的显式水印及隐式数字水印，符合政策要求。
             - `false`: 关闭所有水印，仅对已完成去水印动作的用户生效。
          example: true
        stream:
          type: boolean
          default: false
          description: |-
            是否启用流式输出。
            - `true`: 启用流式输出，模型将通过标准`Event Stream`逐块返回生成的音频内容。
            - `false`: 关闭流式输出，模型在生成所有内容后一次性返回所有内容。默认值为`false`。
        speed:
          type: number
          description: 语速，默认1.0，取值范围[0.5, 2]
        volume:
          type: number
          description: 音量，默认1.0，取值范围(0, 10]
        encode_format:
          type: string
          enum:
            - base64
            - hex
          description: 仅流式返回时，决定返回的编码格式。默认返回对应音频文件格式的`base64`字符串。
        response_format:
          type: string
          enum:
            - wav
            - pcm
          default: pcm
          description: 音频输出格式，默认返回`pcm`格式的文件。流式生成音频时，仅支持返回`pcm`格式的文件
    Error:
      type: object
      properties:
        error:
          required:
            - code
            - message
          type: object
          properties:
            code:
              type: string
            message:
              type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        标准的 HTTP Bearer 认证方式，在 [API
        Keys](https://bigmodel.cn/usercenter/proj-mgmt/apikeys) 页面获取密钥。

````

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