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

# Generate speech

> Request format, responses, and capability boundaries.

`POST /v1/audio/speech`

Send JSON with `model`, `input`, and `voice`. The usual result is binary audio; Content-Type and encoding follow `response_format`. Do not parse successful audio as JSON; errors may still be JSON.

Voices, speed, and style instructions depend on the model. `stream_format: sse` requires channel support. HTTP chunked transfer alone does not mean SSE.

[Integration guide and runnable example](/en/guides/speech)

[简体中文](/zh/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.