{"record":{"id":"29a8903989aebdc3","repo":"xtekky/gpt4free","slug":"prompt-is-empty-29a890","errorCode":null,"errorMessage":"Prompt is empty.","messagePattern":"Prompt is empty\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"g4f/Provider/audio/ElevenLabs.py","lineNumber":65,"sourceCode":"    model_id = \"elevenlabs-tts\"\n    default_model = \"eleven_v3\"\n    default_voice = \"tS45q0QcrDHqHoaWdCDR\"\n    default_format = \"mp3_44100_128\"\n    default_language = \"pt\"\n\n    @classmethod\n    async def create_async_generator(\n        cls,\n        model: str,\n        messages: Messages,\n        prompt: str = None,\n        audio: dict = {},\n        proxy: str = None,\n        **kwargs,\n    ) -> AsyncResult:\n        prompt = get_last_message(messages, prompt)\n        if not prompt:\n            raise ValueError(\"Prompt is empty.\")\n\n        voice = audio.get(\"voice\", cls.default_voice)\n        model_id = audio.get(\"model\", cls.default_model)\n        output_format = audio.get(\"format\", cls.default_format)\n        language = audio.get(\"language\", cls.default_language)\n\n        # hcaptcha accessibility cookie — kwarg, then browser cookie store\n        cookie_val = kwargs.get(\"hc_accessibility\")\n        if not cookie_val:\n            cookie_val = get_cookies(\n                \".hcaptcha.com\", raise_requirements_error=False\n            ).get(\"hc_accessibility\")\n        if not cookie_val:\n            raise RuntimeError(\n                \"hCaptcha accessibility cookie required: log in at \"\n                \"https://dashboard.hcaptcha.com/signup?type=accessibility \"\n                'in your browser, or pass hc_accessibility=\"...\".'\n            )","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/audio/ElevenLabs.py#L47-L83","documentation":"ValueError from ElevenLabs.create_async_generator when there is no text to synthesize: get_last_message(messages, prompt) returned empty. Like all TTS providers, the audio path requires the source text.","triggerScenarios":"Invoking ElevenLabs audio generation with empty messages and no prompt kwarg.","commonSituations":"Chained pipelines where an upstream step produced empty text; whitespace-only strings; forwarded chat state with no user message.","solutions":["Pass prompt='text to speak' explicitly","Ensure the last message in messages has non-empty content","Strip and validate text before calling the audio endpoint"],"exampleFix":"# before\nresp = await client.speech.create(model='ElevenLabs', text='   ')\n\n# after\nresp = await client.speech.create(model='ElevenLabs', text=text.strip()) if text.strip() else None","handlingStrategy":"validation","validationCode":"text = (prompt or '').strip() or last_message_content(messages)\nif not text:\n    raise ValueError('ElevenLabs: nothing to synthesize')","typeGuard":null,"tryCatchPattern":"except ValueError as e:\n    if 'Prompt is empty' in str(e):\n        return None  # empty input is expected in optional-TTS flows","preventionTips":["Validate non-empty text at the API boundary of your app","Guard against whitespace-only strings, not just None"],"tags":["elevenlabs","tts","validation","empty-input"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}