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

When calling Gemini Flash API from a Firebase Function I am all of a sudden receiving the error: ‘Generate object error User location is not supported for the API use’ even though there have been no changes to my code. The Firebase Function and app are hosted in the US. I am using the Blaze plan to pay for Gemini. Any guidance on why this has suddenly started happening. FYI, my code works fine running locally.

13 Likes

This happened in one of my apps today as well. Just change the Firebase function server (the default is in us-east)

import { setGlobalOptions } from 'firebase-functions/v2'
setGlobalOptions({ region: 'us-west1' })

you might want to check this Lokalizacje Cloud Functions  |  Cloud Functions for Firebase

2 Likes

i have this same problem and it just broke my entire app i am using gemini API on cloudrun on us-central-1 and it was working just fine then suddenly not working now no idea what to do if anyone knows?

I’m having the same problem. Worked yesterday, today nothing works in either Prod or Dev.
Oddly enough, my local emulator still works. I’m operating in us-central1.

They seemed to have removed it from us-central-1. I deployed a new instance to uswest1 and got it working. Only problem is i have to change the URLs now and that means submitting a new build to ios and android appstores since i didn’t think i needed to worry about the URL needing to be changed.

Hey folks, to be clear, are you using Vertex AI? Or the Gemini api (ai.google.dev)?

I’m using the Gemini API

Same using Gemini API

Facing the same issue here. Got the error first at 9am ET. Still facing this issue.

+1 with the error → Firebase Function us-central1 → was working without problem → today started the issue
the app is live and also submitted to the contest… :frowning:
the error persist using this library @google/generative-ai - npm or a curl
but localhost it works.

3 Likes

I’m pretty shaken up by this from Google - 8 hours since reported and still happening. Just to add to my misery I had just changed the API key so we could get more precise billing, and then everything broke, so there was a few hours wasted today until I found this post.

Incidentally, if you deploy with firebase functions then setting an env var with a region like this
# export FIREBASE_FUNCTIONS_DEFAULT_REGION=us-west1 will shift your function. With a delete and a create though so all your variables will need to be re-entered

I tried that as well but ended up running into CORS errors when I tried it.
And yeah, we just announced our launch a couple weeks ago so it doesn’t look great for Kahuoi :unamused:

1 Like

If it’s any consolation, one of my co-workers who is doing extensive OpenAI integration just started getting snippets of arabic in his responses…

CORS error because the url is updated, you need to change the url in your client app

Changing it to us-west1 from us-west2 fixed the issue for me. Thank you for sharing the solution here. Though I am very disappointing with google for randomly cutting off several US cloud regions from accessing gemini api. They have to do better if they want developers to take gemini api seriously to build production grade apps around it.

1 Like

+1, also noticing this issue in US-Central1 with GenerateObject

1 Like

“8 hours since reported…” Just wonder where it was reported. Is there some official place to report issues like this one? Would like to track it there when it is fixed.

1 Like

I (and others) have reported it on Google Cloud Community, You have to have some sort of enterprise contract before you can submit a support ticket…
One of the links ends up here (lol):

1 Like

Confirming that moving GCP function to us-west1 restores functionality

Gemini API here too. The problem seems to be localized to cloud functions running us-central1 though so switching the function region should do the trick.