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

# Create Speech

> Convert text to speech.

Provider is resolved automatically from the model name via the model_pricing
table — no hardcoded provider branching. Streaming is used when the provider
adapter supports it and `stream=true` (the default).

The `voice` field is required for ElevenLabs models. Sarvam models use
`speaker` instead.



## OpenAPI

````yaml /api/openapi.json post /v1/audio/speech
openapi: 3.1.0
info:
  title: MeshAPI
  description: One key, all AI models.
  version: 0.1.0
servers:
  - url: https://api.meshapi.ai
security:
  - BearerAuth: []
paths:
  /v1/audio/speech:
    post:
      tags:
        - Audio
      summary: Create Speech
      description: >-
        Convert text to speech.


        Provider is resolved automatically from the model name via the
        model_pricing

        table — no hardcoded provider branching. Streaming is used when the
        provider

        adapter supports it and `stream=true` (the default).


        The `voice` field is required for ElevenLabs models. Sarvam models use

        `speaker` instead.
      operationId: create_speech
      parameters:
        - in: header
          name: X-Mesh-Version
          required: false
          schema:
            type: string
            enum:
              - 2026-08
            default: 2026-08
          example: 2026-08
          description: >-
            Dated version of the API contract to pin this request to. Omit it
            and the request is served under `2026-08` — the oldest supported
            version, so an existing integration is never moved by a release. A
            malformed or unsupported value is rejected with `400
            invalid_api_version` rather than falling back silently. The version
            actually served is echoed as `X-Mesh-Version` on every response,
            including errors.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SpeechRequest'
            examples:
              default:
                summary: Example request
                value:
                  model: elevenlabs/eleven_flash_v2_5
                  input: Welcome to MeshAPI.
                  voice: Rachel
                  response_format: mp3_44100_128
                  stream: false
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
              examples:
                default:
                  summary: Example response
                  value: binary audio bytes
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - BearerAuth: []
components:
  schemas:
    SpeechRequest:
      properties:
        model:
          type: string
          title: Model
          default: eleven_flash_v2_5
        input:
          type: string
          title: Input
        voice:
          anyOf:
            - type: string
            - type: 'null'
          title: Voice
        stream:
          type: boolean
          title: Stream
          default: true
        response_format:
          anyOf:
            - type: string
            - type: 'null'
          title: Response Format
        language_code:
          anyOf:
            - type: string
            - type: 'null'
          title: Language Code
        voice_settings:
          anyOf:
            - $ref: '#/components/schemas/VoiceSettings'
            - type: 'null'
        pronunciation_dictionary_locators:
          anyOf:
            - items:
                $ref: '#/components/schemas/PronunciationDictionaryLocator'
              type: array
            - type: 'null'
          title: Pronunciation Dictionary Locators
        seed:
          anyOf:
            - type: integer
            - type: 'null'
          title: Seed
        previous_text:
          anyOf:
            - type: string
            - type: 'null'
          title: Previous Text
        next_text:
          anyOf:
            - type: string
            - type: 'null'
          title: Next Text
        previous_request_ids:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Previous Request Ids
        next_request_ids:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Next Request Ids
        apply_text_normalization:
          anyOf:
            - type: string
            - type: 'null'
          title: Apply Text Normalization
        apply_language_text_normalization:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Apply Language Text Normalization
        use_pvc_as_ivc:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Use Pvc As Ivc
        enable_logging:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Enable Logging
        optimize_streaming_latency:
          anyOf:
            - type: integer
            - type: 'null'
          title: Optimize Streaming Latency
        speaker:
          type: string
          title: Speaker
          default: anushka
        target_language_code:
          type: string
          title: Target Language Code
          default: hi-IN
        pitch:
          anyOf:
            - type: number
            - type: 'null'
          title: Pitch
        pace:
          anyOf:
            - type: number
            - type: 'null'
          title: Pace
        loudness:
          anyOf:
            - type: number
            - type: 'null'
          title: Loudness
        speech_sample_rate:
          anyOf:
            - type: integer
            - type: 'null'
          title: Speech Sample Rate
        enable_preprocessing:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Enable Preprocessing
      type: object
      required:
        - input
      title: SpeechRequest
      example:
        input: Hello, this is a test of the text-to-speech API.
        model: sarvam/bulbul:v3
        speaker: ritu
        stream: false
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    VoiceSettings:
      properties:
        stability:
          anyOf:
            - type: number
            - type: 'null'
          title: Stability
        similarity_boost:
          anyOf:
            - type: number
            - type: 'null'
          title: Similarity Boost
        style:
          anyOf:
            - type: number
            - type: 'null'
          title: Style
        use_speaker_boost:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Use Speaker Boost
        speed:
          anyOf:
            - type: number
            - type: 'null'
          title: Speed
      type: object
      title: VoiceSettings
    PronunciationDictionaryLocator:
      properties:
        pronunciation_dictionary_id:
          type: string
          title: Pronunciation Dictionary Id
        version_id:
          type: string
          title: Version Id
      type: object
      required:
        - pronunciation_dictionary_id
        - version_id
      title: PronunciationDictionaryLocator
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Enter your MeshAPI key (`rsk_...`) — sent as `Authorization: Bearer
        <key>`.

````