BerriAI/litellm · error · OCIError

oci_key must be a string containing the PEM private key…

Error message

oci_key must be a string containing the PEM private key content. Got type: {type(oci_key).__name__}

What it means

Error "oci_key must be a string containing the PEM private key content. Got type: {type(oci_key).__name__}" thrown in BerriAI/litellm.

Solutions

  1. Pass oci_key as a string containing the PEM private key content, not the type shown in the message.

When it happens

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

Common situations: See trigger scenarios.


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

Appendix: source

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

    }

    signed_header_names: Final = [
        "date",
        "(request-target)",
        "host",
        "content-length",
        "content-type",
        "x-content-sha256",
    ]
    signing_string: Final = build_signature_string(method, path, headers_to_sign, signed_header_names)

    _require_cryptography()

    # Resolve the private key — prefer inline PEM content over file path
    oci_key_content: str | None = None
    if oci_key:
        if not isinstance(oci_key, str):
            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(

View on GitHub (pinned to 77b7c6c40c)