Skip to content

Fixing the “User Location is Not Supported” Error with the Gemini API

    Since its launch, developers have encountered frustrating errors about “User location not supported” when trying to use Google’s powerful new Gemini API. This stems from Google not having enabled Gemini access globally yet. Certain regions like the EU, Africa, and parts of Asia cannot directly call the API at present.

    When your user location is not supported, you may see errors like:

    400 User location is not supported for the API use

    This guide will explore the main causes of this error and some possible workarounds until Google expands availability.

    Why Does This Error Occur?

    There are two key reasons you may encounter this error with the Gemini API:

    1. Google has not enabled API access in your country yet

    As of December 2022, Gemini is only available in a limited set of regions including the US, Canada, parts of Europe, India, Australia, and more.

    If you check the enabled APIs in your Cloud Console and don’t see the Generative AI API, your location is likely unsupported currently.

    2. Your code is inadvertently routing requests through an unsupported region

    Some platforms like Vercel deploy functions globally by default. So even if you are in a supported country, your requests could get routed through servers in an unsupported region, triggering the error.

    You can inspect your code to check if the API endpoint or edge function location is set to a region that Gemini is not enabled in yet.

    Possible Workarounds

    While waiting for expanded access, developers have come up with some tricky workarounds like:

    Using a VPN

    Setting up a VPN connection to a supported country will make your requests appear to come from there. Some popular options are NordVPN, ExpressVPN, and Surfshark.

    Downsides: Adds cost, latency, and may violate Terms of Service.

    Switching Region via Vertex AI Library

    The Vertex AI library allows selecting a region, unlike the main Generative AI SDK:

    # Set region like us-central1
    vertexai.init(project=PROJECT, location=LOCATION, credentials=google_credentials)

    model = GenerativeModel(“gemini-pro”)

    Downsides: More complex setup, may still have functionality restrictions based on actual location.

    Deploying Proxy Service

    On Vercel, you can deploy the Palm Proxy service and route your API requests through it to a supported region.

    Downsides: Hacky workaround, no guarantee Google won’t block in future.

    Identifying Your User Location

    To check if your calls are coming from an unsupported area, use:

    • Cloud Console – Check Enabled APIs and locations
    • Code Inspector – Print and validate API endpoint location
    • GEOIP Service – Get your public IP’s approximate location

    When Will Access Expand?

    Google has stated they are working on rolling out Gemini to more regions soon. Broad availability may take some time due to regulatory hurdles.

    The workarounds discussed can help cover the gap for now, but may come with limitations. There is no guarantee you will get full functionality in unsupported regions even with proxy methods.

    I hope this gives some clarity on why the “User location is not supported” error occurs and potential temporary solutions while we await expanded access. Let me know if you have any other questions!