{"record":{"id":"d69133e135e202f5","repo":"BerriAI/litellm","slug":"cryptography-package-is-required-for-oci-authentic","errorCode":null,"errorMessage":"cryptography package is required for OCI authentication. Please install it with: pip install cryptography","messagePattern":"cryptography package is required for OCI authentication\\. Please install it with: pip install cryptography","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"critical","filePath":"litellm/llms/oci/common_utils.py","lineNumber":35,"sourceCode":"    from cryptography.hazmat.primitives.asymmetric import padding, rsa\n\n    _CRYPTOGRAPHY_AVAILABLE = True\nexcept ImportError:\n    _CRYPTOGRAPHY_AVAILABLE = False\n\ntry:\n    from litellm._version import version as _litellm_version\nexcept ImportError:\n    _litellm_version = \"0.0.0\"\n\n\n# OCI GenAI REST API version — stable since service launch, unlikely to change\nOCI_API_VERSION: Final = \"20231130\"\n\n\ndef _require_cryptography() -> None:\n    if not _CRYPTOGRAPHY_AVAILABLE:\n        raise ImportError(\n            \"cryptography package is required for OCI authentication. Please install it with: pip install cryptography\"\n        )\n\n\nclass OCIError(BaseLLMException):\n    def __init__(\n        self,\n        status_code: int,\n        message: str,\n        headers: httpx.Headers | None = None,\n    ):\n        super().__init__(\n            status_code=status_code,\n            message=message,\n            headers=headers,\n        )\n\n","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/oci/common_utils.py#L17-L53","documentation":"OCI request signing requires the third-party 'cryptography' package (RSA PKCS1v15/SHA256 signing); litellm makes it an optional dependency and _require_cryptography() raises ImportError with install instructions the moment a signing path is entered without it.","triggerScenarios":"Any OCI chat/embedding/rerank call that needs manual signing (no oci_signer provided) on an environment where 'cryptography' is not installed: slim Docker images, Lambda layers, pip --no-deps installs, or air-gapped environments.","commonSituations":"Docker images built with 'pip install litellm' where the extra was not pulled in; upgrading Python versions in a venv that dropped optional deps; CI environments caching only core requirements. The failure appears only at first OCI call, not at import time.","solutions":["pip install cryptography (or add it to requirements.txt / pyproject dependencies).","For Docker: add it to the image explicitly, e.g. RUN pip install 'litellm[oci]' cryptography.","Verify with python -c \"import cryptography; print(cryptography.__version__)\".","If you cannot install it, supply a pre-built oci_signer from the OCI SDK (which bundles its own crypto) via optional_params."],"exampleFix":"# before — ImportError at first OCI call\nlitellm.completion(model=\"oci/cohere.command-r-plus\", messages=m)\n\n# after\n# shell: pip install cryptography\nlitellm.completion(model=\"oci/cohere.command-r-plus\", messages=m)","handlingStrategy":"validation","validationCode":"try:\n    import cryptography  # noqa: F401\n    HAS_CRYPTO = True\nexcept ImportError:\n    HAS_CRYPTO = False\nassert HAS_CRYPTO, \"pip install cryptography\"","typeGuard":null,"tryCatchPattern":"try:\n    litellm.completion(model=\"oci/...\", messages=m)\nexcept ImportError as e:\n    if \"cryptography\" in str(e):\n        subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", \"cryptography\"])\n        raise RuntimeError(\"cryptography installed; restart process\") from e\n    raise","preventionTips":["Add cryptography to your dependency manifest, not relying on litellm extras.","Bake it into Docker/CI images and assert the import at build time.","Startup smoke test any OCI call before serving traffic."],"tags":["oci","dependencies","import-error","packaging"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}