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
- Install the missing package: pip install google-auth.
- Install gateway extras: pip install 'mlflow[gateway]'.
- If using uv, add google-auth to the environment dependencies.
- 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
- Include google-auth in deployment images that serve vertexai routes.
- Install mlflow with gateway extras in CI and production.
- Import-check optional dependencies at container startup.
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
- Unsupported route type for Vertex AI Claude: {route_type}
- Unexpected config type {config.model.config}
- vertex_credentials must be a JSON string or path to a JSON f
- The completions endpoint is not supported for {self.config.m
- RESOURCE_DOES_NOT_EXIST
AI-assisted analysis of mlflow/mlflow@6a27f2decc (2026-08-29).
Data as JSON: /api/errors/a97cc1531ae28e71.
Report an issue: GitHub.