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

# Clone Voice

> Create a custom voice clone from audio samples

Create a professional voice clone using ElevenLabs technology. Upload audio samples of the voice you want to clone, and we'll create a custom voice that can be used with your AI agents.

## Request Body

Send as `multipart/form-data`:

<ParamField body="name" type="string" required>
  Name for the cloned voice.

  **Example:** `Dr. Smith`
</ParamField>

<ParamField body="description" type="string">
  Description of the voice characteristics.

  **Example:** `Warm, professional male voice`
</ParamField>

<ParamField body="files" type="file[]" required>
  Audio files for voice cloning.

  **Requirements:**

  * At least 1 file, up to 25 files
  * Supported formats: WAV, MP3, M4A
  * At least 30 seconds of clean audio per file
  * Total audio should be 1-3 minutes for best results
  * Clear speech, minimal background noise
</ParamField>

## Response

<ResponseField name="id" type="string">
  Unique voice identifier (use as `voice_id` in agent config).
</ResponseField>

<ResponseField name="name" type="string">
  Voice display name.
</ResponseField>

<ResponseField name="description" type="string">
  Voice description.
</ResponseField>

<ResponseField name="preview_url" type="string">
  URL to preview the cloned voice.
</ResponseField>

<ResponseField name="provider" type="string">
  Voice provider (always `elevenlabs` for cloned voices).
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.magpipe.ai/functions/v1/clone-voice \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -F "name=Dr. Smith" \
    -F "description=Warm, professional male voice" \
    -F "files=@sample1.wav" \
    -F "files=@sample2.wav"
  ```

  ```javascript Node.js theme={null}
  const formData = new FormData();
  formData.append('name', 'Dr. Smith');
  formData.append('description', 'Warm, professional male voice');
  formData.append('files', audioFile1);
  formData.append('files', audioFile2);

  const response = await fetch(
    'https://api.magpipe.ai/functions/v1/clone-voice',
    {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_API_KEY',
      },
      body: formData,
    }
  );

  const voice = await response.json();
  console.log('Voice ID:', voice.id);
  ```

  ```python Python theme={null}
  import requests

  files = [
      ('files', ('sample1.wav', open('sample1.wav', 'rb'), 'audio/wav')),
      ('files', ('sample2.wav', open('sample2.wav', 'rb'), 'audio/wav')),
  ]

  response = requests.post(
      'https://api.magpipe.ai/functions/v1/clone-voice',
      headers={
          'Authorization': 'Bearer YOUR_API_KEY',
      },
      data={
          'name': 'Dr. Smith',
          'description': 'Warm, professional male voice',
      },
      files=files
  )

  voice = response.json()
  print(f"Voice ID: {voice['id']}")
  ```
</RequestExample>

<ResponseExample>
  ```json Success Response theme={null}
  {
    "id": "pNInz6obpgDQGcFmaJgB",
    "name": "Dr. Smith",
    "description": "Warm, professional male voice",
    "preview_url": "https://api.elevenlabs.io/v1/voices/pNInz6obpgDQGcFmaJgB/preview.mp3",
    "provider": "elevenlabs",
    "created_at": "2024-01-15T10:30:00Z"
  }
  ```

  ```json Error Response theme={null}
  {
    "error": {
      "code": "insufficient_audio",
      "message": "Please provide at least 30 seconds of clean audio"
    }
  }
  ```
</ResponseExample>

## Voice Cloning Tips

For best results:

1. **Use high-quality recordings** - Professional microphone, quiet room
2. **Provide diverse samples** - Different sentences, natural intonation
3. **Avoid music/background noise** - Clean speech only
4. **Include natural speech patterns** - Not too formal or scripted
5. **1-3 minutes total** - More audio generally improves quality
