sgl-project/sglang · error · HTTPException
{e}
Error message
{e} What it means
Returned as HTTP 400 by the video generation endpoint when building sampling parameters from the request fails with a ValueError or TypeError. The _build_video_sampling_params helper validates numeric ranges (e.g. frames, fps, sampling settings) and their types; invalid combinations are converted into a 400 with the raw message. Temp dirs created for the request are cleaned before raising.
Source
Thrown at python/sglang/multimodal_gen/runtime/entrypoints/openai/video_api.py:836
# Resolve per-request output_path override
effective_output_path = req.output_path or server_args.output_path
if effective_output_path is None:
output_tmp = tempfile.mkdtemp(prefix="sglang_output_")
temp_dirs.append(output_tmp)
effective_output_path = output_tmp
output_persistent = False
# Inject resolved output_path so _build_video_sampling_params picks it up
req.output_path = effective_output_path
logger.debug(f"Server received from create_video endpoint: req={req}")
try:
sampling_params = _build_video_sampling_params(request_id, req)
except (ValueError, TypeError) as e:
for td in temp_dirs:
shutil.rmtree(td, ignore_errors=True)
raise HTTPException(status_code=400, detail=str(e))
batch: Req | None = None
scheduler_batches: list[Req] | None = None
try:
# Build Req for scheduler.
trace_headers = extract_trace_headers(request.headers)
batch = prepare_request(
server_args=server_args,
sampling_params=sampling_params,
external_trace_header=trace_headers,
)
# Add diffusers_kwargs if provided.
if req.diffusers_kwargs:
batch.extra["diffusers_kwargs"] = req.diffusers_kwargs
if "max_sequence_length" in req.diffusers_kwargs:
batch.max_sequence_length = req.diffusers_kwargs["max_sequence_length"]
if "flow_shift" in req.diffusers_kwargs:
batch.flow_shift = req.diffusers_kwargs["flow_shift"]View on GitHub (pinned to 0132848349)
Solutions
- Read the detail string — it contains the exact ValueError/TypeError message naming the invalid param and its constraint
- Align sampling params with the deployed model's supported values (check model card / server startup logs for supported sizes and frame counts)
- Coerce types client-side: send numbers, not numeric strings
- Retry with conservative defaults (omit optional sampling fields entirely to use server defaults)
Example fix
// before
{"model": "m", "prompt": "p", "duration": -5, "fps": "thirty"}
// after
{"model": "m", "prompt": "p", "duration": 5, "fps": 30} Defensive patterns
Strategy: validation
Validate before calling
assert 0 < req.duration <= 60 assert isinstance(req.fps, int) and req.fps > 0 # omit optional sampling fields to use server defaults when unsure
Try / catch
try { await create(req); } catch (e) { if (e.status === 400 && /param/i.test(e.detail)) fixParamFromMessage(e.detail); } Prevention
- Know the model's supported resolution/fps/frame grid before setting sampling fields
- Send numbers not strings for numeric fields
- Start with defaults, add one param at a time
When it happens
Trigger: POST /v1/videos where sampling-related fields (duration, fps, frames, seed, size, guidance scale, etc.) are out of allowed ranges, negative, non-numeric strings, or mutually incompatible so that _build_video_sampling_params raises ValueError/TypeError.
Common situations: Requesting a frame count or resolution the loaded video model does not support; passing strings like "30" where numbers are expected; copying sampling params tuned for a different model; model-specific constraints (e.g. frames % spatial patch size != 0) failing.
Related errors
- Invalid request body: {e}
- TGV cute_ext tactic {tactic} out of range [0, {len(_TGV_CUTE
- Wrong type of stop in sampling parameters.
- Video generation failed: {error_msg}
- Lost connection to server after {consecutive_errors} consecu
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/4b862566dea20a07.
Report an issue: GitHub.