harry0703/MoneyPrinterTurbo · error · ElevenLabsMusicError

ElevenLabs music prompt exceeds 1000 characters

Error message

ElevenLabs music prompt exceeds 1000 characters

What it means

Prompt-length guard in generate_bgm: the stripped prompt exceeds MAX_PROMPT_LENGTH (1000 characters). Sent as form data alongside the video, an oversized prompt would be rejected by ElevenLabs after the whole video upload.

Solutions

  1. Truncate or summarize the prompt to well under 1000 chars — a music style description rarely needs more than a few sentences
  2. If the prompt is LLM-generated, add a length constraint to the generation instruction
  3. Validate prompt length in the UI/task layer so the user gets feedback before render time

Example fix

# before
music_prompt = full_video_script  # thousands of chars
generate_bgm(video, out, duration, music_prompt)

# after
music_prompt = full_video_script[:1000] if len(full_video_script) > 1000 else full_video_script
generate_bgm(video, out, duration, music_prompt)
Defensive patterns

Strategy: validation

Validate before calling

from app.services.elevenlabs_music import MAX_PROMPT_LENGTH

prompt = prompt.strip()[:MAX_PROMPT_LENGTH]

Prevention

When it happens

Trigger: generate_bgm called with a prompt whose .strip() length exceeds 1000 chars — typically a whole video description or concatenated per-scene prompts instead of a short style description.

Common situations: Reusing the full video script/subject text as the music prompt, LLM-generated prompts without a length budget, or prompts in CJK where token-to-char limits are easy to blow past.

Related errors


AI-assisted analysis of harry0703/MoneyPrinterTurbo@1f9f19c202 (2026-08-14). Data as JSON: /api/errors/8ef655595f6f0718. Report an issue: GitHub.

Appendix: source

Thrown at app/services/elevenlabs_music.py:388

    if not get_api_key():
        raise ElevenLabsMusicError("ElevenLabs API key is required")
    if not os.path.isfile(video_path):
        raise ElevenLabsMusicError("ElevenLabs input video does not exist")
    try:
        duration = float(video_duration)
    except (TypeError, ValueError) as exc:
        raise ElevenLabsMusicError(
            "ElevenLabs video duration is invalid"
        ) from exc
    if not math.isfinite(duration) or duration <= 0:
        raise ElevenLabsMusicError("ElevenLabs video duration is invalid")
    if duration > MAX_VIDEO_DURATION_SECONDS:
        raise ElevenLabsMusicError(
            "ElevenLabs supports videos up to 600 seconds"
        )
    prompt = str(prompt or "").strip()
    if len(prompt) > MAX_PROMPT_LENGTH:
        raise ElevenLabsMusicError(
            "ElevenLabs music prompt exceeds 1000 characters"
        )

    proxy_path = ""
    try:
        proxy_path = _create_video_proxy(video_path)
        return _request_bgm(proxy_path, output_path, prompt)
    except ElevenLabsMusicError:
        raise
    except OSError as exc:
        raise ElevenLabsMusicError(
            f"ElevenLabs local file operation failed: {exc}"
        ) from exc
    finally:
        _remove_file(proxy_path)

View on GitHub (pinned to 1f9f19c202)