BerriAI/litellm · error · ValueError

CustomSecretManagerException - key_management_settings is re

Error message

CustomSecretManagerException - key_management_settings is required with custom_secret_manager field

What it means

Config guard: custom_secret_manager was requested in the proxy config, but litellm._key_management_settings is None, meaning key management settings were never initialized before the loader ran. Sentinel ValueError for missing global configuration state.

Source

Thrown at litellm/secret_managers/custom_secret_manager_loader.py:37

    Load and initialize a custom secret manager from a python file.

    Similar to how custom guardrails are loaded - loads the class from
    the custom_secret_manager field in key_management_settings.

    Args:
        config_file_path: Path to the config.yaml file

    Raises:
        ValueError: If required configuration is missing
        ImportError: If the custom secret manager module cannot be loaded
    """

    if not config_file_path:
        raise ValueError("CustomSecretManagerException - config_file_path is required to load custom secret manager")

    # Get the custom_secret_manager class path from settings
    if litellm._key_management_settings is None:
        raise ValueError(
            "CustomSecretManagerException - key_management_settings is required with custom_secret_manager field"
        )

    custom_secret_manager_path: Final = getattr(litellm._key_management_settings, "custom_secret_manager", None)

    if not custom_secret_manager_path:
        raise ValueError(
            "CustomSecretManagerException - custom_secret_manager field is required in key_management_settings"
        )

    # Split into file_name and class_name (e.g., "my_secret_manager.InMemorySecretManager")
    _file_name, _class_name = custom_secret_manager_path.split(".")
    verbose_proxy_logger.debug(
        "Initializing custom secret manager: %s, file_name: %s, class_name: %s",
        custom_secret_manager_path,
        _file_name,
        _class_name,
    )

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Add a key_management_settings block to the config when specifying custom_secret_manager.
  2. Example: key_management_settings: {custom_secret_manager: my_module.MyClass}.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/secret_managers/custom_secret_manager_loader.py:37 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/dddef97497b2a139. Report an issue: GitHub.