Generate object error User location is not supported for the API use

Same issue here. Using Firebase cloud functions from us-central1.

Getting this error:

Error generating embeddings: GoogleGenerativeAIFetchError: [GoogleGenerativeAI Error]: Error fetching from https://generativelanguage.googleapis.com/v1beta/models/text-embedding-004:embedContent: [400 Bad Request] User location is not supported for the API use.

What should we do @Logan_Kilpatrick? Should we switch regions to something else or will it be fixed sometime soon? Thankfully my app isn’t publicly launched yet.

I retract my previos claim about regions.
I have updated my function so it is hosted in several regions [‘us-central1’, ‘europe-west1’, ‘us-west1’];
All the listed regions report the same issue:

Error fetching from https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent: [400 Bad Request] User location is not supported for the API use.

Can it be related to the GCP billing instance location. My country - Lithuania - is listed among supported countries, but perhaps there was some sort of update?

The same issue here - when running from Cloud Function in us-central1 - Gemini API.
Moving to us-west1 solved the issue, but it would be great to get an update on when this will be resolved.

1 Like

Any feedback would be nice, even if it’s just naming the correct place to report this issue

2 Likes

@Logan_Kilpatrick replied - so he is aware of the issue, and he’s certainly one of the right people to raise the issue inside Google.

2 Likes

A general question for everyone:
Is the API Key you’re using just for the free tier, or is it attached to a billing account?

I am using free tier API Key

I’m using a billed account. As others have mentioned, switching the region helps. If free tier would be the reason, I think all regions would be affected.

1 Like

Not necessarily. There are some regions (and by this I mean Gemini API regions) where paid-tier access is allowed, but not free-tier access.

1 Like

It’s not the free tier. We’re paid but we still got whacked.

2 Likes

We’re working internally on a fix. In the meantime, I would be wary of removing your us-central1 function unless you are confident that your users will upgrade their apps quickly. You could make your us-central1 function proxy to your us-west1 function to keep old clients happy.

8 Likes

So glad I came across this discussion thread. Was going crazy trying to figure out why my GCP Cloud Run function (in us-central1) calling Gemini AI API suddenly stopped working. Am I to understand that I need to move my GCP function to us-west1? Is that a temporary workaround?

As Thomas said, there is a fix that is in the works.

Moving the function to another region if you can do this quickly and the rest of your operations won’t be impacted could be considered a temporary workaround, yes. This isn’t feasible in many cases because the endpoint might be hardcoded in your app or webapp. As Thomas suggested, you may wish to setup a proxy in us-central1 as part of your workaround in such cases.

2 Likes

change in frontend const functions = getFunctions(app, ‘us-west1’); // see pass like this

example

const app = initializeApp(firebaseConfig);

const auth = getAuth(app);

const googleProvider = new GoogleAuthProvider();

// Specify the region when initializing the Functions instance

const functions = getFunctions(app, ‘us-west1’);

const db = getFirestore(app);

// Example usage: calling a cloud function

const endTest = httpsCallable(functions, ‘handleIELTSSpeakingTestV’);

// Now, when you call endTest, it will be routed to the correct region (us-west1).

export { auth, googleProvider, db, functions };

Hey everyone, thanks so much for your patience here. This issue should be fixed now. Please let me know if you’re still running into any issues accessing the Gemini API from a GCP service located in us-central1.

5 Likes

Thank u! Working for me now!

1 Like

Confirm working on us-central1. Any explanation for the outage?

us-west2 was not working until 5 hours ago, but it is working fine now.

When i faced this issue, i thought it was my fault… So i spent 5h :joy:

Hey Chris, there was an issue that affected the IP mapping for a set of instances.

1 Like