BerriAI/litellm · error · OCIError

Private key is required for OCI authentication. Provide…

Error message

Private key is required for OCI authentication. Provide either oci_key or oci_key_file.

What it means

Error "Private key is required for OCI authentication. Provide either oci_key or oci_key_file." thrown in BerriAI/litellm.

Solutions

  1. Provide either oci_key (PEM string) or oci_key_file (path to PEM file) for OCI authentication.

When it happens

Trigger: Thrown at litellm/llms/oci/common_utils.py:325 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/122b717af7e810dc. Report an issue: GitHub.

Appendix: source

Thrown at litellm/llms/oci/common_utils.py:325

            raise OCIError(
                status_code=400,
                message=(
                    f"oci_key must be a string containing the PEM private key content. "
                    f"Got type: {type(oci_key).__name__}"
                ),
            )
        oci_key_content = oci_key.replace("\\n", "\n").replace("\r\n", "\n")

    private_key: Final = (
        load_private_key_from_str(oci_key_content)
        if oci_key_content
        else load_private_key_from_file(oci_key_file)
        if oci_key_file
        else None
    )

    if private_key is None:
        raise OCIError(
            status_code=400,
            message="Private key is required for OCI authentication. Provide either oci_key or oci_key_file.",
        )

    signature: Final = private_key.sign(
        signing_string.encode("utf-8"),
        padding.PKCS1v15(),
        hashes.SHA256(),
    )
    signature_b64: Final = base64.b64encode(signature).decode()

    key_id: Final = f"{oci_tenancy}/{oci_user}/{oci_fingerprint}"
    authorization: Final = (
        'Signature version="1",'
        f'keyId="{key_id}",'
        'algorithm="rsa-sha256",'
        f'headers="{" ".join(signed_header_names)}",'
        f'signature="{signature_b64}"'

View on GitHub (pinned to 77b7c6c40c)