sgl-project/sglang · error · ValueError
Either `prompt` or `prompt_embeds` must be provided
Error message
Either `prompt` or `prompt_embeds` must be provided
What it means
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.
Source
Thrown at python/sglang/multimodal_gen/runtime/pipelines_core/stages/input_validation.py:325
self._generate_seeds(batch, server_args)
if (
server_args.pipeline_config.task_type == ModelTaskType.I2M
and batch.num_inference_steps is None
and hasattr(server_args.pipeline_config, "shape_num_inference_steps")
):
batch.num_inference_steps = (
server_args.pipeline_config.shape_num_inference_steps
)
# Ensure prompt is properly formatted (I2M can be image-only)
if (
server_args.pipeline_config.task_type != ModelTaskType.I2M
and batch.prompt is None
and batch.prompt_embeds is None
):
raise ValueError("Either `prompt` or `prompt_embeds` must be provided")
# Ensure negative prompt is properly formatted if using classifier-free guidance
if (
batch.do_classifier_free_guidance
and batch.negative_prompt is None
and batch.negative_prompt_embeds is None
):
raise ValueError(
"For classifier-free guidance, either `negative_prompt` or "
"`negative_prompt_embeds` must be provided"
)
# Validate number of inference steps
if batch.num_inference_steps <= 0:
raise ValueError(
f"Number of inference steps must be positive, but got {batch.num_inference_steps}"
)
View on GitHub (pinned to 0132848349)
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
Example fix
// before out = pipe(prompt=None, image=img, task="i2v") // after out = pipe(prompt="a wave crashing", image=img, task="i2v")
Defensive patterns
Strategy: validation
Validate before calling
if task_type != ModelTaskType.I2M:
assert batch.prompt is not None or batch.prompt_embeds is not None, "non-I2M tasks need a prompt" Type guard
def request_has_text_input(batch, is_i2m: bool) -> bool:
return is_i2m or batch.prompt is not None or batch.prompt_embeds is not None Prevention
- Default prompts to "" rather than None for non-I2M tasks
- Validate task_type matches the request payload
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- unsupported input for causal Conv3D cat/pad CUDA
- unsupported input for usp_merge_heads CUDA
- unsupported input for modulate_scale_shift CUDA
- unsupported input for LTX2 QKNorm split-RoPE CUDA
- fl2va requires first_frame, last_frame, or both
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/a3711a206b067fac.
Report an issue: GitHub.