GoogleAPICallError
google.api_core.exceptions.GoogleAPICallError
Stack trace
google.api_core.exceptions.GoogleAPICallError: 403 The API 'aiplatform.googleapis.com' is not enabled for project 'your-project-id'. Please enable it in the Google Cloud Console.
Why it happens
The Google Cloud project you are using has not enabled the Vertex AI API service. Without enabling this API, any calls to Vertex AI endpoints will be rejected with a permission error. This is a security and billing control enforced by Google Cloud.
Detection
Check for 403 errors mentioning 'API not enabled' in your logs or exception messages when calling Vertex AI services.
Causes & fixes
Vertex AI API is not enabled in the Google Cloud project.
Go to the Google Cloud Console, navigate to APIs & Services > Library, search for 'Vertex AI API', and enable it for your project.
Using incorrect or unauthorized Google Cloud project ID in your client configuration.
Verify that your client code uses the correct project ID and that your service account or user has permissions on that project.
Service account lacks permission to access Vertex AI API.
Ensure the service account has roles like 'Vertex AI User' or 'Editor' assigned in IAM for the project.
Code: broken vs fixed
from google.cloud import aiplatform
client = aiplatform.PipelineServiceClient()
# This call triggers the error if API not enabled
response = client.list_training_pipelines(parent="projects/your-project-id/locations/us-central1")
print(response) import os
from google.cloud import aiplatform
project_id = os.environ.get("GOOGLE_CLOUD_PROJECT")
if not project_id:
raise EnvironmentError("GOOGLE_CLOUD_PROJECT environment variable is not set.")
client = aiplatform.PipelineServiceClient()
# After enabling API in console, this call works
response = client.list_training_pipelines(parent=f"projects/{project_id}/locations/us-central1")
print(response) # Fixed: API enabled and project ID used from env Workaround
If you cannot enable the API immediately, catch the GoogleAPICallError exception and log a clear message prompting to enable the API before retrying.
Prevention
Always enable required Google Cloud APIs for your project before deploying code that calls those services, and verify IAM permissions for your service accounts.