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
- Read the embedded status/body detail: 429 means wait/back off; 403 means the key lacks subscription-read permission; 5xx means retry later.
- If using a custom music_base_url, verify the gateway actually proxies /v1/user/subscription.
- 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
- Rate-limit connection tests (once per session, not per request).
- Read the embedded status code: 403 is permanent (fix key permissions), 429/5xx are transient (back off).
- If using a custom music_base_url, ensure it proxies the subscription path faithfully.
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
- ElevenLabs subscription response does not include an account
- ElevenLabs returned no audio data
- ElevenLabs generation failed ({response.status_code}): {_saf
- ElevenLabs API key is required
- ElevenLabs API key was rejected (401): {_safe_response_error
AI-assisted analysis of harry0703/MoneyPrinterTurbo@1f9f19c202 (2026-08-14).
Data as JSON: /api/errors/858d16d750280fee.
Report an issue: GitHub.