I’m encountering a persistent 404 Not Found error when trying to access standard Gemini models. My requests are consistently being routed to a v1beta endpoint where models like gemini-pro-vision and gemini-pro are not found, even though my list_models() call shows they are available.
The key contradiction is:
A script to list available models successfully shows models/gemini-pro-vision as an option that supports generateContent.
A script to use that exact model (generate_content) fails with a 404 Not Found error.
Troubleshooting Steps I’ve Already Taken: I have already tried the following steps without any change in the error:
Forcefully reinstalling the google-generativeai library to ensure it’s the latest version.
Running the scripts in a completely clean, new Python virtual environment (venv).
Generating a brand new API key in a completely new Google AI Studio project.
Trying different model names, including gemini-pro, gemini-1.5-flash-latest, and gemini-pro-vision.
Using the full model path models/gemini-pro-vision.
Any help in understanding why my project is stuck on the v1beta endpoint or why generate_content cannot find a model that list_models can see would be greatly appreciated. Thank you.
I have attached a python script. To give you some context I am trying to automate the process by getting Gemini to recognise images and create a CSV that contains the relevant identification.
import google.generativeai as genaifrom PIL import Imageimport os
API_KEY = “YOUR_API_KEY_HERE”
IMAGE_FOLDER = r"C:\Path\To\Your\Images"IMAGE_FILENAME = “example_image.jpg”
try:genai.configure(api_key=API_KEY)image_path = os.path.join(IMAGE_FOLDER, IMAGE_FILENAME)
print(f"Attempting to process one image: {image_path}")
if not os.path.exists(image_path):
print(f"\n--- ERROR! ---")
print(f"The image file was not found.")
exit()
# Using the full model name that is failing
model = genai.GenerativeModel('models/gemini-pro-vision')
img = Image.open(image_path)
prompt = "Describe this image in one sentence."
response = model.generate_content([prompt, img])
print("\n--- SUCCESS! ---")
print(response.text)
except Exception as e:print(“\n— ERROR! —”)print(f"The API call failed with the following error:\n{e}")
It then produces the following error:
--- ERROR! --- The API call failed with the following error: 404 models/gemini-pro-vision is not found for API version v1beta, or is not supported for generateContent. Call ListModels to see the list of available models and their supported methods.
If you run the code provided, you will notice that there is no model named models/gemini-pro-vision. Could you recheck and retry with correct model name?
import google.genai as genai
client = genai.Client(api_key="GEMINI_API_KEY")
models = client.models.list()
for model in models:
print(model.name)