Fix Gemini API 400 "User location is not supported"
When the Gemini API returns 400 "User location is not supported", find where requests leave from and check it against the official regions list.
User location is not supported for the API use.The response is HTTP 400 with status FAILED_PRECONDITION. In the official error table, failed_precondition (400) means a prerequisite is not met, such as billing being disabled; with this message, the missing prerequisite is location. The key is not wrong and no quota is exhausted, so resending the same request gives the same result. The troubleshooting page says not to retry client errors such as 400.
[1] Find out where the request leaves from. The location that matters may be the machine making the API call, not your own computer. For Colab, the official regions page says "Region restrictions are applied based on the region that the Colab instance is in, not the region that the user is in." and tells you to check the instance with !curl ipinfo.io. That sentence is about Colab. How a cloud server or container is judged is not stated in the docs.
[2] Compare that location with the list on the Available regions page. It says the Gemini API and Google AI Studio are available in "the following countries and territories". South Korea, Singapore, the United States, Japan, the United Kingdom, and India are on it. Hong Kong, China, and Russia were not on the list when this was checked. The list can change, so open the page itself.
[3] If the location is not on the list, move where the call runs. For a server, use a server or region on the list. For users outside the supported regions, the same page points to the Gemini API in Gemini Enterprise Agent Platform. Its terms and pricing are not covered here.
[4] If the location is on the list and you still get the error, follow the checklist from a staff reply. In one forum thread a staff member, without pinning down a single cause, suggested:
- Confirm you are in a supported region.
- Turn off any VPN, proxy, or iCloud Private Relay and connect directly.
- Confirm you are 18 or older and have verified your age.
- Try a different network, such as a phone hotspot.
- If none of that works, submit the location issue report form.
[5] Know that the error has been reported from listed locations too. In another forum thread, a user got this error from a cloud server in Singapore and said the same code worked after moving the server to Europe. Singapore is on the list above. That thread has no official explanation, and the reason could not be confirmed in the docs. Treat the move as a single user's report.