BerriAI/litellm · error · ValueError

Expected embedding at index {idx} to be a list, got {type(em

Error message

Expected embedding at index {idx} to be a list, got {type(embedding_values)}

What it means

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.

Source

Thrown at litellm/llms/vertex_ai/vertex_embeddings/bge.py:156

        Raises:
            KeyError: If response doesn't contain 'predictions'
            ValueError: If predictions is not a list or contains invalid data
        """
        if "predictions" not in response:
            raise KeyError("Response missing 'predictions' field")

        _predictions: Final = response["predictions"]

        if not isinstance(_predictions, list):
            raise ValueError(f"Expected 'predictions' to be a list, got {type(_predictions)}")

        embedding_response: Final = []
        # BGE models don't return token counts, so we estimate or set to 0
        input_tokens: Final = 0

        for idx, embedding_values in enumerate(_predictions):
            if not isinstance(embedding_values, list):
                raise ValueError(f"Expected embedding at index {idx} to be a list, got {type(embedding_values)}")

            embedding_response.append(
                {
                    "object": "embedding",
                    "index": idx,
                    "embedding": embedding_values,
                }
            )

        model_response.object = "list"
        model_response.data = embedding_response
        model_response.model = model
        usage: Final = Usage(prompt_tokens=input_tokens, completion_tokens=0, total_tokens=input_tokens)
        setattr(model_response, "usage", usage)
        return model_response

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Inspect the prediction at the reported index; it should be a list of floats.
  2. Verify the endpoint returns embeddings in the expected format and that the input instances are well-formed.
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at litellm/llms/vertex_ai/vertex_embeddings/bge.py:156 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/cd4e6ed7184a2a50. Report an issue: GitHub.