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

  1. Read the detail string — it contains the exact ValueError/TypeError message naming the invalid param and its constraint
  2. Align sampling params with the deployed model's supported values (check model card / server startup logs for supported sizes and frame counts)
  3. Coerce types client-side: send numbers, not numeric strings
  4. 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

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


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/4b862566dea20a07. Report an issue: GitHub.