Hello,
I’m facing a persistent 404 Not Found error when trying to call the Vertex AI API (Gemini 1.0 Pro model) and I have exhausted all standard troubleshooting steps. I’m hoping someone in the community or a Google engineer can provide insight into what might be an account-level issue.
The Goal:
To deploy a Python Flask application that calls the gemini-1.0-pro model.
The Persistent Error:
The application crashes with the following error, both when deployed on Google Cloud Functions and on an external platform (Render):
google.api_core.exceptions.NotFound: 404 POST https://us-central1-aiplatform.googleapis.com/v1/projects/agente-bussola-v2/locations/us-central1/publishers/google/models/gemini-1.0-pro:generateContent: Publisher Model was not found or your project does not have access to it.
Our Debugging Journey:
We have confirmed this is not a simple configuration error. The problem has been reproduced even on a brand-new Google Account with a brand-new, cleanly configured project (agente-bussola-v2).
Here are the steps we have already taken:
- Enabled All Required APIs: We have confirmed that Vertex AI, Cloud Functions, Cloud Build, Cloud Run, Service Usage, and all other required APIs are active.
- Granted Correct IAM Permissions: The service account ‘Modified by moderator’ has the “Vertex AI User” role.
- Made Code Explicit: The Python code explicitly initializes the client with the correct project ID and location: vertexai.init(project=“agente-bussola-v2”, location=“us-central1”).
- Updated Libraries: The requirements.txt file forces an up-to-date version of the client library: google-cloud-aiplatform>=1.49.0.
- Pivoted to an External Platform (Render): To rule out a Google Cloud Functions issue, we deployed the exact same code as a Flask app on Render, using a downloaded Service Account JSON key. The exact same 404 error occurred, proving the issue is not with the execution environment but with the Google Cloud project’s ability to access the service.
- Billing Issues: We suspect an account-level block. My original Google Account had billing issues (OR_BACR2_44). Support told me my free credits were exhausted, but my console shows I have R$ 8.061 of credits remaining. This suggests a billing account desynchronization.
Final Code:
This is the code that is currently deployed on Render and still gets the 404 error.
main.py
from flask import Flask, request, jsonify
import vertexai
from vertexai.generative_models import GenerativeModel
app = Flask(name)
SYSTEM_PROMPT = “”"
[A detailed, multi-page system prompt for a chatbot goes here]
“”"
vertexai.init(project=“agente-bussola-v2”, location=“us-central1”)
model = GenerativeModel(“gemini-1.0-pro”)
@app.routeapp.route(‘/’, methods=[‘GET’, ‘POST’])
def bussola_agent():
user_message = “Hello, can you help me?”
if request.is_json and ‘message’ in request.get_json():
user_message = request.get_json()[‘message’]
full_prompt = f"{SYSTEM_PROMPT}\\n\\nUser Message: {user_message}"
try:
response = model.generate_content(full_prompt)
return jsonify({"reply": response.text})
except Exception as e:
print(f"An error occurred: {e}")
return jsonify({"error": str(e)}), 500
requirements.txt
google-cloud-aiplatform>=1.49.0
gunicorn
Flask
My Question:
Given that this error persists across new accounts, new projects, and different deployment platforms, and that there are clear signs of a billing account discrepancy, what could be causing this account-level block? How can I get my account’s ability to consume the Vertex AI service properly enabled?
Thank you for your help.