BerriAI/litellm · error · ValueError

Missing required environment variable - GOOGLE_APPLICATION_C

Error message

Missing required environment variable - GOOGLE_APPLICATION_CREDENTIALS

What it means

First environment check in the Google KMS integration's validate_environment: GOOGLE_APPLICATION_CREDENTIALS is not set, so the Google KMS client cannot authenticate. Set the service-account credentials file path before using Google KMS decryption.

Source

Thrown at litellm/secret_managers/google_kms.py:20

This is a file for the Google KMS integration

Relevant issue: https://github.com/BerriAI/litellm/issues/1235

Requires:
* `os.environ["GOOGLE_APPLICATION_CREDENTIALS"], os.environ["GOOGLE_KMS_RESOURCE_NAME"]`
* `pip install google-cloud-kms`
"""

import os
from typing import Final

import litellm
from litellm.proxy._types import KeyManagementSystem


def validate_environment():
    if "GOOGLE_APPLICATION_CREDENTIALS" not in os.environ:
        raise ValueError("Missing required environment variable - GOOGLE_APPLICATION_CREDENTIALS")
    if "GOOGLE_KMS_RESOURCE_NAME" not in os.environ:
        raise ValueError("Missing required environment variable - GOOGLE_KMS_RESOURCE_NAME")


def load_google_kms(use_google_kms: bool | None):
    if use_google_kms is None or use_google_kms is False:
        return
    try:
        from google.cloud import kms_v1

        validate_environment()

        # Create the KMS client
        client: Final = kms_v1.KeyManagementServiceClient()
        litellm.secret_manager_client = client
        litellm._key_management_system = KeyManagementSystem.GOOGLE_KMS
        litellm._google_kms_resource_name = os.getenv("GOOGLE_KMS_RESOURCE_NAME")
    except Exception as e:

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Set GOOGLE_APPLICATION_CREDENTIALS to the path of a valid service-account JSON key.
  2. Or run on GCP with application default credentials available.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/secret_managers/google_kms.py:20 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/fb9c3eadd929e98c. Report an issue: GitHub.