{"record":{"id":"86dcced1d5293190","repo":"huggingface/transformers","slug":"unsupported-input-item-type-item-type-r","errorCode":null,"errorMessage":"Unsupported input item type: {item_type!r}","messagePattern":"Unsupported input item type: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":422,"severity":"error","filePath":"src/transformers/cli/serving/response.py","lineNumber":556,"sourceCode":"                    \"id\": item[\"call_id\"],\n                    \"function\": {\"name\": item[\"name\"], \"arguments\": item[\"arguments\"]},\n                }\n                if messages and messages[-1][\"role\"] == \"assistant\":\n                    messages[-1].setdefault(\"tool_calls\", []).append(tc)\n                else:\n                    messages.append({\"role\": \"assistant\", \"tool_calls\": [tc]})\n\n            elif item_type == \"function_call_output\":\n                messages.append(\n                    {\n                        \"role\": \"tool\",\n                        \"tool_call_id\": item[\"call_id\"],\n                        \"content\": item[\"output\"],\n                    }\n                )\n\n            else:\n                raise HTTPException(status_code=422, detail=f\"Unsupported input item type: {item_type!r}\")\n\n        return messages\n\n    # ----- streaming -----\n\n    def _streaming(\n        self,\n        request_id: str,\n        model: \"PreTrainedModel\",\n        processor: \"ProcessorMixin | PreTrainedTokenizerFast\",\n        model_id: str,\n        body: dict,\n        inputs: dict,\n        gen_config: \"GenerationConfig\",\n        gen_manager: BaseGenerateManager,\n    ) -> StreamingResponse:\n        \"\"\"Generate a streaming Responses API reply (SSE) using DirectStreamer.\"\"\"\n        response_parser = build_response_parser(processor, model, inputs[\"input_ids\"])","sourceCodeStart":538,"sourceCodeEnd":574,"githubUrl":"https://github.com/huggingface/transformers/blob/a597f974857b3d92939971296bc0deb93d33d780/src/transformers/cli/serving/response.py#L538-L574","documentation":"_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).","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\n{\"input\": [{\"type\": \"reasoning\", \"summary\": []}, {\"role\": \"user\", \"content\": \"hi\"}]}\n\n# after\n{\"input\": [{\"role\": \"user\", \"content\": \"hi\"}]}","handlingStrategy":"validation","validationCode":"SUPPORTED = {\"message\", \"function_call\", \"function_call_output\"}  # adjust to server version\nfor item in items:\n    if isinstance(item, dict) and item.get(\"type\") is not None and item[\"type\"] not in SUPPORTED:\n        items = [i for i in items if i.get(\"type\") in SUPPORTED]\n        break","typeGuard":"def all_items_supported(items: list[dict], supported: set[str]) -> bool:\n    return all(i.get(\"type\") in supported for i in items if \"role\" not in i)","tryCatchPattern":"resp = await client.post(url, json=body)\nif resp.status_code == 422 and \"Unsupported input item type\" in resp.text:\n    body[\"input\"] = [i for i in body[\"input\"] if i.get(\"type\") in SUPPORTED_TYPES or \"role\" in i]\n    resp = await client.post(url, json=body)","preventionTips":["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"],"tags":["serving","api","responses","validation","http-422"],"backgroundTag":null,"analyzedSha":"a597f974857b3d92939971296bc0deb93d33d780","analyzedAt":"2026-08-14T18:24:08.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}