{"record":{"id":"bf9849762f18e152","repo":"sgl-project/sglang","slug":"failed-to-get-model-info-str-e","errorCode":null,"errorMessage":"Failed to get model info: {str(e)}","messagePattern":"Failed to get model info: (.+?)","errorType":"error_code","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/core/server_api.py","lineNumber":61,"sourceCode":"        Get information about the model served by this server.\n\n        Returns:\n            Dictionary containing model information including:\n            - model_path: Path to the model\n            - task_type: Type of task (e.g., \"T2V\", \"I2I\")\n            - pipeline_name: Name of the pipeline\n            - num_gpus: Number of GPUs\n            - dit_precision: DiT model precision\n            - vae_precision: VAE model precision\n        \"\"\"\n        try:\n            # Remove /v1 from base_url for /models endpoint\n            models_url = self.base_url.removesuffix(\"/v1\") + \"/models\"\n            response = requests.get(models_url, headers=self.headers, timeout=30)\n            response.raise_for_status()\n            return response.json()\n        except requests.exceptions.RequestException as e:\n            raise RuntimeError(f\"Failed to get model info: {str(e)}\")\n\n    def generate_image(\n        self,\n        prompt: str,\n        image_path: Optional[str] = None,\n        mask_path: Optional[str] = None,\n        size: Optional[str] = None,\n        width: Optional[int] = None,\n        height: Optional[int] = None,\n        n: int = 1,\n        negative_prompt: Optional[str] = None,\n        guidance_scale: Optional[float] = None,\n        num_inference_steps: Optional[int] = None,\n        seed: Optional[int] = None,\n        enable_teacache: bool = False,\n        response_format: str = \"b64_json\",\n        quality: Optional[str] = \"auto\",\n        style: Optional[str] = \"vivid\",","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/core/server_api.py#L43-L79","documentation":"get_model_info queries the serving backend's /models endpoint (base_url with /v1 stripped) and wraps any requests exception (connection error, timeout, non-2xx status) in a RuntimeError with the underlying message. It signals the SGLang image server is unreachable or erroring.","triggerScenarios":"Calling get_model_info() when the SGLang diffusion server is down, base_url points to the wrong host/port, TLS/proxy issues, or the server returns 4xx/5xx so raise_for_status fires.","commonSituations":"Wrong base_url (missing port, left /v1 off when it should be there), server not started yet, firewall/DNS issues, or the server crashed mid-request.","solutions":["Verify the server is up: curl the /models endpoint from the same machine","Correct SGLDiffusionClient base_url to match the launched server host:port","If it's a transient startup race, wait for server readiness and retry","Inspect the wrapped message for the specific HTTP status or connection error and fix accordingly"],"exampleFix":"# before\nclient = SGLDiffusionClient(base_url=\"http://localhost:8000\")\ninfo = client.get_model_info()  # wrong port\n\n# after\nclient = SGLDiffusionClient(base_url=\"http://localhost:30000/v1\")\ninfo = client.get_model_info()","handlingStrategy":"retry","validationCode":"import requests\ndef server_ready(base_url, tries=30):\n    for _ in range(tries):\n        try:\n            requests.get(base_url.removesuffix(\"/v1\") + \"/models\", timeout=5).raise_for_status()\n            return True\n        except requests.exceptions.RequestException:\n            time.sleep(1)\n    return False\nassert server_ready(client.base_url)","typeGuard":null,"tryCatchPattern":"try:\n    info = client.get_model_info()\nexcept RuntimeError as e:\n    if \"Failed to get model info\" in str(e):\n        # server not reachable: check URL / restart server, then retry once\n        raise\n    raise","preventionTips":["Health-check /models before first use","Smoke-test base_url with curl after server launch"],"tags":["network","http-client","model-info","sglang-server"],"backgroundTag":"http-request-failed","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}