Voice Cloner API

Category: media

Clone a voice from an audio sample and generate speech using ElevenLabs AI. Returns an MP3 audio file.

Endpoint

POST https://anythingtext.com/api/tools/voiceclone
Authentication Required Content-Type: multipart/form-data

Authentication

This API requires an API key. Generate one from the API Keys section in your dashboard settings.

Include the X-API-Key header in all API requests:

X-API-Key: atk_your_api_key_here

Rate Limiting

API requests are limited to 60 requests per minute per user. If you exceed this limit, the API returns a 429 Too Many Requests response.

Every response includes rate limit headers:

X-RateLimit-Limit: 60
X-RateLimit-Remaining: 57
X-RateLimit-Reset: 42

When rate limited, the response body contains:

{ "error": "Rate limit exceeded. Maximum 60 requests per minute.", "retryAfter": 42, "limit": 60 }

Request Parameters

Name Type Required Description
sample File Required Voice sample audio file (MP3, WAV) — at least 30 seconds recommended
Example: voice_sample.mp3
text String Required The text to speak in the cloned voice
Example: Hello, this is my cloned voice speaking.

Response

Content-Type: audio/mpeg

MP3 audio file of the cloned voice speaking the text

(binary MP3 data)

Error Responses

StatusDescriptionBody
401 Not authenticated {"error": "Please log in..."}
400 Bad request / Missing required params {"error": "... is required"}
500 Internal server error {"error": "Failed to ..."}

cURL Example

curl -X POST https://anythingtext.com/api/tools/voiceclone \
  -H "X-API-Key: your_api_key_here" \
  -F "sample=@voice_sample.mp3" \
  -F "text=Hello, this is my cloned voice." \
  --output cloned_speech.mp3

Code Samples

const formData = new FormData();
formData.append('sample', fileInput.files[0]);
formData.append('text', 'Hello, this is my cloned voice.');

const response = await fetch('https://anythingtext.com/api/tools/voiceclone', {
    method: 'POST',
    headers: { 'X-API-Key': 'your_api_key_here' },
    body: formData
});

const blob = await response.blob();
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'output.mp3';
a.click();
import requests

with open('input.mp3', 'rb') as f:
    response = requests.post(
        'https://anythingtext.com/api/tools/voiceclone',
        files={'sample': f},
        data={'text': 'Hello, this is my cloned voice.'},
        headers={'X-API-Key': 'your_api_key_here'}
    )

with open('output.mp3', 'wb') as f:
    f.write(response.content)

print('Saved to output.mp3')
import java.net.URI;
import java.net.http.*;
import java.nio.file.*;

HttpClient client = HttpClient.newHttpClient();
// Build multipart form data with file + parameter
String boundary = "----Boundary" + System.currentTimeMillis();
byte[] fileBytes = Files.readAllBytes(Path.of("input.mp3"));

// See cURL example above for the equivalent command.
// For Java multipart uploads, consider using Apache HttpClient
// or Spring WebClient for simpler multipart handling.

// Example with Apache HttpClient:
// HttpEntity entity = MultipartEntityBuilder.create()
//     .addBinaryBody("sample", fileBytes)
//     .addTextBody("text", "Hello, this is my cloned voice.")
//     .build();