← GPT-AI-VIDEO
DOCUMENT · 4.8 KB

vendor/OpenMontage/.agents/skills/elevenlabs/reference.md

Workspace snapshot · 09/04 14:52

ElevenLabs API Reference

Detailed API documentation for ElevenLabs audio generation services.

Authentication

from elevenlabs.client import ElevenLabs
client = ElevenLabs(api_key=os.getenv("ELEVENLABS_API_KEY"))

Text-to-Speech Models

Model IDDescriptionLanguagesLatency
eleven_flash_v2_5Ultra-low latency streaming32~75ms
eleven_multilingual_v2Highest quality32Standard
eleven_turbo_v2_5Fast, good quality32Low
eleven_v3Best emotional range (alpha)32+Higher

Voice Settings

ParameterRangeDefaultEffect
stability0.0-1.00.5Lower = more expressive/variable
similarity_boost0.0-1.00.75Higher = closer to original voice
style0.0-1.00.0Style exaggeration (v2 models)
speed0.5-2.01.0Playback speed multiplier

Output Formats

Format CodeSample RateBitrateTier Required
mp3_44100_12844.1kHz128kbpsFree (default)
mp3_44100_19244.1kHz192kbpsCreator+
pcm_4410044.1kHz-Pro+
ulaw_80008kHz-Free (telephony)

Long-form Audio (Stitching)

For continuity across multiple generations:

result1 = client.text_to_speech.convert_with_timestamps(
    text="First paragraph...",
    voice_id="JBFqnCBsd6RMkjVDRZzb",
    model_id="eleven_multilingual_v2"
)
request_id_1 = result1.request_id

result2 = client.text_to_speech.convert(
    text="Second paragraph...",
    voice_id="JBFqnCBsd6RMkjVDRZzb",
    model_id="eleven_multilingual_v2",
    previous_request_ids=[request_id_1]
)

Professional Voice Cloning (PVC)

Requires Creator plan+. Creates a fine-tuned model (3-6 hours training).

Requirements:

  • 30 min minimum, 2-3 hours optimal audio
  • Professional XLR mic recommended
  • Pop filter, ~20cm distance
  • Peak levels: -6dB to -3dB
  • Consistent performance style

Workflow:

# 1. Create PVC with samples
pvc = client.voices.create_professional_voice_clone(
    name="My Pro Voice",
    files=["recording1.mp3", "recording2.mp3", ...],
)

# 2. Get verification captcha
captcha = client.voices.get_pvc_verification_captcha(voice_id=pvc.voice_id)
# Read the captcha text aloud and record

# 3. Submit verification
client.voices.verify_pvc(
    voice_id=pvc.voice_id,
    recording=open("captcha_reading.mp3", "rb")
)

# 4. Start training
client.voices.start_pvc_training(voice_id=pvc.voice_id)

Sound Effects Parameters

ParameterTypeRequiredDescription
textstringYesDescription of sound effect
duration_secondsfloatNo1-22 seconds (auto if omitted)
prompt_influencefloatNo0.0-1.0 (default 0.3)

Billing: 100 chars/generation (auto) or 25 chars/second (fixed duration)

Example prompts:

  • Environmental: "Rain on a tin roof, steady and rhythmic"
  • Action: "Sword being drawn from sheath, metallic ring"
  • Mechanical: "Old car engine struggling to start then roaring to life"

Music Parameters

ParameterTypeRequiredDescription
promptstringYes*Natural language music description
composition_planobjectYes*Detailed composition structure
duration_msintNo10000-300000 (10s-5min)
instrumentalboolNoForce instrumental output

*Either prompt or composition_plan required, not both.

Effective prompts include:

  1. Genre/Style: "indie rock", "lo-fi hip hop", "orchestral"
  2. Mood: "uplifting", "melancholic", "tense"
  3. Instruments: "acoustic guitar", "synth pads", "strings"
  4. Tempo/Energy: "slow", "upbeat", "driving"
  5. Context: "for a travel vlog", "podcast intro"

Rate Limits by Tier

TierTTS ConcurrentSFX ConcurrentMusic Concurrent
Free221
Starter332
Creator553
Pro10105
Scale151510

Voice Management

# List voices
voices = client.voices.get_all()
for voice in voices.voices:
    print(f"{voice.name}: {voice.voice_id}")

# Delete voice
client.voices.delete(voice_id="your_voice_id")

Error Handling

from elevenlabs.core.api_error import ApiError

try:
    audio = client.text_to_speech.convert(...)
except ApiError as e:
    if e.status_code == 429:
        print("Rate limited - wait and retry")
    elif e.status_code == 401:
        print("Invalid API key")
CodeMeaningAction
401Invalid API keyCheck API key
403Feature not availableUpgrade tier
422Invalid parametersCheck request body
429Rate limitedWait and retry