sgl-project/sglang · error · RuntimeError
Failed to get model info: {str(e)}
Error message
Failed to get model info: {str(e)} What it means
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.
Source
Thrown at python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/core/server_api.py:61
Get information about the model served by this server.
Returns:
Dictionary containing model information including:
- model_path: Path to the model
- task_type: Type of task (e.g., "T2V", "I2I")
- pipeline_name: Name of the pipeline
- num_gpus: Number of GPUs
- dit_precision: DiT model precision
- vae_precision: VAE model precision
"""
try:
# Remove /v1 from base_url for /models endpoint
models_url = self.base_url.removesuffix("/v1") + "/models"
response = requests.get(models_url, headers=self.headers, timeout=30)
response.raise_for_status()
return response.json()
except requests.exceptions.RequestException as e:
raise RuntimeError(f"Failed to get model info: {str(e)}")
def generate_image(
self,
prompt: str,
image_path: Optional[str] = None,
mask_path: Optional[str] = None,
size: Optional[str] = None,
width: Optional[int] = None,
height: Optional[int] = None,
n: int = 1,
negative_prompt: Optional[str] = None,
guidance_scale: Optional[float] = None,
num_inference_steps: Optional[int] = None,
seed: Optional[int] = None,
enable_teacache: bool = False,
response_format: str = "b64_json",
quality: Optional[str] = "auto",
style: Optional[str] = "vivid",View on GitHub (pinned to 0132848349)
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
Example fix
# before client = SGLDiffusionClient(base_url="http://localhost:8000") info = client.get_model_info() # wrong port # after client = SGLDiffusionClient(base_url="http://localhost:30000/v1") info = client.get_model_info()
Defensive patterns
Strategy: retry
Validate before calling
import requests
def server_ready(base_url, tries=30):
for _ in range(tries):
try:
requests.get(base_url.removesuffix("/v1") + "/models", timeout=5).raise_for_status()
return True
except requests.exceptions.RequestException:
time.sleep(1)
return False
assert server_ready(client.base_url) Try / catch
try:
info = client.get_model_info()
except RuntimeError as e:
if "Failed to get model info" in str(e):
# server not reachable: check URL / restart server, then retry once
raise
raise Prevention
- Health-check /models before first use
- Smoke-test base_url with curl after server launch
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- Failed to get server info. {error_data['error']['message']}
- Failed to edit image: {str(e)}
- Failed to generate image: {str(e)}
- Lost connection to server after {consecutive_errors} consecu
- Network error after {consecutive_errors} consecutive failure
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/bf9849762f18e152.
Report an issue: GitHub.