{"record":{"id":"95e80e2cd0a1f3c2","repo":"BerriAI/litellm","slug":"watsonx-embeddings-require-a-string-or-list-of-str","errorCode":null,"errorMessage":"WatsonX embeddings require a string or list of strings","messagePattern":"WatsonX embeddings require a string or list of strings","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/watsonx/embed/transformation.py","lineNumber":50,"sourceCode":"\n    def transform_embedding_request(\n        self,\n        model: str,\n        input: AllEmbeddingInputValues,\n        optional_params: dict,\n        headers: dict,\n    ) -> dict:\n        watsonx_api_params: Final = _get_api_params(params=optional_params, model=model)\n        watsonx_auth_payload: Final = self._prepare_payload(\n            model=model,\n            api_params=watsonx_api_params,\n        )\n\n        if isinstance(input, str):\n            inputs: list[str] = [input]\n        elif isinstance(input, list):\n            if len(input) > 0 and isinstance(input[0], (list, int)):\n                raise ValueError(\"WatsonX embeddings require a string or list of strings\")\n            inputs = input\n        else:\n            inputs = [input]\n\n        return {\n            \"inputs\": inputs,\n            \"parameters\": optional_params,\n            **watsonx_auth_payload,\n        }\n\n    def get_complete_url(\n        self,\n        api_base: str | None,\n        api_key: str | None,\n        model: str,\n        optional_params: dict,\n        litellm_params: dict,\n        stream: bool | None = None,","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/watsonx/embed/transformation.py#L32-L68","documentation":"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.","triggerScenarios":"Thrown at litellm/llms/watsonx/embed/transformation.py:50 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}