curl -X POST "https://api.elevenlabs8.com/api/tts/audio-generate/" \
  -H "X-API-KEY: your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "inputs": [
      {
        "text": "Hello, this is a test message.",
        "voice_id": "JBFqnCBsd6RMkjVDRZzb"
      },
      {
        "text": "Hello, this is a test message.",
        "voice_id": "JBFqnCBsd6RMkjVDRZzb"
      }
    ],
    "model_id": "eleven_v3"
  }'
{
  "success": true,
  "data": {
    "id": "history_id_123",
    "user": {
      "fullname": "John Doe",
      "avatar": "https://api.elevenlabs8.com/media/avatars/john.jpg"
    },
    "history_id": "unique_history_id",
    "prompt": "Hello, this is a test message.",
    "model": "eleven_v3",
    "voice": "Rachel",
    "config": {
      "stability": 0.5,
      "similarity_boost": 0.75,
      "style": 0.0,
      "use_speaker_boost": true
    },
    "credits_used": 1,
    "status": "completed",
    "shared_url": "https://app.elevenlabs8.com/share/audio_id",
    "created_at": "2024-01-01T12:00:00Z",
    "audio_url": "https://api.elevenlabs8.com/media/audio/output.mp3"
  },
  "message": "Audio generated successfully"
}

Convert Text to Speech

Convert text to speech using TTSLab’s advanced AI models.
curl -X POST "https://api.elevenlabs8.com/api/tts/audio-generate/" \
  -H "X-API-KEY: your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "inputs": [
      {
        "text": "Hello, this is a test message.",
        "voice_id": "JBFqnCBsd6RMkjVDRZzb"
      },
      {
        "text": "Hello, this is a test message.",
        "voice_id": "JBFqnCBsd6RMkjVDRZzb"
      }
    ],
    "model_id": "eleven_v3"
  }'

Request Parameters

v3 Models

ParameterTypeRequiredDescription
inputs.textstringYesText to convert to speech
inputs.voice_idstringYesVoice ID to use
model_idstringYesModel ID (e.g., “eleven_v3”)

v1/v2 Models

ParameterTypeRequiredDescription
textstringYesText to convert to speech
voice_idstringYesVoice ID to use
model_idstringYesModel ID (e.g., “eleven_flash_v2_5”)
configobjectNoVoice configuration settings

Config Parameters (v1/v2 only)

ParameterTypeRangeDescription
stabilityfloat0.0 - 1.0Controls voice consistency
similarity_boostfloat0.0 - 1.0Controls voice similarity to original
stylefloat0.0 - 1.0Controls speaking style
use_speaker_boostboolean-Enhances speaker clarity

Response

{
  "success": true,
  "data": {
    "id": "history_id_123",
    "user": {
      "fullname": "John Doe",
      "avatar": "https://api.elevenlabs8.com/media/avatars/john.jpg"
    },
    "history_id": "unique_history_id",
    "prompt": "Hello, this is a test message.",
    "model": "eleven_v3",
    "voice": "Rachel",
    "config": {
      "stability": 0.5,
      "similarity_boost": 0.75,
      "style": 0.0,
      "use_speaker_boost": true
    },
    "credits_used": 1,
    "status": "completed",
    "shared_url": "https://app.elevenlabs8.com/share/audio_id",
    "created_at": "2024-01-01T12:00:00Z",
    "audio_url": "https://api.elevenlabs8.com/media/audio/output.mp3"
  },
  "message": "Audio generated successfully"
}

Downloading the Audio

To get the actual audio file, make a GET request to the audio_url:
# Download the audio file
audio_response = requests.get(response.json()["data"]["audio_url"])
with open("output.mp3", "wb") as f:
    f.write(audio_response.content)

Error Responses

{
  "success": false,
  "error": {
    "code": "INVALID_VOICE_ID",
    "message": "Voice ID not found"
  }
}

Common Error Codes

CodeDescription
INVALID_API_KEYInvalid or missing API key
INVALID_VOICE_IDVoice ID not found
INVALID_MODEL_IDModel ID not found
TEXT_TOO_LONGText exceeds maximum length
INSUFFICIENT_CREDITSNot enough credits
RATE_LIMIT_EXCEEDEDRate limit exceeded