BerriAI/litellm · error · ValueError
WatsonX embeddings require a string or list of strings
Error message
WatsonX embeddings require a string or list of strings
What it means
Type guard in the watsonx embedding transform: input is neither a str nor a list of str (it is a list of token-id lists or ints, an OpenAI-style encoding watsonx does not accept), so it cannot be mapped to the watsonx 'inputs' field.
Source
Thrown at litellm/llms/watsonx/embed/transformation.py:50
def transform_embedding_request(
self,
model: str,
input: AllEmbeddingInputValues,
optional_params: dict,
headers: dict,
) -> dict:
watsonx_api_params: Final = _get_api_params(params=optional_params, model=model)
watsonx_auth_payload: Final = self._prepare_payload(
model=model,
api_params=watsonx_api_params,
)
if isinstance(input, str):
inputs: list[str] = [input]
elif isinstance(input, list):
if len(input) > 0 and isinstance(input[0], (list, int)):
raise ValueError("WatsonX embeddings require a string or list of strings")
inputs = input
else:
inputs = [input]
return {
"inputs": inputs,
"parameters": optional_params,
**watsonx_auth_payload,
}
def get_complete_url(
self,
api_base: str | None,
api_key: str | None,
model: str,
optional_params: dict,
litellm_params: dict,
stream: bool | None = None,View on GitHub (pinned to 77b7c6c40c)
Solutions
- Pass the embedding input as a string or a list of strings.
- Convert other input types (dicts, numbers) to strings before calling the Watsonx embedding API.
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at litellm/llms/watsonx/embed/transformation.py:50 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/95e80e2cd0a1f3c2.
Report an issue: GitHub.