API response is "User location is not supported for the API use." what can I do?

Hello,

I’ve tried to call below
generativeModel.generateContent(prompt)

My environment is Android/Kotlin, the response is below:

com.google.ai.client.generativeai.type.ServerException: Unexpected Response:
{
“error”: {
“code”: 400,
“message”: “User location is not supported for the API use.”,
“status”: “FAILED_PRECONDITION”
}
}

Nothing has changed in the code or location, and it was working fine before.
I created a different key and tried it, but the result is the same.

Is there anything I can check?

Heyy! Welcome to the forums!
Depending on laws and availability where you live, you might not be allowed to access Google’s AI Studio or other APIs and Services.

For a complete list of countries that can use Google’s AI services, check here!