Hi everyone,
I’m running into an issue where my application successfully calls the Gemini API when testing locally (in preview mode), but fails completely once deployed to Google Cloud Run.
Here is the context of the problem:
-
Local/Preview Environment: The API calls to Gemini work perfectly. Responses are generated as expected without any latency or connection drops.
-
Production Environment (Cloud Run): The container deploys successfully and the service is live, but any function that attempts to call the Gemini API fails
Troubleshooting steps I’ve already tried:
-
Verified that the
GEMINI_API_KEYis correctly set in the Cloud Run Environment Variables/Secrets. -
Ensured that the Cloud Run service account has the necessary permissions (if applicable).
-
Checked standard network egress settings to ensure Cloud Run can make outbound calls to external APIs.
Has anyone experienced this discrepancy between local testing and Cloud Run deployments with the Gemini API? Are there specific network configurations, VPC settings, or IAM roles required for Cloud Run to successfully reach the Google AI Studio endpoints?
Any guidance or pointers would be greatly appreciated!