BerriAI/litellm · error · ImportError

google-cloud-iam is required for GCP IAM Redis authenticatio

Error message

google-cloud-iam is required for GCP IAM Redis authentication. Install it with: pip install google-cloud-iam

What it means

Error "google-cloud-iam is required for GCP IAM Redis authentication. Install it with: pip install google-cloud-iam" thrown in BerriAI/litellm.

Source

Thrown at litellm/_redis_credential_provider.py:34

# Keyed by service_account → (token, expiry_monotonic_timestamp).
_token_cache: Final[dict[str, tuple[str, float]]] = {}
_token_cache_lock: Final = threading.Lock()


def _generate_gcp_iam_access_token(service_account: str) -> str:
    """
    Generate GCP IAM access token for Redis authentication.

    Args:
        service_account: GCP service account in format 'projects/-/serviceAccounts/name@project.iam.gserviceaccount.com'

    Returns:
        Access token string for GCP IAM authentication
    """
    try:
        from google.cloud import iam_credentials_v1
    except ImportError:
        raise ImportError(
            "google-cloud-iam is required for GCP IAM Redis authentication. "
            "Install it with: pip install google-cloud-iam"
        )

    client: Final = iam_credentials_v1.IAMCredentialsClient()
    request: Final = iam_credentials_v1.GenerateAccessTokenRequest(
        name=service_account,
        scope=["https://www.googleapis.com/auth/cloud-platform"],
    )
    response: Final = client.generate_access_token(request=request)
    return str(response.access_token)


def _get_cached_gcp_iam_token(service_account: str) -> str:
    """
    Return a cached GCP IAM token, refreshing only when expired.

    Uses a module-level cache shared across all GCPIAMCredentialProvider

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Install google-cloud-iam: pip install google-cloud-iam.

When it happens

Trigger: Thrown at litellm/_redis_credential_provider.py:34 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/e2cbc4eab6a2d296. Report an issue: GitHub.