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

# Synthesize speech

> Generates text-to-speech audio for the given `text` using the configured Gemini TTS provider.

Accepts an optional `prompt` for style guidance, `voice`, `model`, `audioEncoding`, and `languageCode`.

Returns `{ audioContent, audioConfig, model }` where `audioContent` is base64-encoded audio.

Combined `text` and `prompt` must not exceed 1800 characters.



## OpenAPI

````yaml post /tts/synthesize
openapi: 3.1.0
info:
  title: HERO API
  version: current
  description: |-
    The HERO REST API.

    See https://developers.myhero.so for the rendered docs.
servers:
  - url: https://app.myhero.so
security: []
paths:
  /tts/synthesize:
    post:
      tags:
        - TTS
      summary: Synthesize speech
      description: >-
        Generates text-to-speech audio for the given `text` using the configured
        Gemini TTS provider.


        Accepts an optional `prompt` for style guidance, `voice`, `model`,
        `audioEncoding`, and `languageCode`.


        Returns `{ audioContent, audioConfig, model }` where `audioContent` is
        base64-encoded audio.


        Combined `text` and `prompt` must not exceed 1800 characters.
      operationId: synthesizeSpeech
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                text:
                  type: string
                  minLength: 1
                  maxLength: 900
                prompt:
                  type: string
                  maxLength: 900
                voice:
                  type: string
                model:
                  type: string
                  enum:
                    - gemini-2.5-flash-preview-tts
                    - gemini-2.5-pro-preview-tts
                audioEncoding:
                  type: string
                  enum:
                    - LINEAR16
                    - MP3
                    - OGG_OPUS
                    - ALAW
                    - MULAW
                languageCode:
                  type: string
              required:
                - text
      responses:
        '200':
          description: 200 response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
                    example: true
                  data:
                    type: object
                    properties:
                      audioContent:
                        type: string
                        description: Base64-encoded audio
                      audioConfig:
                        type: object
                        properties:
                          audioEncoding:
                            type: string
                          sampleRateHertz:
                            type: number
                        required:
                          - audioEncoding
                      model:
                        type: string
                    required:
                      - audioContent
                      - audioConfig
                required:
                  - success
                  - data
        '400':
          description: 400 response
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: |-
                      Error class name (e.g.

                      ValidationError, NotFound)
                  message:
                    type: string
                    description: Human-readable error message
                  details:
                    type: array
                    items: {}
                required:
                  - error
                  - message
        '403':
          description: 403 response
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: |-
                      Error class name (e.g.

                      ValidationError, NotFound)
                  message:
                    type: string
                    description: Human-readable error message
                  details:
                    type: array
                    items: {}
                required:
                  - error
                  - message
      security:
        - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: HERO personal access token

````