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

# Quickstart

The Elevenlabs8 API provides a simple interface to state-of-the-art audio [models](/models) and [features](/api-reference/introduction). Follow this guide to learn how to create lifelike speech with our Text to Speech API using direct HTTP requests.

## Using the Text to Speech API

<Steps>
  <Step title="Create an API key">
    [Create an API key in the dashboard here](https://app.elevenlabs8.com/profile/?tab=api-keys), which you'll use to securely [access the API](/docs/api-reference/authentication).

    Store the key as a managed secret and pass it in the `X-API-KEY` header with your requests.

    ```bash title=".env" theme={null}
    ELEVENLABS8_API_KEY=<your_api_key_here>
    ```
  </Step>

  <Step title="Make your first request">
    Create a new file named `example.py` or `example.js`, depending on your language of choice and add the following code:

    <CodeBlocks>
      ```python theme={null}
      import requests
      import os
      from dotenv import load_dotenv

      load_dotenv()

      api_key = os.getenv("ELEVENLABS8_API_KEY")

      url = "https://api.elevenlabs8.com/api/tts/audio-generate/"

      headers = {
          "X-API-KEY": api_key,
          "Content-Type": "application/json"
      }

       # For v3 models
       data = {
           "inputs": [
             {
               "text": "The first move is what sets everything in motion.",
               "voice_id": "JBFqnCBsd6RMkjVDRZzb"
             },
             {
               "text": "The second move is what sets everything in motion.",
               "voice_id": "2EiwWnXFnvU5JabPnv8n"
             },
           ],

           "model_id": "eleven_v3"
       }

       # For other models (v1, v2)
       # data = {
       #     "text": "The first move is what sets everything in motion.",
       #     "voice_id": "JBFqnCBsd6RMkjVDRZzb",
       #     "model_id": "eleven_flash_v2_5",
       #     "config": {
       #         "stability": 0.5,
       #         "similarity_boost": 0.75,
       #         "style": 0.0,
       #         "use_speaker_boost": True
       #     }
       # }

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

       if response.status_code == 200:
           result = response.json()
           print(f"Audio generated successfully! History ID: {result['history_id']}")
           print(f"Audio URL: {result['audio_url']}")
           
           # Download the audio file
           audio_response = requests.get(result['audio_url'])
           with open("output.mp3", "wb") as f:
               f.write(audio_response.content)
           print("Audio file downloaded as output.mp3")
       else:
           print(f"Error: {response.status_code}")
           print(response.text)
      ```

      ```javascript theme={null}
      const fs = require('fs');
      require('dotenv').config();

      const apiKey = process.env.ELEVENLABS8_API_KEY;

      const url = 'https://api.elevenlabs8.com/api/tts/audio-generate/';

      const headers = {
          'X-API-KEY': apiKey,
          'Content-Type': 'application/json'
      };

              // For v3 models
       const data = {
           inputs: [
             {
               text: 'The first move is what sets everything in motion.',
               voice_id: 'JBFqnCBsd6RMkjVDRZzb'
             },
             {
               text: 'The second move is what sets everything in motion.',
               voice_id: '2EiwWnXFnvU5JabPnv8n'
             }
           ],
           model_id: 'eleven_v3'
       };

       // For other models (v1, v2)
       // const data = {
       //     text: 'The first move is what sets everything in motion.',
       //     voice_id: 'JBFqnCBsd6RMkjVDRZzb',
       //     model_id: 'eleven_flash_v2_5',
       //     config: {
       //         stability: 0.5,
       //         similarity_boost: 0.75,
       //         style: 0.0,
       //         use_speaker_boost: true
       //     }
       // };

      fetch(url, {
          method: 'POST',
          headers: headers,
          body: JSON.stringify(data)
      })
              .then(response => {
           if (response.ok) {
               return response.json();
           }
           throw new Error(`HTTP error! status: ${response.status}`);
       })
       .then(result => {
           console.log(`Audio generated successfully! History ID: ${result.history_id}`);
           console.log(`Audio URL: ${result.audio_url}`);
           
           // Download the audio file
           return fetch(result.audio_url);
       })
       .then(audioResponse => {
           return audioResponse.arrayBuffer();
       })
       .then(buffer => {
           fs.writeFileSync('output.mp3', Buffer.from(buffer));
           console.log('Audio file downloaded as output.mp3');
       })
      .catch(error => {
          console.error('Error:', error);
      });
      ```

      ```bash theme={null}
      curl -X POST "https://api.elevenlabs8.com/api/tts/audio-generate/" \
        -H "X-API-KEY: $ELEVENLABS8_API_KEY" \
        -H "Content-Type: application/json" \
                  # For v3 models
         -d '{
           "inputs": [
             {
               "text": "The first move is what sets everything in motion.",
               "voice_id": "JBFqnCBsd6RMkjVDRZzb"
             },
             {
               "text": "The second move is what sets everything in motion.",
               "voice_id": "2EiwWnXFnvU5JabPnv8n"
             },
           ],
           "model_id": "eleven_v3"
         }' \
        
                  # For other models (v1, v2)
         # -d '{
         #   "text": "The first move is what sets everything in motion.",
         #   "voice_id": "JBFqnCBsd6RMkjVDRZzb",
         #   "model_id": "eleven_flash_v2_5",
         #   "config": {
         #     "stability": 0.5,
         #     "similarity_boost": 0.75,
         #     "style": 0.0,
         #     "use_speaker_boost": true
         #   }
         # }' \
        --output output.mp3
      ```
    </CodeBlocks>
  </Step>

  <Step title="Run the code">
    <CodeBlocks>
      ```bash theme={null}
      python example.py
      ```

      ```bash theme={null}
      node example.js
      ```

      ```bash theme={null}
      # For curl, make sure ELEVENLABS8_API_KEY is set in your environment
      export ELEVENLABS8_API_KEY="your_api_key_here"
      # Then run the curl command above
      ```
    </CodeBlocks>

    You should see "Audio generated successfully!" with the History ID and Audio URL, then find an `output.mp3` file in your directory.
  </Step>
</Steps>

## Request Format

All API requests to TTSLab should include the `X-API-KEY` header with your API key:

```bash theme={null}
X-API-KEY: your_api_key_here
```

## Model Versions

TTSLab supports different model versions with different request formats:

### v3 Models

Use the simplified `inputs` format with model\_id:

```json theme={null}
{
  "inputs": [
      {
        "text": "The first move is what sets everything in motion.",
        "voice_id": "JBFqnCBsd6RMkjVDRZzb"
      },
      {
        "text": "The second move is what sets everything in motion.",
        "voice_id": "2EiwWnXFnvU5JabPnv8n"
      },
  ],
  "model_id": "eleven_v3"
}
```

### v1/v2 Models

Use the traditional format with additional parameters and config:

```json theme={null}
{
  "text": "Your text here",
  "voice_id": "voice_id_here",
  "model_id": "eleven_flash_v2_5",
  "config": {
    "stability": 0.5,
    "similarity_boost": 0.75,
    "style": 0.0,
    "use_speaker_boost": true
  }
}
```

**Config Parameters:**

* `stability` (0.0 - 1.0): Controls voice consistency
* `similarity_boost` (0.0 - 1.0): Controls voice similarity to original
* `style` (0.0 - 1.0): Controls speaking style
* `use_speaker_boost` (boolean): Enhances speaker clarity

## Response Handling

The API returns a JSON object with the following structure:

```json theme={null}
{
  "id": "history_id_here",
  "user": {
    "fullname": "User Full Name",
    "avatar": "https://api.elevenlabs8.com/media/avatars/user.jpg"
  },
  "history_id": "unique_history_id",
  "prompt": "The first move is what sets everything in motion.",
  "model": "ttslab_multilingual_v3",
  "voice": "voice_name_here",
  "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"
}
```

### Response Fields:

* **`id`**: Unique identifier for the history record
* **`user`**: User information (fullname, avatar)
* **`history_id`**: History tracking ID
* **`prompt`**: The text that was converted to speech
* **`model`**: Model used for generation
* **`voice`**: Voice used for generation
* **`config`**: Configuration parameters used
* **`credits_used`**: Number of credits consumed
* **`status`**: Status of the generation (completed, processing, failed)
* **`shared_url`**: Public shareable URL for the audio
* **`created_at`**: Timestamp of creation
* **`audio_url`**: Direct URL to download the generated audio file

### Downloading the Audio:

To get the actual audio file, make a GET request to the `audio_url`:

```python theme={null}
# Download the audio file
audio_response = requests.get(response.json()["audio_url"])
with open("output.mp3", "wb") as f:
    f.write(audio_response.content)
```

## Next Steps

* Explore our [API reference](/docs/api-reference/introduction) for all available endpoints
* Learn about different [models](/docs/models) and their capabilities
* Check out [voice management](/docs/api-reference/endpoint/get) for working with voices
