BerriAI/litellm · error · ValueError
Unsupported input type: {type(current)}
Error message
Unsupported input type: {type(current)} What it means
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.
Source
Thrown at litellm/llms/vertex_ai/multimodal_embeddings/transformation.py:162
while i < len(_input_list):
current = _input_list[i]
next_elem = _input_list[i + 1] if i + 1 < len(_input_list) else None
if isinstance(current, str):
if self._is_media_input(current):
# Current element is media - process it standalone
processed_instances.append(self._process_input_element(current))
i += 1
else:
# Current element is text - try to merge with next media element
instance, consumed_next = self._try_merge_text_with_media(text_str=current, next_elem=next_elem)
processed_instances.append(instance)
i += 2 if consumed_next else 1
elif isinstance(current, dict):
processed_instances.append(Instance(**current))
i += 1
else:
raise ValueError(f"Unsupported input type: {type(current)}")
return processed_instances
def transform_embedding_request(
self,
model: str,
input: AllEmbeddingInputValues,
optional_params: dict,
headers: dict,
) -> dict:
optional_params = optional_params or {}
request_data: Final = VertexMultimodalEmbeddingRequest(instances=[])
if "instances" in optional_params:
request_data["instances"] = optional_params["instances"]
elif isinstance(input, list):
vertex_instances: Final[list[Instance]] = self.process_openai_embedding_input(_input=input)View on GitHub (pinned to 77b7c6c40c)
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
Example fix
# before
import tiktoken
ids = tiktoken.get_encoding('cl100k_base').encode('a cat')
resp = litellm.embedding(model='vertex_ai/multimodalembedding@001', input=ids) # ints -> raises
# after
resp = litellm.embedding(
model='vertex_ai/multimodalembedding@001',
input=['a cat', 'gs://bucket/cat.png'], # raw text + media URIs
) Defensive patterns
Strategy: type-guard
Validate before calling
def valid_multimodal_input(inputs) -> bool:
if isinstance(inputs, str):
return True
return all(isinstance(x, (str, dict)) for x in inputs)
assert valid_multimodal_input(inputs), 'multimodal embedding input elements must be str or dict (never token-id ints)' Type guard
from typing import Any
def is_multimodal_embedding_input(inputs: Any) -> bool:
"""Narrow to what vertex multimodal embedding accepts: str, or list[str | dict]."""
if isinstance(inputs, str):
return True
return isinstance(inputs, list) and all(isinstance(x, (str, dict)) for x in inputs) Try / catch
try:
resp = litellm.embedding(model='vertex_ai/multimodalembedding@001', input=inputs)
except ValueError as e:
if 'Unsupported input type' in str(e):
inputs = [str(x) if not isinstance(x, (str, dict)) else x for x in inputs]
resp = litellm.embedding(model='vertex_ai/multimodalembedding@001', input=inputs)
else:
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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)).
Related errors
- Unsupported image type for Vertex AI Gemini image edit.
- Unsupported image type for Vertex AI Imagen image edit.
- Unsupported image input: plain string values are not accepte
- Unsupported image input: filesystem paths are not accepted f
- Unsupported image type for Vertex AI Imagen image edit. Got
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/8ba0cb187b39544c.
Report an issue: GitHub.