harry0703/MoneyPrinterTurbo · error · ElevenLabsMusicError

ElevenLabs account check failed ({response.status_code}): {_

Error message

ElevenLabs account check failed ({response.status_code}): {_safe_response_error(response)}

What it means

ElevenLabsMusicError raised by test_connection() when the subscription endpoint answers with a non-ok status other than 401 (402/403/429/5xx...). The message includes the status code and _safe_response_error(response), which streams at most 500 bytes of the body — enough to see ElevenLabs' reason without polluting logs or reading unbounded error content. 401 is handled separately as an authentication error.

Source

Thrown at app/services/elevenlabs_music.py:128

    响应中的账单和用量详情不会写入日志,避免记录账号隐私。
    """
    api_key = get_api_key()
    if not api_key:
        raise ElevenLabsAuthenticationError("ElevenLabs API key is required")
    try:
        with requests.get(
            f"{_base_url()}{SUBSCRIPTION_PATH}",
            headers={"xi-api-key": api_key},
            timeout=(15, 30),
            stream=True,
        ) as response:
            if response.status_code == 401:
                raise ElevenLabsAuthenticationError(
                    "ElevenLabs API key was rejected (401): "
                    f"{_safe_response_error(response)}"
                )
            if not response.ok:
                raise ElevenLabsMusicError(
                    "ElevenLabs account check failed "
                    f"({response.status_code}): "
                    f"{_safe_response_error(response)}"
                )
            try:
                payload = response.json()
            except ValueError as exc:
                raise ElevenLabsMusicError(
                    "ElevenLabs returned an invalid subscription response"
                ) from exc
    except requests.RequestException as exc:
        raise ElevenLabsMusicError(
            f"failed to connect to ElevenLabs: {exc}"
        ) from exc
    if not isinstance(payload, dict):
        raise ElevenLabsMusicError(
            "ElevenLabs returned an unexpected subscription response"
        )

View on GitHub (pinned to 1f9f19c202)

Solutions

  1. Read the embedded status/body detail: 429 means wait/back off; 403 means the key lacks subscription-read permission; 5xx means retry later.
  2. If using a custom music_base_url, verify the gateway actually proxies /v1/user/subscription.
  3. Retry after a short backoff for transient 5xx; surface the status to the user instead of retrying 403.
Defensive patterns

Strategy: retry

Try / catch

import time
for attempt in range(3):
    try:
        return test_connection()
    except ElevenLabsMusicError as e:
        if 'account check failed (429' in str(e) or ' 5' in str(e):
            time.sleep(2 ** attempt)
            continue
        raise

Prevention

When it happens

Trigger: Any 2xx-以外的 status that is not 401: 403 when the key lacks permission for the subscription endpoint, 429 rate limiting, 5xx outages, or a misconfigured music_base_url pointing at a gateway that returns 404/502.

Common situations: Rate-limited keys during batch video generation; per-endpoint restricted keys; corporate proxies or custom music_base_url values returning non-ElevenLabs errors; transient API incidents.

Related errors


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