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

# 合成语音

> 请求格式、响应与能力边界。

`POST /v1/audio/speech`

发送 JSON，提供 `model`、`input`、`voice`。通常返回音频二进制，Content-Type 和编码随 `response_format` 变化。不要把成功响应按 JSON 读取；错误响应仍可能是 JSON。

音色、语速和风格指令由模型决定。`stream_format: sse` 只有渠道支持时可用，不能因为 HTTP 分块传输就按 SSE 解析。

[完整接入指南与可执行示例](/zh/guides/speech)

[Read in English](/en/api-reference/audio-speech)


## OpenAPI

````yaml openapi/relay.json POST /v1/audio/speech
openapi: 3.0.3
info:
  title: API — Core inference API
  version: 0.5.0
  description: >-
    面向接入的精选规范，不是全部管理或供应商接口。 / Curated integration specification, not the entire
    management or provider API.
  license:
    name: AGPL-3.0-or-later
servers:
  - url: https://gateway.example.com
    description: >-
      Example only; replace with your gateway origin and optional path prefix,
      without /v1.
security:
  - BearerAuth: []
paths:
  /v1/audio/speech:
    post:
      summary: 合成语音 / Generate speech
      description: >-
        常用接入字段；能力取决于模型、渠道与部署。 / Common integration fields; support depends on
        the model, channel, and deployment.
      operationId: POSTAudioSpeech
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SpeechRequest'
      responses:
        '200':
          description: 音频字节；不能按 JSON 解析 / Audio bytes; do not parse as JSON
          content:
            audio/mpeg:
              schema:
                type: string
                format: binary
            application/octet-stream:
              schema:
                type: string
                format: binary
            text/event-stream:
              schema:
                type: string
                description: 仅在所选渠道支持 SSE 时 / Only for channels supporting SSE
        '400':
          description: 请求参数错误 / Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: 身份校验失败 / Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: 访问被拒绝 / Access denied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: 接口或资源不存在 / Endpoint or resource not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: 请求被限流或受配额限制 / Rate or quota restriction
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: 网关或上游错误 / Gateway or upstream error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: 服务暂不可用 / Service unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        default:
          description: 其他网关或上游错误；格式可能不同 / Other gateway or upstream error; shape may vary
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    SpeechRequest:
      type: object
      properties:
        model:
          type: string
          description: >-
            当前密钥可用且支持此接口的模型 ID / Model ID available to the key and supporting
            this endpoint
          example: YOUR_MODEL_ID
        input:
          type: string
          description: 待合成文本 / Text to speak
        voice:
          type: string
          description: 模型支持的音色标识 / Voice ID supported by the model
        response_format:
          type: string
          description: >-
            常见 mp3、wav、opus、aac、flac、pcm；支持情况由模型决定 / Common formats include mp3,
            wav, opus, aac, flac, pcm; support depends on model
        instructions:
          type: string
          description: >-
            可选风格指令，非所有模型支持 / Optional style instructions; not supported by every
            model
        speed:
          type: number
          description: 语速；范围由模型决定 / Speed; accepted range depends on the model
        stream_format:
          type: string
          description: >-
            audio 或 sse 需渠道支持；本指南使用音频字节 / audio or sse requires channel support;
            this guide uses audio bytes
      required:
        - model
        - input
        - voice
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
            param:
              type: string
              nullable: true
            code:
              nullable: true
              description: 错误标识；类型随上游变化 / Error identifier; type varies by upstream
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: 模型调用 API Key，不是控制台登录凭据 / Model API key, not console login credentials

````

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