sgl-project/sglang · error · ValueError

unsupported content part type: {ptype!r}

Error message

unsupported content part type: {ptype!r}

What it means

Content part types are limited to text/input_text, thinking/reasoning, image types (_IMAGE_PART_TYPES), and audio types (_AUDIO_PART_TYPES). Any other 'type' value in a part raises ValueError with the offending type.

Source

Thrown at python/sglang/srt/parser/inkling_renderer.py:247

        if not isinstance(part, Mapping):
            raise TypeError(f"content part must be mapping, got {type(part).__name__}")
        ptype = part.get("type")
        if ptype in (None, "text", "input_text"):
            text = part.get("text", "")
            yield ("text", text if isinstance(text, str) else "")
        elif ptype in ("thinking", "reasoning"):
            text = part.get("thinking")
            if text is None:
                text = part.get("text", "")
            if not isinstance(text, str):
                raise TypeError("Inkling thinking part payload must be a string")
            yield ("thinking", text)
        elif ptype in _IMAGE_PART_TYPES:
            yield ("image", "")
        elif ptype in _AUDIO_PART_TYPES:
            yield ("audio", "")
        else:
            raise ValueError(f"unsupported content part type: {ptype!r}")


def _format_reasoning_effort(reasoning_effort: float) -> str:
    if isinstance(reasoning_effort, bool) or not isinstance(
        reasoning_effort, (int, float)
    ):
        raise TypeError("Inkling reasoning_effort must be a number")
    value = float(reasoning_effort)
    if not math.isfinite(value) or not 0.0 <= value <= 0.99:
        raise ValueError("Inkling reasoning_effort must be finite and in [0.0, 0.99]")
    return f"{round(value, 2):g}"


def _expect_role(message: Mapping[str, Any]) -> str:
    role = message.get("role")
    if role not in ROLE_MESSAGE_TOKENS:
        raise ValueError(
            f"unsupported Inkling message role {role!r}; expected one of {sorted(ROLE_MESSAGE_TOKENS)}"

View on GitHub (pinned to 0132848349)

Solutions

  1. Remove or convert unsupported part types to text
  2. Check _IMAGE_PART_TYPES/_AUDIO_PART_TYPES in inkling_renderer.py for the accepted values
  3. Request/implement support for the part type and add a branch plus tokens

Example fix

# before
{"type":"video_url","video_url":{"url":"..."}}
# after
{"type":"text","text":"[video attached]"}
Defensive patterns

Strategy: validation

Validate before calling

allowed = {None, "text", "input_text", "thinking", "reasoning"} | set(_IMAGE_PART_TYPES) | set(_AUDIO_PART_TYPES)
for m in messages:
    c = m.get("content", "")
    if isinstance(c, list):
        bad = [p for p in c if isinstance(p, dict) and p.get("type") not in allowed]
        assert not bad, bad

Try / catch

try: render_inkling_messages(...)
except ValueError as e: if "unsupported content part type" in str(e): coerce the offending part to text and retry

Prevention

When it happens

Trigger: Sending {"type":"video_url",...}, {"type":"file",...}, or {"type":"input_audio"} if not in the allowed audio set, in an Inkling-rendered conversation.

Common situations: Using OpenAI-style part types the Inkling renderer has not implemented, like video_url or file citation parts.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/38e504e75ca9bcd9. Report an issue: GitHub.