sgl-project/sglang · info · Exception

Usage: sglang serve --model-path <model-name-or-path> [addit

Error message

Usage: sglang serve --model-path <model-name-or-path> [additional-arguments]\n\nThis command can launch either a standard language model server or a diffusion model server.\nThe server type is determined by the --model-path.\n

What it means

Raised by get_model_path() in the CLI utils when no --model-path argument is found AND a help flag (-h/--help) is present. It doubles as the usage banner for `sglang serve --help`, explaining that the command launches either a language-model or diffusion-model server, selected by --model-path.

Source

Thrown at python/sglang/cli/utils.py:122

        if arg in ("--model-path", "--model"):
            if i + 1 < len(extra_argv):
                model_path = extra_argv[i + 1]
                break
        elif arg.startswith("--model-path=") or arg.startswith("--model="):
            model_path = arg.split("=", 1)[1]
            break

    return model_path


def get_model_path(extra_argv):
    # Find the model_path argument
    model_path = try_get_model_path(extra_argv)

    if model_path is None:
        # Fallback for --help or other cases where model-path is not provided
        if any(h in extra_argv for h in ["-h", "--help"]):
            raise Exception(
                "Usage: sglang serve --model-path <model-name-or-path> [additional-arguments]\n\n"
                "This command can launch either a standard language model server or a diffusion model server.\n"
                "The server type is determined by the --model-path.\n"
            )
        else:
            raise Exception(
                "Error: --model-path is required. "
                "Please provide the path to the model."
            )
    return model_path


@lru_cache(maxsize=1)
def get_git_commit_hash() -> str:
    try:
        commit_hash = os.environ.get("SGLANG_GIT_COMMIT")
        if not commit_hash:
            commit_hash = (

View on GitHub (pinned to 0132848349)

Solutions

  1. Treat it as help text: run `sglang serve --model-path <model> ...` with a real model.
  2. If wrapping the CLI, don't pass -h/--help alongside real invocations.
Defensive patterns

Strategy: validation

Validate before calling

if any(h in argv for h in ("-h", "--help")):
    print(serve_help_text); return 0  # don't call get_model_path

Try / catch

try:
    path = get_model_path(argv)
except Exception as e:
    if str(e).startswith("Usage:"):
        print(e); return 0

Prevention

When it happens

Trigger: Running `sglang serve -h` or `sglang serve --help` (help path with no model path); any invocation where try_get_model_path returns None and a help flag is in extra_argv.

Common situations: Users exploring the CLI with --help; wrapper scripts that always append -h.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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