{"record":{"id":"57f1852808a37d4b","repo":"xtekky/gpt4free","slug":"prompt-cannot-be-empty-57f185","errorCode":null,"errorMessage":"Prompt cannot be empty.","messagePattern":"Prompt cannot be empty\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"g4f/Provider/needs_auth/Video.py","lineNumber":157,"sourceCode":"    @classmethod\n    async def create_async_generator(\n        cls, model: str, messages: Messages, prompt: str = None, **kwargs\n    ) -> AsyncResult:\n        if not model:\n            model = cls.default_model\n        if model not in cls.video_models:\n            raise ValueError(\n                f\"Model '{model}' is not supported by {cls.__name__}. Supported models: {cls.models}\"\n            )\n        yield ProviderInfo(**cls.get_dict(), model=model)\n        prompt = (\n            format_media_prompt(messages, prompt)\n            .encode()[:100]\n            .decode(\"utf-8\", \"ignore\")\n            .strip()\n        )\n        if not prompt:\n            raise ValueError(\"Prompt cannot be empty.\")\n        prompt = await RequestConfig.translate_prompt(prompt)\n        response = await RequestConfig.get_response(prompt, model == \"search\")\n        if response:\n            yield Reasoning(label=f\"Found {len(response.urls)} Video(s)\", status=\"\")\n            yield response\n            return\n        raise RuntimeError(\"Failed to find any videos for the prompt.\")\n","sourceCodeStart":139,"sourceCodeEnd":165,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/needs_auth/Video.py#L139-L165","documentation":"Raised as ValueError by the Video provider when format_media_prompt(messages, prompt) truncates/normalizes to an empty string (encode to 100 bytes, decode, strip). If the user messages contain no usable text and no explicit prompt was given, there is nothing to search videos with.","triggerScenarios":"Messages consist solely of media/empty content, or the first 100 bytes decode to whitespace only, and no prompt argument was passed.","commonSituations":"Sending image-only messages to a video search provider, prompt argument accidentally empty string, whitespace-only user content.","solutions":["Pass a non-empty prompt argument describing the desired video","Ensure the user message contains actual text content, not just attachments"],"exampleFix":"# before\nresponse = client.chat.completions.create(model='search', messages=[{'role':'user','content':''}], provider=g4f.Provider.Video)\n\n# after\nresponse = client.chat.completions.create(model='search', messages=[{'role':'user','content':''}], prompt='ocean waves at sunset', provider=g4f.Provider.Video)","handlingStrategy":"validation","validationCode":"from g4f.Provider.helper import format_media_prompt\nif not (prompt or format_media_prompt(messages, None)).strip():\n    raise ValueError('Provide a text prompt for video search')","typeGuard":"def has_video_prompt(messages, prompt: str | None) -> bool:\n    text = prompt or ' '.join(m.get('content', '') for m in messages if isinstance(m.get('content'), str))\n    return bool(text.strip())","tryCatchPattern":"try:\n    result = ...create(..., provider=g4f.Provider.Video)\nexcept ValueError as e:\n    if 'empty' in str(e):\n        skip_video_enrichment()\n    else:\n        raise","preventionTips":["Always pass an explicit prompt when messages may be media-only","Validate user content contains non-whitespace text before routing to media providers"],"tags":["validation","empty-prompt","video","g4f"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}