Vertex AI GenerateContent fails with 404 Publisher Model not found despite Owner role, correct config, and ADC.
I am trying to use the Vertex AI Python client library (google-cloud-aiplatform) to call Gemini models from a Python script running on my local machine (macOS). I am using Application Default Credentials (ADC) set up via gcloud auth application-default login on a standalone personal Google Cloud project (not part of an Organization, not using VPC Service Controls).
My vertexai.init() call succeeds, and instantiating GenerativeModel() also succeeds. However, when I call the model.generate_content() method, it fails consistently.
Error Message:
google.api_core.exceptions.NotFound: 404 Publisher Model `projects/blog-writer-agent/locations/us-central1/publishers/google/models/gemini-1.0-pro` was not found or your project does not have access to it. Please ensure you are using a valid model version. For more information, see: https://cloud.google.com/vertex-ai/generative-ai/docs/learn/model-versions
(Traceback points to the prediction_service/client.py making the API call)
Minimal Reproducible Code (test_vertexai.py):
import vertexai
from vertexai.generative_models import GenerativeModel
import traceback
# --- Configuration ---
PROJECT_ID = "blog-writer-agent"
LOCATION = "us-central1"
MODEL_NAME = "gemini-1.0-pro" # Stable model tested
print(f"Attempting to initialize Vertex AI for project='{PROJECT_ID}', location='{LOCATION}'...")
try:
# Initialize Vertex AI
vertexai.init(project=PROJECT_ID, location=LOCATION)
print("Vertex AI initialized successfully.")
print(f"Attempting to load model: '{MODEL_NAME}'...")
# Load the model
model = GenerativeModel(MODEL_NAME)
print("Model loaded successfully.")
print("Attempting to generate content...")
# Generate content - THIS IS WHERE THE ERROR OCCURS
response = model.generate_content("Why is the sky blue?")
print("Content generation call successful.")
print("\n--- Response ---")
print(response.text)
print("--- End Response ---")
except Exception as e:
print("\n--- An Error Occurred ---")
print(f"Error: {e}")
traceback.print_exc()
print("--- End Error ---")
Troubleshooting Steps Performed:
-
IAM: Confirmed my user account (PII Removed by Staff) has the Owner role on the blog-writer-agent project.
-
API Status: Verified “Vertex AI API” is Enabled in the Cloud Console for the project. Also tried disabling and re-enabling it, waiting 10+ minutes. Checked Console metrics, confirming 100% error rate for PredictionService.GenerateContent.
-
Credentials: Successfully created and refreshed Application Default Credentials using gcloud auth application-default login. Also tried renaming the credentials file and re-running the command.
-
Billing: Confirmed a Billing Account is linked to the project and is Active with no warnings or alerts. Corrected billing address details in payment settings.
-
Code Config: Verified PROJECT_ID and LOCATION (us-central1) are correct in the code and used in vertexai.init().
-
Model: Tested with stable model gemini-1.0-pro (also tried gemini-1.5-flash previously with same error).
-
Environment: Confirmed project is personal (no Org policies) and not using VPC Service Controls.
-
Cloud Status: Checked Google Cloud Status Dashboard; no active incidents seem related to Vertex AI predictions in us-central1.
Despite all these checks, the generate_content call consistently fails with the 404 Not Found error.
What other potential causes could lead to this specific error under these circumstances, or what further diagnostic steps can I take?