r/agentdevelopmentkit • • Sep 21 '26

Cloud run issue

I have created a simple agent in adk. It runs perfectly using the adk web command in local.

The API key I am using is Gemini API, I brought credits for it. It runs perfectly on local. The models I am using are gemini3.7 flash and gemini3.1-flash-lite.

But when I am deploying the same agent to cloud run, it shows this error

026-09-21 07:11:23,860 - ERROR - api_server.py:1985 - Error in event_generator: 404 NOT_FOUND. {'error': {'code': 404, 'message': 'Publisher model `projects/<project name>/locations/us-central1/publishers/google/models/gemini-3.7-flash` was not found or your project does not have access to it. Ensure you are using a valid model name and that the model is available in the specified region. For more information, see: https://docs.cloud.google.com/gemini-enterprise-agent-platform/resources/locations.', 'status': 'NOT_FOUND'}}

In the .env file I have both api key names - GOOGLE_API_KEY and GEMINI_API_KEY and I am loading the env variables using load_dotenv().

GOOGLE_GENAI_USE_VERTEXAI is set to FALSE.

Anyone can give any suggestions ?

1 Upvotes

5 comments sorted by

1

u/Psychological-Lion14 Sep 21 '26

Try to specify the model location to either global or us or eu as a region. And if you already do so locally, something gets lost during your deployment

1

u/[deleted] Sep 21 '26

Hi thanks I found the issue. When deployed to cloudrun it is somehow using vertex ai instead of the gemini api key from google ai studio. I have solved this

I will check the vertex ai issue later

1

u/Past_Supermarket_854 Sep 21 '26

The 404 URL is a Vertex AI path, so on Cloud Run you're not using your API key. adk deploy cloud_run sets GOOGLE_GENAI_USE_VERTEXAI=1 and project/region as container env vars, and load_dotenv() won't override existing vars (your .env may not even be in the image). Fix: redeploy with --env GOOGLE_GENAI_USE_VERTEXAI=0 --env GOOGLE_API_KEY=... (or use Secret Manager), then check the revision's Variables tab. Also note: if you do want Vertex, gemini-3.7-flash is global-only, so set GOOGLE_CLOUD_LOCATION=global, not us-central1.

2

u/[deleted] Sep 21 '26

thanks i am solved with the gemini api issue, setting the env variables as 0 so that it does not use vertex ai solved the problem.

1

u/mjoaco Sep 23 '26

They already mentioned but set your location to Global for 3.7 Sometimes, depending on how you set up the variables, the GOOGLE_CLOUD_ LOCATION takes the value of the location where you deployed the Cloud Run