# Clone a voice

> Create a cloned voice for your project from recordings of the speaker, with their consent.

`POST https://api.getlykia.com/v1/audio/voices`

Creates a voice from recordings of a speaker, for models that support cloning. The request is `multipart/form-data`. Walkthrough: [Speech and voices](https://www.getlykia.com/en/docs/guides/speech-and-voices#clone-a-voice).

> **Consent is required:** Clone only a voice you have the right to use. `consent=true` is your statement that the speaker has given you permission to clone their voice. Without it the request is rejected with `consent_required`. Lykia records the statement with the API key and project that sent it.

## Form fields

- `file` (file, required) — A recording of the speaker. Repeat the field to send several recordings.
- `name` (string, required) — A name for the voice, up to 100 characters.
- `consent` (string, required) — `true`.
- `model` (string) — The speech model to clone for (for example `elevenlabs/eleven_multilingual_v2`), or a preset. Defaults to `@tts`.
- `description` (string) — A note about the voice.
- `language` (string) — The speaker's language.

## Example

**Request**

cURL

```bash
# consent=true confirms that you have the speaker's permission to clone this voice
curl https://api.getlykia.com/v1/audio/voices \
  -H "Authorization: Bearer $LYKIA_API_KEY" \
  -F model=elevenlabs/eleven_multilingual_v2 \
  -F name="Store narrator" \
  -F description="Calm narration voice" \
  -F consent=true \
  -F file=@sample.mp3
```

Python

```python
import os

import requests

with open("sample.mp3", "rb") as sample:
    response = requests.post(
        "https://api.getlykia.com/v1/audio/voices",
        headers={"Authorization": f"Bearer {os.environ['LYKIA_API_KEY']}"},
        data={
            "model": "elevenlabs/eleven_multilingual_v2",
            "name": "Store narrator",
            # You confirm that you have the speaker's permission to clone this voice
            "consent": "true",
        },
        files={"file": ("sample.mp3", sample, "audio/mpeg")},
        timeout=120,
    )
response.raise_for_status()
voice = response.json()
print(voice["id"], voice["name"])  # use the id as `voice` in speech requests of this project
```

TypeScript

```typescript
import { readFile } from "node:fs/promises";

const form = new FormData();
form.append("model", "elevenlabs/eleven_multilingual_v2");
form.append("name", "Store narrator");
// You confirm that you have the speaker's permission to clone this voice
form.append("consent", "true");
form.append("file", new Blob([await readFile("sample.mp3")], { type: "audio/mpeg" }), "sample.mp3");

const response = await fetch("https://api.getlykia.com/v1/audio/voices", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.LYKIA_API_KEY}` },
  body: form,
});
if (!response.ok) throw new Error(`Lykia returned ${response.status}: ${await response.text()}`);

const voice = (await response.json()) as { id: string; name: string };
console.log(voice.id, voice.name); // use the id as `voice` in speech requests of this project
```

**Response (201)**

```json
{
    "id": "lvc_xg3eZdWjqZ19YY04ozRw",
    "object": "voice",
    "name": "Narrator",
    "category": "cloned",
    "description": "Calm narration voice",
    "provider": "elevenlabs",
    "model": "elevenlabs/eleven_multilingual_v2",
    "created_at": 1795463459,
    "requires_verification": false
}
```

## Response

`201` with the voice: `id` (`lvc_…`), `object` (`voice`), `name`, `category` (`cloned`), `description`, `provider`, `model`, `created_at` and `requires_verification` (whether the provider wants the speaker to verify the clone before use).

The clone belongs to the key's project and works only there, with the same provider and the same key (Lykia's or your own) it was created with. Cloning is not charged.

## Errors

| Status | Code                | When                                     |
| ------ | ------------------- | ---------------------------------------- |
| `400`  | `consent_required`  | `consent=true` is missing.               |
| `400`  | `unsupported_model` | The model cannot clone voices.           |
| `413`  | `payload_too_large` | A recording is larger than Lykia allows. |

```json
{
    "error": {
        "message": "Voice cloning requires `consent=true`: you confirm you have the speaker's permission to clone this voice",
        "type": "invalid_request_error",
        "code": "consent_required",
        "status": 400,
        "metadata": {
            "reason": "invalid_request",
            "param": "consent"
        }
    }
}
```
