High severity beginner · Fix: 2-5 min

NotFound

google.api_core.exceptions.NotFound

What this error means
The specified Vertex AI GenerativeModel model ID does not exist or is not accessible in the project or location.

Stack trace

traceback
google.api_core.exceptions.NotFound: 404 The model "projects/your-project/locations/us-central1/models/nonexistent-model" was not found.
	at google.cloud.aiplatform_v1.services.model_service.client.ModelServiceClient.get_model(ModelServiceClient.java:...)
QUICK FIX
Double-check and correct the model resource name string passed to the GenerativeModel client constructor.

Why it happens

This error occurs when the model ID provided to the Vertex AI GenerativeModel client does not exist in the specified project or location, or the authenticated user lacks permission to access it. It can also happen if the model name is misspelled or the location is incorrect.

Detection

Catch google.api_core.exceptions.NotFound exceptions when calling model-related methods and log the full model resource name to verify correctness before retrying.

Causes & fixes

1

Incorrect or misspelled model resource name passed to the GenerativeModel client.

✓ Fix

Verify and correct the full model resource name format: 'projects/{project}/locations/{location}/models/{model_id}'.

2

Model does not exist in the specified project or location.

✓ Fix

Confirm the model is deployed in the correct project and location via the Google Cloud Console or gcloud CLI.

3

Insufficient IAM permissions to access the model resource.

✓ Fix

Ensure the service account or user has roles/aiplatform.user or equivalent permissions for the model.

Code: broken vs fixed

Broken - triggers the error
python
from google.cloud import aiplatform

client = aiplatform.gapic.GenerativeModelServiceClient()

model_name = "projects/my-project/locations/us-central1/models/nonexistent-model"

response = client.generate_text(model=model_name, prompt="Hello")  # This line triggers NotFound error
Fixed - works correctly
python
import os
from google.cloud import aiplatform

os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = os.environ.get("GOOGLE_APPLICATION_CREDENTIALS")  # Use env var for auth

client = aiplatform.gapic.GenerativeModelServiceClient()

model_name = "projects/my-project/locations/us-central1/models/valid-model-id"  # Correct model ID

response = client.generate_text(model=model_name, prompt="Hello")
print(response)
Corrected the model resource name to a valid existing model ID and ensured authentication via environment variable for Google credentials.

Workaround

Wrap calls in try/except for NotFound and fallback to a default known good model or notify the user to check model availability.

Prevention

Use infrastructure as code or deployment scripts to manage and verify model deployment and resource names before runtime to avoid invalid references.

Python 3.9+ · google-cloud-aiplatform >=1.26.0 · tested on 1.30.0
Verified 2026-04
Verify ↗

Community Notes

No notes yetBe the first to share a version-specific fix or tip.