{"record":{"id":"a3711a206b067fac","repo":"sgl-project/sglang","slug":"either-prompt-or-prompt-embeds-must-be-provide","errorCode":null,"errorMessage":"Either `prompt` or `prompt_embeds` must be provided","messagePattern":"Either `prompt` or `prompt_embeds` must be provided","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/input_validation.py","lineNumber":325,"sourceCode":"\n        self._generate_seeds(batch, server_args)\n\n        if (\n            server_args.pipeline_config.task_type == ModelTaskType.I2M\n            and batch.num_inference_steps is None\n            and hasattr(server_args.pipeline_config, \"shape_num_inference_steps\")\n        ):\n            batch.num_inference_steps = (\n                server_args.pipeline_config.shape_num_inference_steps\n            )\n\n        # Ensure prompt is properly formatted (I2M can be image-only)\n        if (\n            server_args.pipeline_config.task_type != ModelTaskType.I2M\n            and batch.prompt is None\n            and batch.prompt_embeds is None\n        ):\n            raise ValueError(\"Either `prompt` or `prompt_embeds` must be provided\")\n\n        # Ensure negative prompt is properly formatted if using classifier-free guidance\n        if (\n            batch.do_classifier_free_guidance\n            and batch.negative_prompt is None\n            and batch.negative_prompt_embeds is None\n        ):\n            raise ValueError(\n                \"For classifier-free guidance, either `negative_prompt` or \"\n                \"`negative_prompt_embeds` must be provided\"\n            )\n\n        # Validate number of inference steps\n        if batch.num_inference_steps <= 0:\n            raise ValueError(\n                f\"Number of inference steps must be positive, but got {batch.num_inference_steps}\"\n            )\n","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/input_validation.py#L307-L343","documentation":"The input-validation stage requires a textual prompt or precomputed prompt_embeds for every request except the I2M (image-to-motion) task, which can be image-only. If batch.prompt and batch.prompt_embeds are both None on a non-I2M task, generation cannot proceed because the text conditioner has no input.","triggerScenarios":"Calling a T2V/T2I/I2V task with prompt=None and no prompt_embeds (e.g. relying on the image alone), or constructing a batch manually and forgetting to populate the prompt fields.","commonSituations":"Building image-to-video requests and assuming the image suffices (only valid for task_type == I2M); passing prompt as an empty string handled as None upstream; programmatic batch construction that skips prompt; disabling text conditioning flags while still using a text-conditioned task.","solutions":["Provide a non-None prompt (even a short caption) for non-I2M tasks","Or pass precomputed prompt_embeds if you encode prompts yourself","If the request really is image-only motion generation, set server_args.pipeline_config.task_type to ModelTaskType.I2M"],"exampleFix":"// before\nout = pipe(prompt=None, image=img, task=\"i2v\")\n\n// after\nout = pipe(prompt=\"a wave crashing\", image=img, task=\"i2v\")","handlingStrategy":"validation","validationCode":"if task_type != ModelTaskType.I2M:\n    assert batch.prompt is not None or batch.prompt_embeds is not None, \"non-I2M tasks need a prompt\"","typeGuard":"def request_has_text_input(batch, is_i2m: bool) -> bool:\n    return is_i2m or batch.prompt is not None or batch.prompt_embeds is not None","tryCatchPattern":null,"preventionTips":["Default prompts to \"\" rather than None for non-I2M tasks","Validate task_type matches the request payload"],"tags":["prompt-validation","task-type","input-validation"],"backgroundTag":"required-argument-missing","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}