Generate speech

August 18, 2025

Table of contents

  1. Request Headers
  2. Request Body
  3. Responses
  4. Model
  5. Examples
  6. Try It

This endpoint generates high-quality speech from text using Mureka’s advanced text-to-speech technology. You can use either predefined voices or custom cloned voices created via POST /speech/voice. For multi-speaker conversations, use the conversation parameter with different voice IDs. Speech generation typically takes 20-90 seconds depending on text length.

https://api.useapi.net/v1/mureka/speech

Request Headers
Authorization: Bearer {API token}
Content-Type: application/json
# Content-Type: multipart/form-data
Request Body
  • account is optional when only one account configured. However, if you have multiple accounts configured, this parameter becomes required.

  • title is optional string.
    Maximum length is 500 characters.

  • text is required string when not using conversation. Must be used together with voice_id.
    Maximum text length is 5000 characters.

  • voice_id is required number when not using conversation. Must be used together with text. Get available voice IDs from GET /speech/voices.
    To create a cloned voice, first use POST /speech/voice to upload an audio sample and clone the voice.

  • conversation is optional JSON string. Alternative to text and voice_id. Must be a JSON string array of objects with voice_id (number) and text (string) fields. Cannot be used together with text and voice_id.
    Total text length across all conversation items cannot exceed 5000 characters.

    Example conversation JSON:

      [
          {"voice_id": 12345, "text": "Hello, welcome to our service!"},
          {"voice_id": 67890, "text": "Thank you for choosing us today."},
          {"voice_id": 12345, "text": "Is there anything I can help you with?"}
      ]
    
Responses
  • 200 OK

    {
        "title": "Sample Speech Title",
        "preview": "This is a preview of the generated speech content that demonstrates the text-to-speech capabilities.",
        "cover": "https://static-cos.mureka.ai/cos-prod/res/cover/….png",
        "mp3_url": "https://static-cos.mureka.ai/cos-prod/tts-v2/….mp3",
        "id": 12345678901234,
        "duration_milliseconds": 15000,
        "audio_quality": 2,
        "state": 3
    }
    
  • 400 Bad Request

    {
        "error": "<Error message>",
        "code": 400
    }
    
  • 401 Unauthorized

    {
      "error": "Unauthorized",
      "code": 401
    }
    
Model
{ // TypeScript, all fields are optional
    title: string
    preview: string
    cover: string
    mp3_url: string
    id: number
    duration_milliseconds: number
    audio_quality: number
    state: number
}
Examples
  • curl "https://api.useapi.net/v1/mureka/speech" \
       -H "Accept: application/json" \
       -H "Authorization: Bearer …" \
       -H "Content-Type: application/json" \
       -d '{
         "text": "Hello, this is a sample text for speech generation.",
         "voice_id": 67890
       }'
    
  • const token = "API token";
    const apiUrl = "https://api.useapi.net/v1/mureka/speech"; 
    const response = await fetch(apiUrl, {
      method: "POST",
      headers: {
        "Authorization": `Bearer ${token}`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        text: "Hello, this is a sample text for speech generation.",
        voice_id: 67890
      }),
    });
    const result = await response.json();
    console.log("response", {response, result});
    
  • import requests
    token = "API token"
    apiUrl = "https://api.useapi.net/v1/mureka/speech"
    headers = {
        "Content-Type": "application/json", 
        "Authorization" : f"Bearer {token}"
    }
    data = {
        "text": "Hello, this is a sample text for speech generation.",
        "voice_id": 67890
    }
    response = requests.post(apiUrl, headers=headers, json=data)
    print(response, response.json())
    
Try It