> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ruapi.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Gemini API: “User location is not supported for the API use” — what it means and how to fix it

> The 400 FAILED_PRECONDITION error “User location is not supported for the API use” in the Gemini API: why Google rejects the request based on location, why it happens even on a cloud server, and how to connect Gemini without this error — by changing the key and the address.

**Short answer:** this error is returned by Google itself when a request to the Gemini API comes from a place that isn't on its list of regions. What gets checked is the address the request came from, not the key: a new key or a new project won't help. For the error to go away, the request has to reach Google from an address other than yours. That's exactly how it works with a RuAPI key: you change the key and the address in your code, and the Gemini models stay the same — no VPN needed.

## What the error looks like

```json theme={null}
{
  "error": {
    "code": 400,
    "message": "User location is not supported for the API use.",
    "status": "FAILED_PRECONDITION"
  }
}
```

In the SDK it comes as an exception with code 400 and the same text: `User location is not supported for the API use.`

## Why it happens

* **Google checks where the request came from.** If the address belongs to a region that isn't on the [Available regions for Google AI Studio and Gemini API](https://ai.google.dev/gemini-api/docs/available-regions) list, the request is rejected before it reaches the model.
* **The error also happens on servers in supported countries.** This is reported on Google's developer forum ([example](https://discuss.ai.google.dev/t/gemini-api-returns-failed-precondition-user-location-is-not-supported-for-the-api-use/190618)).
* **A VPN is an unreliable workaround.** Google blocks many VPN addresses too, and keeping a server running a program that needs Gemini behind a VPN is inconvenient.

## What you can do

| Situation | What to do |
| - | - |
| The server is in a supported country, but the error still appears | Check where the server's address is detected (`curl ipinfo.io`), change the cloud region or the internet egress |
| You yourself are in a region that isn't on Google's list | Connect Gemini via RuAPI — steps below |
| Your code is already written for google-genai | Don't rewrite anything: the same RuAPI key works in Google's format too; only `api_key` and `base_url` change |

## How to connect Gemini via RuAPI

**1. Sign up**

Sign up at [www.ruapi.ai](https://www.ruapi.ai/?lng=en\&utm_source=docs\&utm_campaign=en-gemini-user-location-not-supported) — with email, Google or Yandex.

**2. Top up**

Console → **Wallet**: USDT or USDC (TRC20 / BEP20 / Polygon; USDT also on TON), from 5 USDT. No USDT yet? [Buy it with rubles via SBP (Faster Payments System)](https://docs.ruapi.ai/en/buy-usdt.md). Cards from foreign banks (Visa / Mastercard) are accepted too.

**3. Key**

Console → **API Keys** → **Create API key** — you'll get an `sk-...` string.

**4. Update your code**

Change the key and the address — the rest of the code stays as it was.

```python google-genai (previously for Google) theme={null}
from google import genai

client = genai.Client(
    api_key="sk-your-RuAPI-key",
    http_options={"base_url": "https://www.ruapi.ai"},  # no /v1beta
)

response = client.models.generate_content(
    model="gemini-3.8-flash",
    contents="Hello!",
)
print(response.text)
```

```python OpenAI SDK theme={null}
from openai import OpenAI

client = OpenAI(
    api_key="sk-your-RuAPI-key",
    base_url="https://www.ruapi.ai/v1",
)

resp = client.chat.completions.create(
    model="gemini-3.8-flash",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(resp.choices[0].message.content)
```

```bash curl theme={null}
curl "https://www.ruapi.ai/v1beta/models/gemini-3.8-flash:generateContent" \
  -H "x-goog-api-key: sk-your-RuAPI-key" \
  -H "Content-Type: application/json" \
  -d '{ "contents": [{ "parts": [{ "text": "Hello!" }] }] }'
```

Which Gemini model to choose (Argon, Flash, Flash-Lite, Pro) is covered in the [Gemini API guide](https://docs.ruapi.ai/en/gemini-api.md).

## FAQ

> [accordion] Will a new key or a new project in AI Studio help?
>
> No. Google checks not the key but the address the request came from. From the same address, a new key will get the same error.

> [accordion] Is this the same error as “not available in your region” in AI Studio?
>
> The cause is the same; only the place differs: in AI Studio it's a message on the page, in the API it's a 400 response. There's a separate article about AI Studio: [Google AI Studio: not available in your region](https://docs.ruapi.ai/en/google-ai-studio-russia.md).

> [accordion] Is this the original Gemini?
>
> Yes. These are Google's original models — gemini-4-argon, gemini-3.8-flash and others — with no substitution and no quality cuts.

## Next steps

> [card] [Gemini API without a VPN](https://docs.ruapi.ai/en/gemini-api-russia.md)
>
> Connect in three steps, with Python and curl examples.

> [card] [RuAPI error codes](https://docs.ruapi.ai/en/errors.md)
>
> 400, 401, 403, 429 — what they mean and how to fix them.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.