mlflow/mlflow · error · ImportError

Vertex AI provider requires the google-auth package. Install

Error message

Vertex AI provider requires the google-auth package. Install it with: pip install google-auth

What it means

The Vertex AI provider needs the google-auth package to obtain OAuth credentials. If the import fails, it raises ImportError with instructions to install google-auth. This is a lazy optional-dependency check.

Source

Thrown at mlflow/gateway/providers/vertex_ai.py:233

        if self._model_type == "claude":
            self._delegate = _VertexAIClaudeProvider(
                config, self.vertex_config, self._get_credentials
            )
        elif self._model_type == "maas":
            self._delegate = _VertexAIMaaSProvider(
                config, self.vertex_config, self._get_credentials
            )
        else:
            self._delegate = None

    def _get_credentials(self):
        """Get Google Cloud credentials, caching them for reuse."""
        try:
            import google.auth
            import google.auth.transport.requests
            from google.oauth2 import service_account
        except ImportError:
            raise ImportError(
                "Vertex AI provider requires the google-auth package. "
                "Install it with: pip install google-auth"
            )

        if self._cached_credentials is not None and self._cached_credentials.valid:
            return self._cached_credentials

        if creds_data := self.vertex_config.vertex_credentials:
            try:
                info = json.loads(creds_data)
            except (json.JSONDecodeError, TypeError):
                try:
                    info = json.loads(Path(creds_data).read_text())
                except Exception as e:
                    raise ValueError(
                        "vertex_credentials must be a JSON string or path to a JSON file"
                    ) from e
            credentials = service_account.Credentials.from_service_account_info(

View on GitHub (pinned to 6a27f2decc)

Solutions

  1. Install the missing package: pip install google-auth.
  2. Install gateway extras: pip install 'mlflow[gateway]'.
  3. If using uv, add google-auth to the environment dependencies.
  4. Rebuild/redeploy the container image with google-auth included.

Example fix

# before
pip install mlflow
# after
pip install "mlflow[gateway]" google-auth
Defensive patterns

Strategy: try-catch

Validate before calling

import importlib.util
if importlib.util.find_spec('google.auth') is None:
    raise SystemExit("Install google-auth: pip install 'mlflow[gateway]' google-auth")

Try / catch

try:
    headers = await provider.headers()
except ImportError as e:
    log.error('Optional dependency missing: %s', e)
    # install google-auth and retry

Prevention

When it happens

Trigger: Using a vertexai gateway route in an environment where google-auth is not installed, so `import google.auth` inside _get_credentials raises ImportError.

Common situations: MLflow skinny or minimal installs without the gateway extras, CI environments missing optional dependencies, or deploying the gateway to a fresh container without pip install 'mlflow[gateway]' extras.

Related errors


AI-assisted analysis of mlflow/mlflow@6a27f2decc (2026-08-29). Data as JSON: /api/errors/a97cc1531ae28e71. Report an issue: GitHub.