huggingface/transformers · error · HTTPException
Unsupported input item type: {item_type!r}
Error message
Unsupported input item type: {item_type!r} What it means
_normalize_response_items converts OpenAI Responses-style input items (role/message/function_call/tool_call dicts) into chat messages. It handles known item types and raises HTTP 422 'Unsupported input item type' for an item whose 'type' field is not recognized (e.g. custom types, future OpenAI item types, or misspelled ones).
Source
Thrown at src/transformers/cli/serving/response.py:556
"id": item["call_id"],
"function": {"name": item["name"], "arguments": item["arguments"]},
}
if messages and messages[-1]["role"] == "assistant":
messages[-1].setdefault("tool_calls", []).append(tc)
else:
messages.append({"role": "assistant", "tool_calls": [tc]})
elif item_type == "function_call_output":
messages.append(
{
"role": "tool",
"tool_call_id": item["call_id"],
"content": item["output"],
}
)
else:
raise HTTPException(status_code=422, detail=f"Unsupported input item type: {item_type!r}")
return messages
# ----- streaming -----
def _streaming(
self,
request_id: str,
model: "PreTrainedModel",
processor: "ProcessorMixin | PreTrainedTokenizerFast",
model_id: str,
body: dict,
inputs: dict,
gen_config: "GenerationConfig",
gen_manager: BaseGenerateManager,
) -> StreamingResponse:
"""Generate a streaming Responses API reply (SSE) using DirectStreamer."""
response_parser = build_response_parser(processor, model, inputs["input_ids"])View on GitHub (pinned to a597f97485)
Solutions
- Strip unsupported items (e.g. reasoning traces, tool outputs for unimplemented tools) before sending
- Use only supported item types: message items with role/content, function_call, and function_call_output
- Ensure every list item has an explicit recognized 'type' field
- Upgrade transformers serve — newer versions handle more item types
Example fix
# before
{"input": [{"type": "reasoning", "summary": []}, {"role": "user", "content": "hi"}]}
# after
{"input": [{"role": "user", "content": "hi"}]} Defensive patterns
Strategy: validation
Validate before calling
SUPPORTED = {"message", "function_call", "function_call_output"} # adjust to server version
for item in items:
if isinstance(item, dict) and item.get("type") is not None and item["type"] not in SUPPORTED:
items = [i for i in items if i.get("type") in SUPPORTED]
break Type guard
def all_items_supported(items: list[dict], supported: set[str]) -> bool:
return all(i.get("type") in supported for i in items if "role" not in i) Try / catch
resp = await client.post(url, json=body)
if resp.status_code == 422 and "Unsupported input item type" in resp.text:
body["input"] = [i for i in body["input"] if i.get("type") in SUPPORTED_TYPES or "role" in i]
resp = await client.post(url, json=body) Prevention
- Sanitize replayed OpenAI Responses payloads: drop reasoning/tool items the server lacks
- Keep item 'type' fields exactly spelled and present
- Version-lock serve and clients so supported item types stay in sync
When it happens
Trigger: Sending items with type values like 'reasoning' variants, 'image_gen_call', or any type not in the handled set; misspelling 'function_call' as 'functioncall'; a dict without a 'type' key that reaches this branch; passing message items nested with unsupported subtypes.
Common situations: Replaying OpenAI Responses API request bodies verbatim, including item types the local server does not implement; forward-porting newer API payloads to an older serve version; hand-crafted items missing the type key.
Related errors
- 'input' must be a string or list
- Missing `model` field in the request body.
- Unexpected fields in the request: {unexpected}
- Expected file upload, got string
- Expected model name as string
AI-assisted analysis of huggingface/transformers@a597f97485 (2026-08-14).
Data as JSON: /api/errors/86dcced1d5293190.
Report an issue: GitHub.