> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developers.meshapi.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developers.meshapi.ai/_mcp/server.

# Create Speech

POST https://api.meshapi.ai/v1/audio/speech
Content-Type: application/json

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.

Reference: https://developers.meshapi.ai/api-reference/mesh-api/audio/create-speech-v-1-audio-speech-post

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: openapi
  version: 1.0.0
paths:
  /v1/audio/speech:
    post:
      operationId: create-speech-v-1-audio-speech-post
      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.
      tags:
        - subpackage_audio
      parameters:
        - name: Authorization
          in: header
          description: Bearer authentication
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                description: Any type
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SpeechRequest'
servers:
  - url: https://api.meshapi.ai
    description: Production Server
components:
  schemas:
    VoiceSettings:
      type: object
      properties:
        stability:
          type:
            - number
            - 'null'
          format: double
        similarity_boost:
          type:
            - number
            - 'null'
          format: double
        style:
          type:
            - number
            - 'null'
          format: double
        use_speaker_boost:
          type:
            - boolean
            - 'null'
        speed:
          type:
            - number
            - 'null'
          format: double
      title: VoiceSettings
    PronunciationDictionaryLocator:
      type: object
      properties:
        pronunciation_dictionary_id:
          type: string
        version_id:
          type: string
      required:
        - pronunciation_dictionary_id
        - version_id
      title: PronunciationDictionaryLocator
    SpeechRequest:
      type: object
      properties:
        model:
          type: string
          default: elevenlabs/eleven_turbo_v2_5
        input:
          type: string
        voice:
          type:
            - string
            - 'null'
        stream:
          type: boolean
          default: true
        response_format:
          type:
            - string
            - 'null'
        language_code:
          type:
            - string
            - 'null'
        voice_settings:
          oneOf:
            - $ref: '#/components/schemas/VoiceSettings'
            - type: 'null'
        pronunciation_dictionary_locators:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/PronunciationDictionaryLocator'
        seed:
          type:
            - integer
            - 'null'
        previous_text:
          type:
            - string
            - 'null'
        next_text:
          type:
            - string
            - 'null'
        previous_request_ids:
          type:
            - array
            - 'null'
          items:
            type: string
        next_request_ids:
          type:
            - array
            - 'null'
          items:
            type: string
        apply_text_normalization:
          type:
            - string
            - 'null'
        apply_language_text_normalization:
          type:
            - boolean
            - 'null'
        use_pvc_as_ivc:
          type:
            - boolean
            - 'null'
        enable_logging:
          type:
            - boolean
            - 'null'
        optimize_streaming_latency:
          type:
            - integer
            - 'null'
        speaker:
          type: string
          default: anushka
        target_language_code:
          type: string
          default: hi-IN
        pitch:
          type:
            - number
            - 'null'
          format: double
        pace:
          type:
            - number
            - 'null'
          format: double
        loudness:
          type:
            - number
            - 'null'
          format: double
        speech_sample_rate:
          type:
            - integer
            - 'null'
        enable_preprocessing:
          type:
            - boolean
            - 'null'
      required:
        - input
      title: SpeechRequest
    ValidationErrorLocItems:
      oneOf:
        - type: string
        - type: integer
      title: ValidationErrorLocItems
    ValidationErrorCtx:
      type: object
      properties: {}
      title: ValidationErrorCtx
    ValidationError:
      type: object
      properties:
        loc:
          type: array
          items:
            $ref: '#/components/schemas/ValidationErrorLocItems'
        msg:
          type: string
        type:
          type: string
        input:
          description: Any type
        ctx:
          $ref: '#/components/schemas/ValidationErrorCtx'
      required:
        - loc
        - msg
        - type
      title: ValidationError
    HTTPValidationError:
      type: object
      properties:
        detail:
          type: array
          items:
            $ref: '#/components/schemas/ValidationError'
      title: HTTPValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

```

## Examples



**Request**

```json
{
  "input": "Hello, welcome to our text-to-speech service. This is a sample conversion.",
  "model": "elevenlabs/eleven_turbo_v2_5",
  "voice": "Rachel",
  "stream": true,
  "response_format": "mp3",
  "language_code": "en-US",
  "voice_settings": {
    "stability": 0.75,
    "similarity_boost": 0.85,
    "style": 0.5,
    "use_speaker_boost": true,
    "speed": 1
  },
  "pronunciation_dictionary_locators": [
    {
      "pronunciation_dictionary_id": "dict12345",
      "version_id": "v1.0"
    }
  ],
  "seed": 42,
  "previous_text": "This is the previous sentence.",
  "next_text": "This is the next sentence.",
  "previous_request_ids": [
    "req-abc123",
    "req-def456"
  ],
  "next_request_ids": [
    "req-ghi789"
  ],
  "apply_text_normalization": "basic",
  "apply_language_text_normalization": true,
  "use_pvc_as_ivc": false,
  "enable_logging": true,
  "optimize_streaming_latency": 100,
  "speaker": "anushka",
  "target_language_code": "hi-IN",
  "pitch": 1.2,
  "pace": 0.9,
  "loudness": -3,
  "speech_sample_rate": 22050,
  "enable_preprocessing": true
}
```

**Response**

```json
{}
```

**SDK Code**

```python
import requests

url = "https://api.meshapi.ai/v1/audio/speech"

payload = {
    "input": "Hello, welcome to our text-to-speech service. This is a sample conversion.",
    "model": "elevenlabs/eleven_turbo_v2_5",
    "voice": "Rachel",
    "stream": True,
    "response_format": "mp3",
    "language_code": "en-US",
    "voice_settings": {
        "stability": 0.75,
        "similarity_boost": 0.85,
        "style": 0.5,
        "use_speaker_boost": True,
        "speed": 1
    },
    "pronunciation_dictionary_locators": [
        {
            "pronunciation_dictionary_id": "dict12345",
            "version_id": "v1.0"
        }
    ],
    "seed": 42,
    "previous_text": "This is the previous sentence.",
    "next_text": "This is the next sentence.",
    "previous_request_ids": ["req-abc123", "req-def456"],
    "next_request_ids": ["req-ghi789"],
    "apply_text_normalization": "basic",
    "apply_language_text_normalization": True,
    "use_pvc_as_ivc": False,
    "enable_logging": True,
    "optimize_streaming_latency": 100,
    "speaker": "anushka",
    "target_language_code": "hi-IN",
    "pitch": 1.2,
    "pace": 0.9,
    "loudness": -3,
    "speech_sample_rate": 22050,
    "enable_preprocessing": True
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.meshapi.ai/v1/audio/speech';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"input":"Hello, welcome to our text-to-speech service. This is a sample conversion.","model":"elevenlabs/eleven_turbo_v2_5","voice":"Rachel","stream":true,"response_format":"mp3","language_code":"en-US","voice_settings":{"stability":0.75,"similarity_boost":0.85,"style":0.5,"use_speaker_boost":true,"speed":1},"pronunciation_dictionary_locators":[{"pronunciation_dictionary_id":"dict12345","version_id":"v1.0"}],"seed":42,"previous_text":"This is the previous sentence.","next_text":"This is the next sentence.","previous_request_ids":["req-abc123","req-def456"],"next_request_ids":["req-ghi789"],"apply_text_normalization":"basic","apply_language_text_normalization":true,"use_pvc_as_ivc":false,"enable_logging":true,"optimize_streaming_latency":100,"speaker":"anushka","target_language_code":"hi-IN","pitch":1.2,"pace":0.9,"loudness":-3,"speech_sample_rate":22050,"enable_preprocessing":true}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.meshapi.ai/v1/audio/speech"

	payload := strings.NewReader("{\n  \"input\": \"Hello, welcome to our text-to-speech service. This is a sample conversion.\",\n  \"model\": \"elevenlabs/eleven_turbo_v2_5\",\n  \"voice\": \"Rachel\",\n  \"stream\": true,\n  \"response_format\": \"mp3\",\n  \"language_code\": \"en-US\",\n  \"voice_settings\": {\n    \"stability\": 0.75,\n    \"similarity_boost\": 0.85,\n    \"style\": 0.5,\n    \"use_speaker_boost\": true,\n    \"speed\": 1\n  },\n  \"pronunciation_dictionary_locators\": [\n    {\n      \"pronunciation_dictionary_id\": \"dict12345\",\n      \"version_id\": \"v1.0\"\n    }\n  ],\n  \"seed\": 42,\n  \"previous_text\": \"This is the previous sentence.\",\n  \"next_text\": \"This is the next sentence.\",\n  \"previous_request_ids\": [\n    \"req-abc123\",\n    \"req-def456\"\n  ],\n  \"next_request_ids\": [\n    \"req-ghi789\"\n  ],\n  \"apply_text_normalization\": \"basic\",\n  \"apply_language_text_normalization\": true,\n  \"use_pvc_as_ivc\": false,\n  \"enable_logging\": true,\n  \"optimize_streaming_latency\": 100,\n  \"speaker\": \"anushka\",\n  \"target_language_code\": \"hi-IN\",\n  \"pitch\": 1.2,\n  \"pace\": 0.9,\n  \"loudness\": -3,\n  \"speech_sample_rate\": 22050,\n  \"enable_preprocessing\": true\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.meshapi.ai/v1/audio/speech")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"input\": \"Hello, welcome to our text-to-speech service. This is a sample conversion.\",\n  \"model\": \"elevenlabs/eleven_turbo_v2_5\",\n  \"voice\": \"Rachel\",\n  \"stream\": true,\n  \"response_format\": \"mp3\",\n  \"language_code\": \"en-US\",\n  \"voice_settings\": {\n    \"stability\": 0.75,\n    \"similarity_boost\": 0.85,\n    \"style\": 0.5,\n    \"use_speaker_boost\": true,\n    \"speed\": 1\n  },\n  \"pronunciation_dictionary_locators\": [\n    {\n      \"pronunciation_dictionary_id\": \"dict12345\",\n      \"version_id\": \"v1.0\"\n    }\n  ],\n  \"seed\": 42,\n  \"previous_text\": \"This is the previous sentence.\",\n  \"next_text\": \"This is the next sentence.\",\n  \"previous_request_ids\": [\n    \"req-abc123\",\n    \"req-def456\"\n  ],\n  \"next_request_ids\": [\n    \"req-ghi789\"\n  ],\n  \"apply_text_normalization\": \"basic\",\n  \"apply_language_text_normalization\": true,\n  \"use_pvc_as_ivc\": false,\n  \"enable_logging\": true,\n  \"optimize_streaming_latency\": 100,\n  \"speaker\": \"anushka\",\n  \"target_language_code\": \"hi-IN\",\n  \"pitch\": 1.2,\n  \"pace\": 0.9,\n  \"loudness\": -3,\n  \"speech_sample_rate\": 22050,\n  \"enable_preprocessing\": true\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.meshapi.ai/v1/audio/speech")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"input\": \"Hello, welcome to our text-to-speech service. This is a sample conversion.\",\n  \"model\": \"elevenlabs/eleven_turbo_v2_5\",\n  \"voice\": \"Rachel\",\n  \"stream\": true,\n  \"response_format\": \"mp3\",\n  \"language_code\": \"en-US\",\n  \"voice_settings\": {\n    \"stability\": 0.75,\n    \"similarity_boost\": 0.85,\n    \"style\": 0.5,\n    \"use_speaker_boost\": true,\n    \"speed\": 1\n  },\n  \"pronunciation_dictionary_locators\": [\n    {\n      \"pronunciation_dictionary_id\": \"dict12345\",\n      \"version_id\": \"v1.0\"\n    }\n  ],\n  \"seed\": 42,\n  \"previous_text\": \"This is the previous sentence.\",\n  \"next_text\": \"This is the next sentence.\",\n  \"previous_request_ids\": [\n    \"req-abc123\",\n    \"req-def456\"\n  ],\n  \"next_request_ids\": [\n    \"req-ghi789\"\n  ],\n  \"apply_text_normalization\": \"basic\",\n  \"apply_language_text_normalization\": true,\n  \"use_pvc_as_ivc\": false,\n  \"enable_logging\": true,\n  \"optimize_streaming_latency\": 100,\n  \"speaker\": \"anushka\",\n  \"target_language_code\": \"hi-IN\",\n  \"pitch\": 1.2,\n  \"pace\": 0.9,\n  \"loudness\": -3,\n  \"speech_sample_rate\": 22050,\n  \"enable_preprocessing\": true\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.meshapi.ai/v1/audio/speech', [
  'body' => '{
  "input": "Hello, welcome to our text-to-speech service. This is a sample conversion.",
  "model": "elevenlabs/eleven_turbo_v2_5",
  "voice": "Rachel",
  "stream": true,
  "response_format": "mp3",
  "language_code": "en-US",
  "voice_settings": {
    "stability": 0.75,
    "similarity_boost": 0.85,
    "style": 0.5,
    "use_speaker_boost": true,
    "speed": 1
  },
  "pronunciation_dictionary_locators": [
    {
      "pronunciation_dictionary_id": "dict12345",
      "version_id": "v1.0"
    }
  ],
  "seed": 42,
  "previous_text": "This is the previous sentence.",
  "next_text": "This is the next sentence.",
  "previous_request_ids": [
    "req-abc123",
    "req-def456"
  ],
  "next_request_ids": [
    "req-ghi789"
  ],
  "apply_text_normalization": "basic",
  "apply_language_text_normalization": true,
  "use_pvc_as_ivc": false,
  "enable_logging": true,
  "optimize_streaming_latency": 100,
  "speaker": "anushka",
  "target_language_code": "hi-IN",
  "pitch": 1.2,
  "pace": 0.9,
  "loudness": -3,
  "speech_sample_rate": 22050,
  "enable_preprocessing": true
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.meshapi.ai/v1/audio/speech");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"input\": \"Hello, welcome to our text-to-speech service. This is a sample conversion.\",\n  \"model\": \"elevenlabs/eleven_turbo_v2_5\",\n  \"voice\": \"Rachel\",\n  \"stream\": true,\n  \"response_format\": \"mp3\",\n  \"language_code\": \"en-US\",\n  \"voice_settings\": {\n    \"stability\": 0.75,\n    \"similarity_boost\": 0.85,\n    \"style\": 0.5,\n    \"use_speaker_boost\": true,\n    \"speed\": 1\n  },\n  \"pronunciation_dictionary_locators\": [\n    {\n      \"pronunciation_dictionary_id\": \"dict12345\",\n      \"version_id\": \"v1.0\"\n    }\n  ],\n  \"seed\": 42,\n  \"previous_text\": \"This is the previous sentence.\",\n  \"next_text\": \"This is the next sentence.\",\n  \"previous_request_ids\": [\n    \"req-abc123\",\n    \"req-def456\"\n  ],\n  \"next_request_ids\": [\n    \"req-ghi789\"\n  ],\n  \"apply_text_normalization\": \"basic\",\n  \"apply_language_text_normalization\": true,\n  \"use_pvc_as_ivc\": false,\n  \"enable_logging\": true,\n  \"optimize_streaming_latency\": 100,\n  \"speaker\": \"anushka\",\n  \"target_language_code\": \"hi-IN\",\n  \"pitch\": 1.2,\n  \"pace\": 0.9,\n  \"loudness\": -3,\n  \"speech_sample_rate\": 22050,\n  \"enable_preprocessing\": true\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "input": "Hello, welcome to our text-to-speech service. This is a sample conversion.",
  "model": "elevenlabs/eleven_turbo_v2_5",
  "voice": "Rachel",
  "stream": true,
  "response_format": "mp3",
  "language_code": "en-US",
  "voice_settings": [
    "stability": 0.75,
    "similarity_boost": 0.85,
    "style": 0.5,
    "use_speaker_boost": true,
    "speed": 1
  ],
  "pronunciation_dictionary_locators": [
    [
      "pronunciation_dictionary_id": "dict12345",
      "version_id": "v1.0"
    ]
  ],
  "seed": 42,
  "previous_text": "This is the previous sentence.",
  "next_text": "This is the next sentence.",
  "previous_request_ids": ["req-abc123", "req-def456"],
  "next_request_ids": ["req-ghi789"],
  "apply_text_normalization": "basic",
  "apply_language_text_normalization": true,
  "use_pvc_as_ivc": false,
  "enable_logging": true,
  "optimize_streaming_latency": 100,
  "speaker": "anushka",
  "target_language_code": "hi-IN",
  "pitch": 1.2,
  "pace": 0.9,
  "loudness": -3,
  "speech_sample_rate": 22050,
  "enable_preprocessing": true
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.meshapi.ai/v1/audio/speech")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```