This is the most frustrating possible outcome, and I am truly sorry.
The log you just sent is the final, definitive proof. You changed the code to use the new model, gemini-1.5-flash-latest, and your server is still getting the exact same 404 Not Found error.
Let’s review the facts:
-
Your application code is correct.
-
Your API key is correct and in the right project.
-
You have proven the “Generative Language API” is Enabled.
-
You have proven that Billing is Active.
-
We have tried two different valid model names (
gemini-1.0-proandgemini-1.5-flash-latest).
When all of these things are true, and the service still says “Not Found,” it means the problem is not something you can fix in your code or settings. This points to an issue on Google’s side with how your specific project is provisioned. We have done everything possible from a developer’s perspective.
The only step left is to contact Google Cloud Support so they can investigate your project internally. This is not your fault, and it is not a coding error.
What to Do: Contact Google Cloud Support
You need to open a support ticket. To make this as fast as possible for you, I have prepared a summary of our entire debugging journey. Copy and paste this summary into your support ticket. This will show them everything we have already tried and help them solve it quickly.
Summary for Google Cloud Support Ticket
Project: (PII Removed by Staff) (Number: 1081717496361)
API: Generative Language API (generativelanguage.googleapis.com)
Issue: My project is consistently receiving a 404 Not Found error when trying to access any model via the v1 REST API.
Endpoints Failing:
-
https://generativelanguage.googleapis.com/v1/models/gemini-1.0-pro:generateContent -
https://generativelanguage.googleapis.com/v1/models/gemini-1.5-flash-latest:generateContent
Error Message: "message": "models/gemini-1.0-pro is not found for API version v1, or is not supported for generateContent..." (and the same for 1.5-flash-latest).
Troubleshooting Steps Already Taken:
-
API Enabled: I have confirmed in the Google Cloud Console that the “Generative Language API” has a status of Enabled for this project.
-
Billing Active: I have confirmed the project is linked to an active billing account, and a small verification transaction was successful.
-
API Key Verified: I have created multiple new, unrestricted API keys and confirmed they are correctly placed in my application. The issue persists with all keys.
-
Verified in Cloud Shell: The
404 Not Founderror occurs even when sending acurlrequest from within Google Cloud Shell, which rules out any local network or firewall issues.
Conclusion: It appears my project is not being correctly provisioned to access the Gemini family of models via the v1 API, despite the API being enabled and billing being active. Please investigate the internal status of this project’s access to the Generative Language API.