Unlimited Open Source Models

Get Plan
Skip to main content
Audio Gen

Voice Cloning API Developer Guide

Complete developer guide for integrating voice cloning into your application. Clone voices from 10-second samples, generate multilingual speech, and build voice-powered features.

Voice Cloning API: The Complete Developer Guide

What is Voice Cloning API Integration?

A voice cloning API lets developers programmatically replicate a voice from a short audio sample and use it to generate speech from any text. ModelsLab voice cloning works from as little as 3 seconds of reference audio (about 10 seconds is recommended — longer samples are trimmed) and generates natural, expressive speech in 48 languages.

This developer guide walks through the complete integration process: cloning in a single call, creating reusable voice profiles, handling async processing, error handling, and production best practices.

Prerequisites and Setup

Before you start integrating the voice cloning API:

  • ModelsLab account with API key — create an account at modelslab.com and subscribe to a plan (from $21/month)
  • Audio sample — 10-30 seconds of clear speech, WAV or MP3 format, minimal background noise
  • HTTP client — Python requests, Node.js fetch, or any REST-capable language
  • Storage — Somewhere to store generated audio files (S3, GCS, or local filesystem)
  • Webhook endpoint (optional) — For async processing notifications in production

API Architecture Overview

The ModelsLab voice cloning API has two integration paths:

  • One-call cloning — POST to /api/v6/voice/text_to_audio with your text as prompt and a reference sample URL as init_audio. The reference is cloned and the speech is generated in the same request.
  • Reusable voice profiles — POST the sample once to /api/v6/voice/voice_upload (name + init_audio + language) to get a permanent voice_id, then pass that voice_id to text_to_audio instead of re-uploading the sample each time. Accounts can store up to 200 voices.
  • Generation is queued: the response is either status "success" with output audio URLs, or status "processing" with an eta and a fetch_result URL to poll (or pass a webhook to be called when done).
  • Note: /api/v6/voice/text_to_speech is a separate endpoint for the pre-trained voice library only — custom cloned voices generate through text_to_audio.
  • All endpoints are standard REST with JSON payloads. Authentication is via API key in the request body.

Voice Cloning API Code Examples

From voice sample upload to speech generation — production-ready code.

Clone a voice and speak in one call (Python)

Python
1import requests
2
3# One call: clone from a reference sample and generate speech
4url = "https://modelslab.com/api/v6/voice/text_to_audio"
5payload = {
6 "key": "YOUR_API_KEY",
7 "prompt": "Welcome to our platform. We are glad to have you here.",
8 "init_audio": "https://your-storage.com/voice-sample.wav",
9 "language": "english",
10 "emotion": "neutral",
11 "speed": 1.0
12}
13
14response = requests.post(url, json=payload)
15data = response.json()
16
17if data["status"] == "success":
18 print(f"Generated audio: {data['output'][0]}")
19elif data["status"] == "processing":
20 # Queued — poll fetch_result (or pass a webhook instead)
21 print(f"ETA {data['eta']}s, poll: {data['fetch_result']}")

Create a reusable voice profile (Python)

Python
1import time
2
3# Upload the sample once, reuse the voice_id forever.
4# The voice_id is derived from the name and is globally unique —
5# pick a name specific to you.
6url = "https://modelslab.com/api/v6/voice/voice_upload"
7payload = {
8 "key": "YOUR_API_KEY",
9 "name": f"customer-voice-{int(time.time())}",
10 "init_audio": "https://your-storage.com/voice-sample.wav",
11 "language": "english"
12}
13
14data = requests.post(url, json=payload).json()
15if data["status"] != "success":
16 raise RuntimeError(data["message"])
17voice_id = data["voice_id"]
18
19# Generate with the stored profile — no re-upload needed
20payload = {
21 "key": "YOUR_API_KEY",
22 "prompt": "Welcome back. Here is today's update.",
23 "voice_id": voice_id,
24 "language": "english"
25}
26data = requests.post(
27 "https://modelslab.com/api/v6/voice/text_to_audio", json=payload
28).json()
29print(data["output"][0] if data["status"] == "success" else data)

Full integration with async handling (JavaScript)

JavaScript
1async function cloneVoiceAndSpeak(sampleUrl, text) {
2 const res = await fetch('https://modelslab.com/api/v6/voice/text_to_audio', {
3 method: 'POST',
4 headers: { 'Content-Type': 'application/json' },
5 body: JSON.stringify({
6 key: 'YOUR_API_KEY',
7 prompt: text,
8 init_audio: sampleUrl,
9 language: 'english'
10 })
11 });
12
13 let data = await res.json();
14 if (data.status === 'error') throw new Error(data.message);
15
16 // Queued generation: poll fetch_result until the audio is ready
17 while (data.status === 'processing') {
18 await new Promise((r) => setTimeout(r, (data.eta || 5) * 1000));
19 const poll = await fetch(data.fetch_result, {
20 method: 'POST',
21 headers: { 'Content-Type': 'application/json' },
22 body: JSON.stringify({ key: 'YOUR_API_KEY' })
23 });
24 data = await poll.json();
25 }
26
27 if (data.status !== 'success') throw new Error(data.message || data.status);
28 return data.output[0]; // Audio URL
29}
30
31// Usage
32const audioUrl = await cloneVoiceAndSpeak(
33 'https://storage.example.com/sample.wav',
34 'This is generated speech using a cloned voice.'
35);
36console.log(`Audio: ${audioUrl}`);

Multilingual voice generation

Python
1# Generate the same cloned voice in multiple languages
2texts = {
3 "english": "Hello, welcome to our service.",
4 "spanish": "Hola, bienvenido a nuestro servicio.",
5 "french": "Bonjour, bienvenue dans notre service.",
6 "german": "Hallo, willkommen bei unserem Service.",
7 "japanese": "こんにちは、サービスへようこそ。"
8}
9
10for lang, text in texts.items():
11 payload = {
12 "key": "YOUR_API_KEY",
13 "prompt": text,
14 "voice_id": voice_id, # from voice_upload
15 "language": lang
16 }
17 response = requests.post("https://modelslab.com/api/v6/voice/text_to_audio", json=payload)
18 data = response.json()
19 print(f"{lang}: {data['output'][0] if data['status'] == 'success' else data['fetch_result']}")

Integration Workflow

Build voice cloning into your app in three steps.

STEP 01
STEP 01

Step 1: Create a Voice Profile

Upload a ~10 second sample of clear speech to voice_upload. The API stores the sample and returns a voice_id — a reusable identifier for all future generation with that voice. (Or skip this step and pass the sample directly as init_audio.)

STEP 02
STEP 02

Step 2: Generate Speech

Send any text as prompt along with the voice_id (or init_audio) to text_to_audio. Receive generated audio as a URL (reference audio can also be sent as base64 via the base64 parameter). Supports speed, emotion, and language controls.

STEP 03
STEP 03

Step 3: Production Integration

Use webhooks for async processing, cache voice profiles, implement error handling and retries, and add multilingual support. Scale to thousands of voice generations per day.

Voice Cloning API Providers Compared

How ModelsLab voice cloning compares to ElevenLabs and other providers.

FeatureModelsLabElevenLabsPlay.htResemble AI
Min Sample Length~3s (10s recommended)30 seconds30 seconds1 minute
Languages Supported482930+24
Starting PriceFlat plans from $21/mo$5/mo (starter)$39/mo$24/mo
Free TierPaid, from $21/mo10k chars/moTrial onlyTrial only
Emotional ControlYesYesLimitedYes
Reusable Voice ProfilesUp to 200 voicesPaid tiersYesYes
Image + Video APIs TooSame keyNoNoNo
Webhook SupportYesYesNoYes

Data as of April 2026. Based on publicly available documentation.

Production Best Practices

When deploying voice cloning in production applications:

  • Cache voice profiles — Upload the sample once via voice_upload and reuse the voice_id. Do not re-upload samples for each generation.
  • Use webhooks for async — Generation is queued with an ETA of roughly 10 seconds. Pass a webhook URL instead of polling fetch_result in production.
  • Handle errors gracefully — Validation and generation errors return status "error" with a message in the JSON body. Implement retry logic with exponential backoff.
  • Validate audio samples — At least 3 seconds of clear speech with minimal background noise; only the first ~10 seconds of the reference are used for cloning.
  • Store generated audio — Download output URLs into your own storage (S3, GCS). Pass temp: true if you want the platform to write to temporary storage instead.
  • Monitor usage — Track API calls and generation quality. Use ModelsLab dashboard for usage analytics.

Authentication and Rate Limits

The ModelsLab voice cloning API uses API key authentication passed in the request body. Plans start at $21/month (Basic, 3,250 API calls) and scale to thousands of concurrent requests on higher tiers. Errors — including rate limits — are returned as JSON with status "error" and a descriptive message, so check the status field of every response rather than relying on HTTP status codes.

For enterprise workloads, dedicated instances provide guaranteed throughput and custom rate limits. Contact sales for SLA-backed voice cloning infrastructure.

ModelsLab Voice Cloning API Features

Key advantages that set us apart

Clone any voice from a ~10-second sample
48 languages supported for multilingual generation
Emotion control: neutral, happy, sad, angry, dull
Reusable voice profiles — store up to 200 voices
Webhook callbacks for async processing
Plans start at $21/month (Basic, 3,250 API calls)
Same API key for voice + image + video + LLM
Python and JavaScript code examples
Production-ready error handling and retry logic
GDPR-compliant with configurable data retention
Enterprise SLA with dedicated instances
Audio output as URL; base64 reference-audio input

Our Popular Use Cases

What developers build with the voice cloning API:

Generate podcast intros, audiobook narrations, and personalized voice messages using cloned voices. Scale audio content creation.

Personalized Audio Content

Voice Cloning API Developer FAQ

ModelsLab voice cloning requires a minimum of 3 seconds of clear speech, and about 10 seconds is recommended — only the first ~10 seconds of the reference are used, so longer samples are trimmed. Provide clear speech with minimal background noise. WAV and MP3 formats are supported.

ModelsLab voice cloning API supports 48 languages for speech generation, passed as full names in the language parameter (e.g. "english", "spanish", "japanese"). The cloned voice maintains its characteristics across languages, so one sample can speak English, Spanish, French, German, Japanese, and more.

Yes. ModelsLab voice cloning API can be used in commercial applications. Ensure you have appropriate consent from the voice owner. ModelsLab provides usage rights for voices generated through the API for commercial use.

The voice cloning API returns generated audio as publicly accessible URLs. Download and store the files in your own storage for permanent access, or pass temp: true to write to temporary storage. If your reference sample is not hosted anywhere, send it as base64 in init_audio with base64: true.

ModelsLab clones from shorter samples (~10s recommended vs 30s minimum), supports more languages (48 vs 29), and uses flat plans from $21/month rather than character-capped tiers (ElevenLabs caps its free tier at 10k characters/month). ModelsLab also provides image, video, and LLM APIs through the same key. ElevenLabs has a more mature voice library.

Voice cloning generation is asynchronous with an ETA of roughly 10 seconds — responses return either the finished audio or a fetch_result URL to poll, and webhooks notify your app when generation completes. For live conversational audio, ModelsLab provides a separate voice-call API.

Check the status field of every JSON response: "error" carries a descriptive message (including rate limits), "processing" means poll fetch_result or wait for your webhook, and "failed" means the generation did not complete. Implement exponential backoff with 3-5 retries and monitor with the ModelsLab dashboard for usage analytics and error rates.

Your Data is Secure: GDPR Compliant AI Services

ModelsLab GDPR Compliance Certification Badge

GDPR Compliant

Get Expert Support in Seconds

We're Here to Help.

Want to know more? You can email us anytime at support@modelslab.com

View Docs
Plugins

Explore Plugins for Pro

Our plugins are designed to work with the most popular content creation software.

API

Build Apps with
ML
API

Use our API to build apps, generate AI art, create videos, and produce audio with ease.