ModelNotFoundError or 404 Model Not Found
google.api_core.exceptions.NotFound: 404 The model `gemini-pro-vision` does not exist
Stack trace
google.api_core.exceptions.NotFound: 404 The model `gemini-pro-vision` does not exist or you do not have permission to access it.
Details: {
'error': {
'code': 404,
'message': 'The model `gemini-pro-vision` does not exist or you do not have permission to access it.',
'errors': [{
'message': 'The model `gemini-pro-vision` does not exist or you do not have permission to access it.',
'domain': 'global',
'reason': 'notFound'
}],
'status': 'NOT_FOUND'
}
} Why it happens
Google deprecated gemini-pro-vision in favor of newer multimodal models (gemini-1.5-flash, gemini-2.0-flash) that have better vision capabilities, faster inference, and lower costs. The model no longer exists on Google's servers, so any request to it returns a 404 error. This is a hard deprecation: the model is gone, not just marked deprecated.
Detection
Check your code for hardcoded 'gemini-pro-vision' strings and test against the current Google Generative AI SDK (>=0.7.0). Add model existence validation before generation calls to catch deprecated models at startup rather than runtime.
Causes & fixes
Using hardcoded model name 'gemini-pro-vision' in genai.GenerativeModel() calls
Replace 'gemini-pro-vision' with 'gemini-1.5-flash' (recommended) or 'gemini-2.0-flash'. No other code changes needed: both support vision/multimodal inputs identically.
Loading model name from old config file or environment variable that still references gemini-pro-vision
Update your config files (.env, config.yaml, secrets.json) to use gemini-1.5-flash instead. Redeploy or restart the app to load the new config.
Using an old version of google-generativeai SDK (pre-0.7.0) that doesn't support newer models
Upgrade the SDK: `pip install --upgrade google-generativeai` to 0.7.0 or later. Check pip show google-generativeai to verify the version.
Dynamically constructing model name from user input or data without validation against supported models
Add a whitelist of supported models: `SUPPORTED_MODELS = ['gemini-2.0-flash', 'gemini-1.5-pro', 'gemini-1.5-flash']` and validate user input against it before calling GenerativeModel().
Code: broken vs fixed
import os
import google.generativeai as genai
genai.configure(api_key=os.environ['GOOGLE_API_KEY'])
# This model no longer exists — returns 404
model = genai.GenerativeModel('gemini-pro-vision') # ← BROKEN: deprecated model
response = model.generate_content('What is in this image?', images=[image_bytes])
print(response.text) import os
import google.generativeai as genai
genai.configure(api_key=os.environ['GOOGLE_API_KEY'])
# Use gemini-1.5-flash instead (supports vision/multimodal)
model = genai.GenerativeModel('gemini-1.5-flash') # ← FIXED: current multimodal model
response = model.generate_content('What is in this image?', images=[image_bytes])
print(response.text) # Works identically to old gemini-pro-vision Workaround
If you must maintain backward compatibility temporarily, create a compatibility layer that maps the old model name to the new one: `MODEL_MAP = {'gemini-pro-vision': 'gemini-1.5-flash'}` and replace all GenerativeModel(model_name) with GenerativeModel(MODEL_MAP.get(model_name, model_name)). This buys time for a full migration but should be removed within 2 sprints.
Prevention
Store model names in a centralized config file (not hardcoded), implement a model validation function that checks against an official supported list, and monitor Google's model deprecation roadmap. Use the latest google-generativeai SDK and test monthly against new models to catch deprecations early.