sgl-project/sglang · error · ValueError
Unsupported Kimi-K3 encoder media item: {image}
Error message
Unsupported Kimi-K3 encoder media item: {image} What it means
prepare_kimi_k3_encoder_inputs accepts per-image items either as raw images or as dicts of the form {'type': 'image', 'image': <payload>, ...}. Any dict that does not have type == 'image' and an 'image' key is rejected with this ValueError, protecting the encoder from unsupported media kinds (e.g. video/audio dicts or malformed entries).
Source
Thrown at python/sglang/srt/multimodal/kimi_k3_image_processing.py:83
"in_patch_limit",
"patch_limit_on_one_side",
"image_mean",
"image_std",
)
missing = [name for name in required if name not in media_proc_cfg]
if missing:
raise ValueError(
"Kimi-K3 image processor is missing deferred-preprocessing config: "
+ ", ".join(missing)
)
concrete_images = []
content_digests = []
for image in images:
content_digest = None
if isinstance(image, dict):
if image.get("type") != "image" or "image" not in image:
raise ValueError(f"Unsupported Kimi-K3 encoder media item: {image}")
content_digest = image.get("content_hash")
image = image["image"]
concrete_images.append(image)
content_digests.append(content_digest)
patch_size = int(media_proc_cfg["patch_size"])
merge_kernel_size = int(media_proc_cfg["merge_kernel_size"])
deferred_preprocessing = functools.partial(
KimiK3DeferredPreprocessing,
backend="gpu" if use_gpu_preprocessing else "cpu",
image_mean=list(media_proc_cfg["image_mean"]),
image_std=list(media_proc_cfg["image_std"]),
transparent_bg_config=media_proc_cfg.get("transparent_bg_config"),
)
items = []
grids = []
original_image_sizes = []View on GitHub (pinned to 0132848349)
Solutions
- Filter the content list to items with item.get('type') == 'image' before passing
- Ensure each dict has an 'image' key holding the image payload; unwrap raw images if dicts are unnecessary
- Normalize other modalities through their own encoder-input preparers instead of this image API
Example fix
// before
images = content # contains {'type':'text',...}
prepare_kimi_k3_encoder_inputs(images, cfg)
// after
images = [c for c in content if c.get('type') == 'image']
prepare_kimi_k3_encoder_inputs(images, cfg) Defensive patterns
Strategy: type-guard
Type guard
def is_kimi_k3_image_item(x):
return not isinstance(x, dict) or (x.get("type") == "image" and "image" in x) Try / catch
try:
prepare_kimi_k3_encoder_inputs(images, cfg)
except ValueError as e:
if "Unsupported Kimi-K3 encoder media item" in str(e):
images = [i for i in images if is_kimi_k3_image_item(i)]
prepare_kimi_k3_encoder_inputs(images, cfg)
else:
raise Prevention
- Filter chat content by type=='image' before calling the encoder prep
- Keep dict schema exactly {'type':'image','image':payload[,'content_hash':...]}
When it happens
Trigger: Passing an images list containing a dict like {'type': 'video', ...}, {'type': 'image'} without an 'image' key, or a dict with a differently-named payload key (e.g. 'url' instead of 'image').
Common situations: Forwarding an unfiltered chat content list (which contains text/video entries) directly as images; renaming keys when building the request payload; partial refactors of the mm item schema.
Related errors
- mm_content_hashes has {len(content_hashes)} entries for {med
- Unsupported image type: {type(image)}
- When using multiple prompts with multiple input images, prov
- {key}.position_ids is required
- {key}.{field} is required
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/5931e8a3208189aa.
Report an issue: GitHub.