{"record":{"id":"cd4e6ed7184a2a50","repo":"BerriAI/litellm","slug":"expected-embedding-at-index-idx-to-be-a-list-go","errorCode":null,"errorMessage":"Expected embedding at index {idx} to be a list, got {type(embedding_values)}","messagePattern":"Expected embedding at index (.+?) to be a list, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/vertex_ai/vertex_embeddings/bge.py","lineNumber":156,"sourceCode":"        Raises:\n            KeyError: If response doesn't contain 'predictions'\n            ValueError: If predictions is not a list or contains invalid data\n        \"\"\"\n        if \"predictions\" not in response:\n            raise KeyError(\"Response missing 'predictions' field\")\n\n        _predictions: Final = response[\"predictions\"]\n\n        if not isinstance(_predictions, list):\n            raise ValueError(f\"Expected 'predictions' to be a list, got {type(_predictions)}\")\n\n        embedding_response: Final = []\n        # BGE models don't return token counts, so we estimate or set to 0\n        input_tokens: Final = 0\n\n        for idx, embedding_values in enumerate(_predictions):\n            if not isinstance(embedding_values, list):\n                raise ValueError(f\"Expected embedding at index {idx} to be a list, got {type(embedding_values)}\")\n\n            embedding_response.append(\n                {\n                    \"object\": \"embedding\",\n                    \"index\": idx,\n                    \"embedding\": embedding_values,\n                }\n            )\n\n        model_response.object = \"list\"\n        model_response.data = embedding_response\n        model_response.model = model\n        usage: Final = Usage(prompt_tokens=input_tokens, completion_tokens=0, total_tokens=input_tokens)\n        setattr(model_response, \"usage\", usage)\n        return model_response\n","sourceCodeStart":138,"sourceCodeEnd":172,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/vertex_ai/vertex_embeddings/bge.py#L138-L172","documentation":"Type guard inside the BGE predictions loop: the embedding value at the given index is not a list of floats as expected, so it cannot be used as an embedding vector for that input. Indicates a malformed per-item prediction payload.","triggerScenarios":"Thrown at litellm/llms/vertex_ai/vertex_embeddings/bge.py:156 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the prediction at the reported index; it should be a list of floats.","Verify the endpoint returns embeddings in the expected format and that the input instances are well-formed."],"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"}