{"record":{"id":"8f80e496c2fa45e9","repo":"sgl-project/sglang","slug":"usage-sglang-serve-model-path-model-name-or-pa","errorCode":null,"errorMessage":"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","messagePattern":"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","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"info","filePath":"python/sglang/cli/utils.py","lineNumber":122,"sourceCode":"        if arg in (\"--model-path\", \"--model\"):\n            if i + 1 < len(extra_argv):\n                model_path = extra_argv[i + 1]\n                break\n        elif arg.startswith(\"--model-path=\") or arg.startswith(\"--model=\"):\n            model_path = arg.split(\"=\", 1)[1]\n            break\n\n    return model_path\n\n\ndef get_model_path(extra_argv):\n    # Find the model_path argument\n    model_path = try_get_model_path(extra_argv)\n\n    if model_path is None:\n        # Fallback for --help or other cases where model-path is not provided\n        if any(h in extra_argv for h in [\"-h\", \"--help\"]):\n            raise Exception(\n                \"Usage: sglang serve --model-path <model-name-or-path> [additional-arguments]\\n\\n\"\n                \"This command can launch either a standard language model server or a diffusion model server.\\n\"\n                \"The server type is determined by the --model-path.\\n\"\n            )\n        else:\n            raise Exception(\n                \"Error: --model-path is required. \"\n                \"Please provide the path to the model.\"\n            )\n    return model_path\n\n\n@lru_cache(maxsize=1)\ndef get_git_commit_hash() -> str:\n    try:\n        commit_hash = os.environ.get(\"SGLANG_GIT_COMMIT\")\n        if not commit_hash:\n            commit_hash = (","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/cli/utils.py#L104-L140","documentation":"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.","triggerScenarios":"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.","commonSituations":"Users exploring the CLI with --help; wrapper scripts that always append -h.","solutions":["Treat it as help text: run `sglang serve --model-path <model> ...` with a real model.","If wrapping the CLI, don't pass -h/--help alongside real invocations."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if any(h in argv for h in (\"-h\", \"--help\")):\n    print(serve_help_text); return 0  # don't call get_model_path","typeGuard":null,"tryCatchPattern":"try:\n    path = get_model_path(argv)\nexcept Exception as e:\n    if str(e).startswith(\"Usage:\"):\n        print(e); return 0","preventionTips":["Short-circuit help flags before any path extraction in CLI wrappers.","Don't pass -h/--help in scripted invocations."],"tags":["sglang","cli","usage","help","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}