I'm trying to use the Google Generative AI gemini-pro
model with the following Python code using the Google Generative AI Python SDK:
import google.generativeai as genai
import os
genai.configure(api_key=os.environ['GOOGLE_CLOUD_API_KEY'])
model = genai.GenerativeModel('gemini-pro')
response = model.generate_content('Say this is a test')
print(response.text)
I'm getting the following error:
User location is not supported for the API use.
I've searched the official documentation and a few Google GitHub repositories for a while but haven't found any location restrictions stated for API usage. I live in Austria, Europe.
Full traceback:
Traceback (most recent call last):
File "C:\Users\xxxxx\Desktop\gemini-pro.py", line 7, in <module>
response = model.generate_content('Say this is a test')
File "C:\Users\xxxxx\AppData\Local\Programs\Python\Python310\lib\site-packages\google\generativeai\generative_models.py", line 243, in generate_content
response = self._client.generate_content(request)
File "C:\Users\xxxxx\AppData\Local\Programs\Python\Python310\lib\site-packages\google\ai\generativelanguage_v1beta\services\generative_service\client.py", line 566, in generate_content
response = rpc(
File "C:\Users\xxxxx\AppData\Roaming\Python\Python310\site-packages\google\api_core\gapic_v1\method.py", line 131, in __call__
return wrapped_func(*args, **kwargs)
File "C:\Users\xxxxx\AppData\Roaming\Python\Python310\site-packages\google\api_core\retry.py", line 372, in retry_wrapped_func
return retry_target(
File "C:\Users\xxxxx\AppData\Roaming\Python\Python310\site-packages\google\api_core\retry.py", line 207, in retry_target
result = target()
File "C:\Users\xxxxx\AppData\Roaming\Python\Python310\site-packages\google\api_core\timeout.py", line 120, in func_with_timeout
return func(*args, **kwargs)
File "C:\Users\xxxxx\AppData\Roaming\Python\Python310\site-packages\google\api_core\grpc_helpers.py", line 81, in error_remapped_callable
raise exceptions.from_grpc_error(exc) from exc
google.api_core.exceptions.FailedPrecondition: 400 User location is not supported for the API use.
EDIT
I finally found the "Available regions". It's the last item in the sidebar. As of today, Austria is not on the list. I clicked through Google websites, and there were no location restrictions stated. At least on the official Gemini webpage, they could have added an asterisk somewhere to indicate that it is not available everywhere in the world.
The Gemini API and Google AI Studio are available in the following countries and territories:
Algeria American Samoa Angola Anguilla Antarctica Antigua and Barbuda Argentina Armenia Aruba Australia Azerbaijan The Bahamas Bahrain Bangladesh Barbados Belize Benin Bermuda Bhutan Bolivia Botswana Brazil British Indian Ocean Territory British Virgin Islands Brunei Burkina Faso Burundi Cabo Verde Cambodia Cameroon Caribbean Netherlands Cayman Islands Central African Republic Chad Chile Christmas Island Cocos (Keeling) Islands Colombia Comoros Cook Islands Côte d'Ivoire Costa Rica Curaçao Democratic Republic of the Congo Djibouti Dominica Dominican Republic Ecuador Egypt El Salvador Equatorial Guinea Eritrea Eswatini Ethiopia Falkland Islands (Islas Malvinas) Fiji Gabon The Gambia Georgia Ghana Gibraltar Grenada Guam Guatemala Guernsey Guinea Guinea-Bissau Guyana Haiti Heard Island and McDonald Islands Honduras India Indonesia Iraq Isle of Man Israel Jamaica Japan Jersey Jordan Kazakhstan Kenya Kiribati Kyrgyzstan Kuwait Laos Lebanon Lesotho Liberia Libya Madagascar Malawi Malaysia Maldives Mali Marshall Islands Mauritania Mauritius Mexico Micronesia Mongolia Montserrat Morocco Mozambique Namibia Nauru Nepal New Caledonia New Zealand Nicaragua Niger Nigeria Niue Norfolk Island Northern Mariana Islands Oman Pakistan Palau Palestine Panama Papua New Guinea Paraguay Peru Philippines Pitcairn Islands Puerto Rico Qatar Republic of the Congo Rwanda Saint Barthélemy Saint Kitts and Nevis Saint Lucia Saint Pierre and Miquelon Saint Vincent and the Grenadines Saint Helena, Ascension and Tristan da Cunha Samoa São Tomé and Príncipe Saudi Arabia Senegal Seychelles Sierra Leone Singapore Solomon Islands Somalia South Africa South Georgia and the South Sandwich Islands South Korea South Sudan Sri Lanka Sudan Suriname Taiwan Tajikistan Tanzania Thailand Timor-Leste Togo Tokelau Tonga Trinidad and Tobago Tunisia Türkiye Turkmenistan Turks and Caicos Islands Tuvalu Uganda United Arab Emirates United States United States Minor Outlying Islands U.S. Virgin Islands Uruguay Uzbekistan Vanuatu Venezuela Vietnam Wallis and Futuna Western Sahara Yemen Zambia Zimbabwe
I've looked at multiple sources and all signs point to the same issue: You're likely in a location where the generative AI isn't supported. While you're using the new Gemini Pro, the API is very similar to the previous iteration "PaLM", and they likely have the same regional limitations.
https://www.googlecloudcommunity.com/gc/AI-ML/When-has-europe-access-to-PALM-and-Makersuite/m-p/644100
Error message (FailedPrecondition: 400 User location is not supported for the API use.) when using the 51GB Google Colab runtime and Palm API
EU tends to have stringent laws and regulations around new technology, so it usually takes longer for these things to roll out there to give companies time to work out the legal boundaries. (E.g does our AI produce copyrighted works when prompted).