{"record":{"id":"57782a87c93dc4ca","repo":"BerriAI/litellm","slug":"raw-response-text-57782a","errorCode":null,"errorMessage":"raw_response.text","messagePattern":"raw_response\\.text","errorType":"http","errorClass":"PerplexityEmbeddingError","httpStatus":null,"severity":"error","filePath":"litellm/llms/perplexity/embedding/transformation.py","lineNumber":151,"sourceCode":"            int8_values: Final = struct.unpack(f\"{count}b\", raw_bytes)\n            return [float(v) / 127.0 for v in int8_values]\n        return embedding_value\n\n    def transform_embedding_response(\n        self,\n        model: str,\n        raw_response: httpx.Response,\n        model_response: EmbeddingResponse,\n        logging_obj: LiteLLMLoggingObj,\n        api_key: str | None = None,\n        request_data: dict = {},\n        optional_params: dict = {},\n        litellm_params: dict = {},\n    ) -> EmbeddingResponse:\n        try:\n            raw_response_json: Final = raw_response.json()\n        except Exception:\n            raise PerplexityEmbeddingError(message=raw_response.text, status_code=raw_response.status_code)\n\n        model_response.model = raw_response_json.get(\"model\", model)\n        model_response.object = raw_response_json.get(\"object\", \"list\")\n\n        raw_data: Final = raw_response_json.get(\"data\", [])\n        decoded_data: Final[list[dict[str, Any]]] = []\n        for item in raw_data:\n            decoded_item = dict(item)\n            decoded_item[\"embedding\"] = self._decode_base64_embedding(item.get(\"embedding\"))\n            decoded_data.append(decoded_item)\n        model_response.data = decoded_data\n\n        usage_data: Final = raw_response_json.get(\"usage\", {})\n        usage: Final = Usage(\n            prompt_tokens=usage_data.get(\"prompt_tokens\", 0) or usage_data.get(\"total_tokens\", 0),\n            total_tokens=usage_data.get(\"total_tokens\", 0),\n        )\n        model_response.usage = usage","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/perplexity/embedding/transformation.py#L133-L169","documentation":"LiteLLM's Perplexity embedding handler calls raw_response.json(); when the body is not JSON it raises PerplexityEmbeddingError with the raw body text as the message and the real HTTP status code. Note Perplexity's API is primarily search/chat, so embedding models are limited and invalid model names commonly produce non-JSON errors.","triggerScenarios":"Calling litellm.embedding(model='perplexity/...') with an unavailable embedding model, an invalid/expired API key, or an api_base pointing at something that returns HTML or plain text.","commonSituations":"Assuming Perplexity serves OpenAI-compatible embeddings it does not offer; expired PERPLEXITYAI_API_KEY; gateway/CDN error pages during incidents.","solutions":["Read the exception message - it is the raw body naming the real problem","Confirm the embedding model actually exists on Perplexity's API","Verify/rotate PERPLEXITYAI_API_KEY","Route embeddings to a provider that supports them (e.g., OpenAI) if Perplexity lacks the model"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"Catch PerplexityEmbeddingError around litellm.embedding(); log the message (raw body) to identify auth vs. model-availability issues, and fall back to an OpenAI-compatible embedding provider when Perplexity rejects the model.","preventionTips":["Verify the embedding model exists on Perplexity before integrating","Keep a secondary embedding provider configured for fallback","Rotate keys proactively so expired credentials surface in staging, not production"],"tags":["perplexity","embedding","json-parsing","http-response","litellm"],"backgroundTag":"invalid-json-response","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}