Short answer
Country, region, or territory not supported is OpenAI refusing the request because of where it comes from, not because of your key or account. OpenAI checks the location of the IP address the request arrives from, and if it is not on its list of supported countries and territories, it answers with HTTP 403 before it even looks at your API key. Changing the key, topping up the account or reinstalling the SDK will not help. You either send the request from a supported location, or you send it to an API gateway that is reachable from where you are and forwards it to the model for you.
What the error looks like
The raw response from api.openai.com:
{
"error": {
"code": "unsupported_country_region_territory",
"message": "Country, region, or territory not supported",
"param": null,
"type": "request_forbidden"
}
}
The HTTP status is 403 Forbidden. In the official Python and Node SDKs it surfaces as a PermissionDeniedError (403) that contains the same JSON. Codex CLI reports it as a 403 Forbidden with the same message, and chatgpt.com itself answers with 403 from the same locations.
We reproduced it on 19 October 2026 from a server in Hong Kong: a request with no API key at all got exactly this response. That is the quickest proof that the key is not the problem.
Why it happens
OpenAI publishes the list of countries and territories where its API is offered. Requests from anywhere else are refused, and the same page warns that accessing the services from outside the list may get the account blocked or suspended. Among the places not on the list (checked on 19 October 2026) are mainland China, Hong Kong, Macau and Russia.
What counts is the location of the IP address the request comes from, which is not always where you are:
| Situation | Why you get the error |
|---|---|
| You are in an unsupported country or territory | Your own connection is the request origin |
| Your server or CI runner is in an unsupported region (for example a Hong Kong cloud region) | The request comes from the server's IP, wherever you sit |
| A VPN, proxy or corporate gateway exits in an unsupported location | OpenAI sees the exit IP, not yours |
| Your proxy settings apply to the browser but not to the terminal | The SDK or Codex connects directly, from your real location |
How to fix it
1. Check where your requests actually come from
Run this from the same machine, terminal or container that makes the API call:
curl https://ipinfo.io/country
It prints a two-letter country code (for example HK). If that country is not on OpenAI's list, that is your answer. On a server, also check the cloud region; on a laptop, check whether HTTPS_PROXY / HTTP_PROXY are set in the shell that runs your code.
2. If you are in a supported country, fix the route
Move the workload to a cloud region in a supported country, or point the proxy exit to one. Do not try to disguise access from an unsupported location: OpenAI's terms allow it to block the account, and you lose the balance with it.
3. If you are in an unsupported location, use a gateway
An API gateway accepts your request on its own domain and forwards it to the model. Your code only changes the base URL and the key; the request format stays OpenAI-compatible. TeamoRouter is such a gateway: GPT-6 and other OpenAI models, plus Claude and Gemini, on one balance at https://api.teamorouter.cn, with no OpenAI account needed.
OpenAI Python SDK
from openai import OpenAI
client = OpenAI(
api_key="sk-teamo-...", # key from the TeamoRouter dashboard
base_url="https://api.teamorouter.cn/v1",
)
resp = client.responses.create(model="gpt-6-sol", input="Hello")
print(resp.output_text)
curl
curl https://api.teamorouter.cn/v1/responses \
-H "Authorization: Bearer $TEAMOROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "gpt-6-sol", "input": "Hello"}'
Codex CLI — put this in ~/.codex/config.toml and set the key in OPENAI_API_KEY:
model_provider = "teamorouter"
model = "gpt-6-sol"
[model_providers.teamorouter]
name = "TeamoRouter"
base_url = "https://api.teamorouter.cn/v1"
env_key = "OPENAI_API_KEY"
wire_api = "responses"
Other tools follow the same idea; see the API integration guide and the Codex setup guide.
Paying without an OpenAI account
You top up a balance in the TeamoRouter dashboard and pay only for the tokens you use; there is no subscription. The minimum top-up is $5. You can pay by card.
FAQ
Does this error mean my OpenAI account is banned? No. It is returned before authentication, so it says nothing about the account. Account problems show up as different errors, and only once the request is allowed through.
Will a VPN fix it? If the exit node is in a supported country, the request will usually pass. But OpenAI's terms say access from outside supported countries can get the account suspended, so this is a risk to the account and its balance, not a fix.
Why does it work in the browser but fail in my code? Browser proxy extensions and system proxy settings often do not apply to terminal programs. Run the ipinfo.io check from the terminal that runs your code.
Is unsupported_country_region_territory the same as a 429? No. A 429 means the request was accepted but you hit a rate limit or ran out of quota. The 403 means the request was refused because of its origin.
I see this error in Codex. What should I change? The base URL, through model_provider in config.toml as shown above. Logging in with a ChatGPT account will not work from an unsupported location either.
Related
- Codex request blocked? Why it happens and how to fix it
- Gemini API "User location is not supported": the same kind of block on Google's API