BerriAI/litellm · error · KeyError

Response missing 'predictions' field

Error message

Response missing 'predictions' field

What it means

KeyError guard in the BGE embedding transform: the Vertex response dict has no 'predictions' key, so there are no embedding vectors to map into the OpenAI-format EmbeddingResponse — typically an error body was returned instead.

Source

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

            [0.002, 0.021, ...],
            [0.003, 0.022, ...]
          ]
        }

        Args:
            response: The raw response from Vertex AI
            model: The model name
            model_response: The EmbeddingResponse object to populate

        Returns:
            EmbeddingResponse: The transformed response in OpenAI format

        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,

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Inspect the raw response for an upstream error; a missing 'predictions' field usually signals a failed prediction call.
  2. Verify the BGE endpoint deployment, request payload format, and credentials, then retry.
Defensive patterns

Strategy: validation

When it happens

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