sgl-project/sglang · error · ValueError
No base64 image data found
Error message
No base64 image data found
What it means
ValueError from decode_image_from_response: the selected image entry exists but its 'b64_json' field is missing or empty, so the client cannot decode pixel data. Some servers return a URL instead of inline base64.
Source
Thrown at python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/core/server_api.py:440
"""
Decode base64 image from API response.
Args:
response_data: API response dictionary
index: Index of the image in the response (default: 0)
Returns:
PIL Image object
"""
if "data" not in response_data or not response_data["data"]:
raise ValueError("No image data in response")
if index >= len(response_data["data"]):
raise IndexError(f"Image index {index} out of range")
image_data = response_data["data"][index]
if "b64_json" not in image_data or not image_data["b64_json"]:
raise ValueError("No base64 image data found")
image_bytes = base64.b64decode(image_data["b64_json"])
image = Image.open(io.BytesIO(image_bytes))
# Convert to RGB if needed
if image.mode != "RGB":
image = image.convert("RGB")
return image
def set_lora(
self,
lora_nickname: str,
lora_path: Optional[str] = None,
target: str = "all",
) -> Dict[str, Any]:
"""
Set a LoRA adapter for the specified transformer(s).View on GitHub (pinned to 0132848349)
Solutions
- Log the image entry keys to see the actual schema (url vs b64_json).
- If URLs are returned, download the image from the URL instead of decoding base64.
- Ensure the request asked for response_format b64 (if supported).
- Upgrade client and server to matching versions.
Example fix
// before
image_data = response["data"][0] # then decode_image_from_response fails
// after
entry = response["data"][0]
if not entry.get("b64_json") and entry.get("url"):
import requests as rq, io
from PIL import Image
image = Image.open(io.BytesIO(rq.get(entry["url"]).content)) Defensive patterns
Strategy: type-guard
Validate before calling
entry = response['data'][index]
assert entry.get('b64_json'), f'keys={list(entry)}' Type guard
def has_b64(entry: dict) -> bool:
return bool(entry.get('b64_json')) Try / catch
if not entry.get('b64_json'):
if entry.get('url'):
img = fetch(entry['url'])
else:
raise ValueError(f'no image payload: {entry}') Prevention
- Request b64_json response format when supported.
- Handle both url and b64_json schemas defensively.
- Log entry keys when the schema surprises you.
When it happens
Trigger: Server returns images as 'url' references instead of 'b64_json', or returns an entry with an empty b64 string (failed per-image generation).
Common situations: Server configured for URL-response mode; partial failure where one of n images failed; API version mismatch changing the response schema.
Related errors
- No image data in response
- Image index {index} out of range
- lora_nickname cannot be empty
- material URI has data after base64 padding
- Failed to decode base64 image. Expected format: `data:[<medi
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/4f5804592065b50e.
Report an issue: GitHub.