BerriAI/litellm · error · ValueError

{self.type.capitalize()} API call failed. Error: {e}

Error message

{self.type.capitalize()} API call failed. Error: {e}

What it means

Wrapper in the LiteLLM semantic-router encoder: the underlying litellm embedding call (query or document type) raised exception e; the encoder re-raises with the call type and error so semantic-router surfaces the provider failure.

Source

Thrown at litellm/router_strategy/auto_router/litellm_encoder.py:120

        return self.encode_queries(docs, **kwargs)

    async def acall(self, docs: list[Any], **kwargs) -> list[list[float]]:
        """Encode a list of documents into embeddings using LiteLLM asynchronously.

        :param docs: List of documents to encode.
        :return: List of embeddings for each document."""
        return await self.aencode_queries(docs, **kwargs)

    def encode_queries(self, docs: list[str], **kwargs) -> list[list[float]]:
        if self.litellm_router_instance is None:
            raise ValueError("litellm_router_instance is not set")
        try:
            embeds: Final = self.litellm_router_instance.embedding(
                input=self._clamp(docs), model=self.model_name, **kwargs
            )
            return litellm_to_list(embeds)
        except Exception as e:
            raise ValueError(f"{self.type.capitalize()} API call failed. Error: {e}") from e

    def encode_documents(self, docs: list[str], **kwargs) -> list[list[float]]:
        if self.litellm_router_instance is None:
            raise ValueError("litellm_router_instance is not set")
        try:
            embeds: Final = self.litellm_router_instance.embedding(
                input=self._clamp(docs), model=self.model_name, **kwargs
            )
            return litellm_to_list(embeds)
        except Exception as e:
            raise ValueError(f"{self.type.capitalize()} API call failed. Error: {e}") from e

    async def aencode_queries(self, docs: list[str], **kwargs) -> list[list[float]]:
        if self.litellm_router_instance is None:
            raise ValueError("litellm_router_instance is not set")
        try:
            embeds: Final = await self.litellm_router_instance.aembedding(
                input=self._clamp(docs), model=self.model_name, **kwargs

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Check the underlying error, model credentials, and endpoint availability, then retry.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at litellm/router_strategy/auto_router/litellm_encoder.py:120 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/7ef4cd66d0f4ac83. Report an issue: GitHub.