{"record":{"id":"7ef4cd66d0f4ac83","repo":"BerriAI/litellm","slug":"self-type-capitalize-api-call-failed-error","errorCode":null,"errorMessage":"{self.type.capitalize()} API call failed. Error: {e}","messagePattern":"(.+?) API call failed\\. Error: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/router_strategy/auto_router/litellm_encoder.py","lineNumber":120,"sourceCode":"        return self.encode_queries(docs, **kwargs)\n\n    async def acall(self, docs: list[Any], **kwargs) -> list[list[float]]:\n        \"\"\"Encode a list of documents into embeddings using LiteLLM asynchronously.\n\n        :param docs: List of documents to encode.\n        :return: List of embeddings for each document.\"\"\"\n        return await self.aencode_queries(docs, **kwargs)\n\n    def encode_queries(self, docs: list[str], **kwargs) -> list[list[float]]:\n        if self.litellm_router_instance is None:\n            raise ValueError(\"litellm_router_instance is not set\")\n        try:\n            embeds: Final = self.litellm_router_instance.embedding(\n                input=self._clamp(docs), model=self.model_name, **kwargs\n            )\n            return litellm_to_list(embeds)\n        except Exception as e:\n            raise ValueError(f\"{self.type.capitalize()} API call failed. Error: {e}\") from e\n\n    def encode_documents(self, docs: list[str], **kwargs) -> list[list[float]]:\n        if self.litellm_router_instance is None:\n            raise ValueError(\"litellm_router_instance is not set\")\n        try:\n            embeds: Final = self.litellm_router_instance.embedding(\n                input=self._clamp(docs), model=self.model_name, **kwargs\n            )\n            return litellm_to_list(embeds)\n        except Exception as e:\n            raise ValueError(f\"{self.type.capitalize()} API call failed. Error: {e}\") from e\n\n    async def aencode_queries(self, docs: list[str], **kwargs) -> list[list[float]]:\n        if self.litellm_router_instance is None:\n            raise ValueError(\"litellm_router_instance is not set\")\n        try:\n            embeds: Final = await self.litellm_router_instance.aembedding(\n                input=self._clamp(docs), model=self.model_name, **kwargs","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/router_strategy/auto_router/litellm_encoder.py#L102-L138","documentation":"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.","triggerScenarios":"Thrown at litellm/router_strategy/auto_router/litellm_encoder.py:120 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the underlying error, model credentials, and endpoint availability, then retry."],"exampleFix":null,"handlingStrategy":"try-catch","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-14T00:17:10.932Z"}