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

# Text-to-speech

> POST /v1/audio/speech — synthesise speech from text.

```bash theme={null}
curl https://api.infery.ai/v1/audio/speech \
  -H "Authorization: Bearer $INFERY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "tts-1",
    "input": "Hello from Infery",
    "voice": "alloy"
  }' --output out.mp3
```

Response is the audio binary (`audio/mpeg` / `audio/wav` depending on `response_format`).

### Sample output

<video controls src="https://mintcdn.com/inferyai/5YDpMTITcUUspdCA/samples/tts.wav?fit=max&auto=format&n=5YDpMTITcUUspdCA&q=85&s=1f8e8f9630d85339d42202fc260af070" style={{ width: '100%', maxWidth: 480, height: 54 }} data-path="samples/tts.wav" />

*Generated with `gemini-2.5-flash-preview-tts`, voice Kore. [Download tts.wav](/samples/tts.wav).*

## Parameters

* `voice` — model-dependent (`alloy`, `echo`, `onyx`, `nova`, `shimmer`, etc.)
* `response_format` — `mp3`, `wav`, `opus`, `flac`, `pcm`
* `speed` — 0.25–4.0


## OpenAPI

````yaml openapi.json POST /v1/audio/speech
openapi: 3.0.0
info:
  title: Infery Gateway
  description: >-
    Infery Inference Gateway — OpenAI-compatible API for LLMs, embeddings,
    images, audio, and video
  version: '1.0'
  contact: {}
servers:
  - url: https://api.infery.ai
    description: Production
  - url: http://localhost:3001
    description: Local
security: []
tags: []
paths:
  /v1/audio/speech:
    post:
      tags:
        - Audio
      summary: Text-to-speech
      operationId: createSpeech
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model
                - input
                - voice
              properties:
                model:
                  type: string
                  description: Model ID to use for TTS
                input:
                  type: string
                  description: Text to synthesize into speech
                voice:
                  type: string
                  description: Voice to use for synthesis
                response_format:
                  type: string
                  enum:
                    - mp3
                    - opus
                    - aac
                    - flac
                  default: mp3
                speed:
                  type: number
                  description: Speed of the generated audio (0.25 to 4.0)
                  default: 1
      responses:
        '200':
          description: >-
            Binary audio stream. Content-Type reflects the requested
            `response_format`: `audio/mpeg` (mp3, default), `audio/wav`,
            `audio/ogg` (opus), `audio/flac`, `audio/aac`, or `audio/pcm`.
            Credits deducted are returned in the `x-credits-used` response
            header.
          content:
            audio/wav:
              schema:
                type: string
                format: binary
              examples:
                sample:
                  summary: Generated speech sample
                  value: /samples/tts.wav
          headers:
            x-credits-used:
              schema:
                type: integer
              description: Credits deducted from the workspace balance
            x-model-used:
              schema:
                type: string
              description: >-
                Slug of the model that actually handled the request (may differ
                from requested when fallback fires)
            x-request-id:
              schema:
                type: string
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseDto'
        '401':
          description: Unauthorized — invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseDto'
        '404':
          description: Model not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseDto'
      security:
        - ApiKey: []
components:
  schemas:
    ErrorResponseDto:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetailDto'
      required:
        - error
    ErrorDetailDto:
      type: object
      properties:
        message:
          type: string
          example: Model not found
          description: Human-readable error message
        type:
          type: string
          example: invalid_request_error
          description: Error category
          enum:
            - invalid_request_error
            - authentication_error
            - permission_error
            - quota_exceeded
            - rate_limit_error
            - server_error
        code:
          type: object
          example: model_not_found
          nullable: true
          description: Stable machine-readable error code
        param:
          type: object
          example: model
          nullable: true
          description: >-
            Name of the request parameter that triggered the error, if
            applicable
      required:
        - message
        - type
        - code
        - param
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: Authorization
      description: 'API key in format: Bearer inf_***'

````