{"record":{"id":"8ba0cb187b39544c","repo":"BerriAI/litellm","slug":"unsupported-input-type-type-current","errorCode":null,"errorMessage":"Unsupported input type: {type(current)}","messagePattern":"Unsupported input type: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/vertex_ai/multimodal_embeddings/transformation.py","lineNumber":162,"sourceCode":"        while i < len(_input_list):\n            current = _input_list[i]\n            next_elem = _input_list[i + 1] if i + 1 < len(_input_list) else None\n\n            if isinstance(current, str):\n                if self._is_media_input(current):\n                    # Current element is media - process it standalone\n                    processed_instances.append(self._process_input_element(current))\n                    i += 1\n                else:\n                    # Current element is text - try to merge with next media element\n                    instance, consumed_next = self._try_merge_text_with_media(text_str=current, next_elem=next_elem)\n                    processed_instances.append(instance)\n                    i += 2 if consumed_next else 1\n            elif isinstance(current, dict):\n                processed_instances.append(Instance(**current))\n                i += 1\n            else:\n                raise ValueError(f\"Unsupported input type: {type(current)}\")\n\n        return processed_instances\n\n    def transform_embedding_request(\n        self,\n        model: str,\n        input: AllEmbeddingInputValues,\n        optional_params: dict,\n        headers: dict,\n    ) -> dict:\n        optional_params = optional_params or {}\n\n        request_data: Final = VertexMultimodalEmbeddingRequest(instances=[])\n\n        if \"instances\" in optional_params:\n            request_data[\"instances\"] = optional_params[\"instances\"]\n        elif isinstance(input, list):\n            vertex_instances: Final[list[Instance]] = self.process_openai_embedding_input(_input=input)","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/vertex_ai/multimodal_embeddings/transformation.py#L144-L180","documentation":"The Vertex multimodal embedding request builder (process_openai_embedding_input) accepts only two kinds of list elements: str (treated as text, a gs:// media URI, or base64 image data) and dict (spread into a raw Instance). Any other element type raises this ValueError with the offending type. Notably, lists of integers — the token-ID format used by OpenAI embeddings clients — are rejected, because multimodal instances are not built from tokens.","triggerScenarios":"litellm.embedding(model='vertex_ai/multimodalembedding@001', input=[1, 2, 3]) with pre-tokenized ints (e.g. output of tiktoken); input=[None]; input=[b'raw bytes']; input containing numpy.str_ or other str subclasses that fail isinstance on plain str in some pipelines.","commonSituations":"Reusing OpenAI embeddings code that encodes text to token IDs first; mixed payloads where a None slips in from optional fields; passing bytes text from file reads; feeding chat-message dicts with non-Instance keys (TypeError-adjacent path via Instance(**current)).","solutions":["Pass plain text strings directly — multimodal embedding does not want token IDs: input=['a cat', 'gs://bucket/cat.png']","Map token lists back to text, or skip tokenization entirely for this model","Sanitize the list: [x if isinstance(x, (str, dict)) else str(x) for x in inputs]","Drop None elements before calling"],"exampleFix":"# before\nimport tiktoken\nids = tiktoken.get_encoding('cl100k_base').encode('a cat')\nresp = litellm.embedding(model='vertex_ai/multimodalembedding@001', input=ids)  # ints -> raises\n\n# after\nresp = litellm.embedding(\n    model='vertex_ai/multimodalembedding@001',\n    input=['a cat', 'gs://bucket/cat.png'],  # raw text + media URIs\n)","handlingStrategy":"type-guard","validationCode":"def valid_multimodal_input(inputs) -> bool:\n    if isinstance(inputs, str):\n        return True\n    return all(isinstance(x, (str, dict)) for x in inputs)\n\nassert valid_multimodal_input(inputs), 'multimodal embedding input elements must be str or dict (never token-id ints)'","typeGuard":"from typing import Any\n\ndef is_multimodal_embedding_input(inputs: Any) -> bool:\n    \"\"\"Narrow to what vertex multimodal embedding accepts: str, or list[str | dict].\"\"\"\n    if isinstance(inputs, str):\n        return True\n    return isinstance(inputs, list) and all(isinstance(x, (str, dict)) for x in inputs)","tryCatchPattern":"try:\n    resp = litellm.embedding(model='vertex_ai/multimodalembedding@001', input=inputs)\nexcept ValueError as e:\n    if 'Unsupported input type' in str(e):\n        inputs = [str(x) if not isinstance(x, (str, dict)) else x for x in inputs]\n        resp = litellm.embedding(model='vertex_ai/multimodalembedding@001', input=inputs)\n    else:\n        raise","preventionTips":["Do not pre-tokenize text for multimodal embedding — pass raw strings","Enforce list[str | dict] types in request schemas for embedding endpoints","Strip None and non-str elements in a normalization step before calling litellm"],"tags":["vertex-ai","multimodal-embeddings","input-validation","unsupported-type","tokenization"],"backgroundTag":"unsupported-input-type","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}