{"record":{"id":"62bb88a8fc2f065b","repo":"BerriAI/litellm","slug":"failed-to-parse-oci-embed-response-as-json-e","errorCode":null,"errorMessage":"Failed to parse OCI embed response as JSON: {e}","messagePattern":"Failed to parse OCI embed response as JSON: (.+?)","errorType":"exception","errorClass":"OCIError","httpStatus":null,"severity":"error","filePath":"litellm/llms/oci/embed/transformation.py","lineNumber":268,"sourceCode":"        model: str,\n        raw_response: httpx.Response,\n        model_response: EmbeddingResponse,\n        logging_obj: LiteLLMLoggingObj,\n        api_key: str | None,\n        request_data: dict,\n        optional_params: dict,\n        litellm_params: dict,\n    ) -> EmbeddingResponse:\n        if raw_response.status_code != 200:\n            raise OCIError(\n                status_code=raw_response.status_code,\n                message=raw_response.text,\n            )\n\n        try:\n            json_response: Final = raw_response.json()\n        except Exception as e:\n            raise OCIError(\n                status_code=raw_response.status_code,\n                message=f\"Failed to parse OCI embed response as JSON: {e}\",\n            )\n\n        try:\n            parsed: Final = OCIEmbedResponse(**json_response)\n        except Exception as e:\n            raise OCIError(\n                status_code=500,\n                message=f\"OCI embed response does not match expected schema: {e}\",\n            )\n\n        model_response.model = parsed.modelId\n        model_response.data = [\n            {\n                \"object\": \"embedding\",\n                \"index\": i,\n                \"embedding\": embedding,","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/oci/embed/transformation.py#L250-L286","documentation":"The OCI embedding adapter expects the endpoint to return JSON (it calls `raw_response.json()` inside transform_embedding_response). If the body cannot be parsed as JSON — even with a 200 status — this error wraps the parse exception and includes it in the message, preserving the upstream status code.","triggerScenarios":"The endpoint returns HTML (auth proxy login page, WAF block page), an empty body, a truncated stream, or plain-text error text with Content-Type confusion. Typically happens when api_base points at a gateway/proxy rather than the real OCI generative-ai service.","commonSituations":"Corporate proxies or API gateways (Kong, nginx, Cloudflare) intercepting the request and returning HTML; a wrong api_base that hits a generic web server; or a middlebox closing the connection mid-body.","solutions":["Verify the api_base URL points to the OCI generative-ai endpoint (https://inference.generativeai.<region>.oci.oraclecloud.com/...).","Reproduce the request with curl to inspect what body is actually returned; if it is a proxy login/block page, fix proxy or network config.","If the body is empty intermittently, check for connection resets and retry."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    resp = litellm.embedding(model=\"oci/...\", input=texts)\nexcept Exception as e:\n    if \"Failed to parse OCI embed response as JSON\" in str(e):\n        # body wasn't JSON: likely proxy/gateway or wrong api_base\n        log_raw_probe(api_base)\n        raise","preventionTips":["Point api_base only at real OCI inference endpoints","Smoke-test with a single embedding after any network/proxy change","Curl the endpoint manually when this fires to see the actual body"],"tags":["oci","embedding","json","proxy","response-parsing"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}