> ## 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.

# OpenAI API: “unsupported_country_region_territory” (403) — what it means and how to fix it

> The 403 error “Country, region, or territory not supported” (code unsupported_country_region_territory) in the OpenAI API: why OpenAI rejects the request based on location, why it happens even on a cloud server, and how to connect GPT models without this error — by changing the key and the address.

**Short answer:** this error is returned by OpenAI itself when a request to the API comes from a place that isn't on its list of countries. What gets checked is the address the request came from, not the key: a new key or a topped-up balance won't help. For the error to go away, the request has to reach OpenAI 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 GPT models stay the same — no VPN needed.

## What the error looks like

A response with code **403**:

```json theme={null}
{
  "error": {
    "code": "unsupported_country_region_territory",
    "message": "Country, region, or territory not supported",
    "param": null,
    "type": "request_forbidden"
  }
}
```

In the Python SDK it comes as `openai.PermissionDeniedError: Error code: 403` with the same body.

## Why it happens

* **OpenAI checks where the request came from.** If the address belongs to a country that isn't on the [Supported countries and territories](https://developers.openai.com/api/docs/supported-countries) page, the request is rejected before it reaches the model.
* **The error also happens on servers in supported countries.** On OpenAI's developer forum ([example thread](https://community.openai.com/t/cloud-run-in-asia-northeast3-suddenly-getting-unsupported-country-region-territory-error-from-openai-api/1279969)) it was reported from a cloud server in a supported country. In that discussion, OpenAI later fixed it on their side, and changing the cloud region helped one of the users.
* **A VPN is a risky workaround.** On the same page, OpenAI warns that access from countries outside the list may lead to the account being blocked or suspended. The balance you deposited goes away along with the account.

## 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 OpenAI's list | Connect GPT models via RuAPI — steps below |
| Your code is already written for the OpenAI SDK | Don't rewrite anything: only `api_key` and `base_url` change |

## How to connect GPT via RuAPI

**1. Sign up**

Sign up at [www.ruapi.ai](https://www.ruapi.ai/?lng=en\&utm_source=docs\&utm_campaign=en-openai-unsupported-country-region-territory) — 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 Python 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="gpt-6-luna",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(resp.choices[0].message.content)
```

```javascript Node.js theme={null}
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "sk-your-RuAPI-key",
  baseURL: "https://www.ruapi.ai/v1",
});

const resp = await client.chat.completions.create({
  model: "gpt-6-luna",
  messages: [{ role: "user", content: "Hello!" }],
});
console.log(resp.choices[0].message.content);
```

```bash curl theme={null}
curl https://www.ruapi.ai/v1/chat/completions \
  -H "Authorization: Bearer sk-your-RuAPI-key" \
  -H "Content-Type: application/json" \
  -d '{"model": "gpt-6-luna", "messages": [{"role": "user", "content": "Hello!"}]}'
```

You may not need to touch the code at all: many programs read the `OPENAI_API_KEY` and `OPENAI_BASE_URL` environment variables — just set them to your RuAPI key and `https://www.ruapi.ai/v1`. Which GPT models are available and how they differ is covered in the [GPT API guide](https://docs.ruapi.ai/en/gpt-api.md).

## FAQ

> [accordion] Will a new key or topping up my OpenAI balance help?
>
> No. OpenAI checks not the key or the balance but the address the request came from. From the same address, a new key will get the same error.

> [accordion] ChatGPT works in the browser, but the API doesn't. Why?
>
> These are different services with different checks, and a ChatGPT Plus subscription has nothing to do with the API: the API is paid for separately. More in [OpenAI API key: where to get it and how to pay](https://docs.ruapi.ai/en/openai-api-key-russia.md).

> [accordion] The error comes not from my code but from a program (Cursor, n8n, Cline…)
>
> In the program's settings, find the “OpenAI API key” and “Base URL” fields (sometimes “OpenAI-compatible”), and enter your RuAPI key and `https://www.ruapi.ai/v1`. Ready-made guides are in the Integrations section.

> [accordion] Are these the original OpenAI models?
>
> Yes. These are the original models — gpt-6.1-sol, gpt-6-luna, gpt-5.4-mini and others — with no substitution and no quality cuts.

## Next steps

> [card] [OpenAI API key](https://docs.ruapi.ai/en/openai-api-key-russia.md)
>
> Where to get a key and how to pay.

> [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.