Skip to content

OpenAI API Proxy: A Fixed IP in a Supported Country

One fixed server IP for your API calls — in a country OpenAI supports, and the same address every time.

Why API calls need the right exit

OpenAI serves its API only in the countries on its supported list. Mainland China, Hong Kong, Macau and Russia are not on it: a request from an unsupported location gets 403 “Country, region, or territory not supported”, and OpenAI warns that access from outside the list may get an account blocked or suspended.

In code, the fix is small. The official Python and Node SDKs both accept a proxy, so only the client you configure sends its API traffic through it, while the rest of the machine stays on its normal network.

A fixed datacenter IP suits calls from scripts and servers: it’s the lowest price per IP, and it stays the same for the whole term. That gives you one fixed address for your project’s IP allowlist — with the allowlist on, OpenAI rejects requests from any other address, even with a valid key.

Datacenter or static ISP for OpenAI?

Scroll horizontally with the arrow keys to read all content.

Datacenter or static ISP for OpenAI?
ItemDatacenter IPStatic ISP IP
What you getA server IP, fixed for the termA home-broadband IP, fixed for the term
PriceUS$3.99 for 30 daysUS$7.99 for 30 days
Best forAPI calls from scripts, servers and agentsA person signing in to ChatGPT in a browser
IP allowlistOne fixed address to addOne fixed address to add

Prices per IP in US dollars, the same in every country; the wallet uses PTC at 1 PTC = US$1. If the same person also uses ChatGPT in a browser, the ChatGPT setup starts from static ISP.

Recommended OpenAI API setup

Scroll horizontally with the arrow keys to read all content.

Recommended OpenAI API setup
ItemChooseWhy
ProductDatacenter proxy, per IPA fixed server address at the lowest price per IP
CountryOne on OpenAI’s supported list, e.g. the US, Japan or SingaporeThe order page shows which countries are in stock
ProtocolHTTPThe examples below use an HTTP proxy URL; the IP keeps the protocol you buy it with
How many IPsOne per server or environmentEach environment keeps its own address on the allowlist
TermRenew before the end dateAuto-renewal isn’t available yet; renewing keeps the same IP, so the allowlist entry stays valid

The button below opens datacenter proxies with the AI setup; Protocol starts on HTTP and Term on 30 days. Pick the country and Quantity (up to 100 at a time) before you pay.

Set up your OpenAI API proxy

  1. Buy a datacenter IP

    The button below opens datacenter proxies with the AI setup. Pick a country on OpenAI’s supported list, keep Protocol on HTTP and Term on 30 days, set Quantity to one IP per server or environment, then click Review cost and generate.

  2. Copy the details

    In My assets, View credentials shows host, port, username and password; Copy all copies them in one go.

  3. Test the route with curl

    Run the three commands below on the machine that will make the calls. The first must show the country you bought; the second should print 401 before you add a key.

    Expected result The third command returns your list of models.

    Before continuing From mainland China the proxy usually can’t be reached directly: on Windows or macOS run the Proxy302 Helper (Connect → Helper tools) and use its local address and port in place of HOST:PORT.

  4. Put the proxy in the SDK

    Use the Python or Node example below. Only the client you configure uses the proxy; other programs on the machine keep their normal network.

  5. Optional: lock the key to this IP

    On platform.openai.com open Settings → Security → IP allowlist, add the exit IP the first command showed and enable the allowlist for the project. Changes take up to 15 minutes; calls from other addresses then fail with 401 ip_not_authorized.

    Before continuing Add every environment that calls the API — CI, staging, your own laptop — before you enable it, or those calls stop.

Test the route with curl

Scroll horizontally with the arrow keys to read all content.

# 1) Exit IP and country of your datacenter IP (HTTP line)
curl -x "http://USERNAME:PASSWORD@HOST:PORT" https://ipinfo.io/json

# 2) Does OpenAI accept this exit? Without a key, 401 = yes, 403 = unsupported country
curl -s -o /dev/null -w "%{http_code}\n" -x "http://USERNAME:PASSWORD@HOST:PORT" \
  https://api.openai.com/v1/models

# 3) With your key: 200 and the list of models
curl -x "http://USERNAME:PASSWORD@HOST:PORT" https://api.openai.com/v1/models \
  -H "Authorization: Bearer $OPENAI_API_KEY"

A 401 without a key means the request reached OpenAI from a supported location; a 403 “Country, region, or territory not supported” means the exit isn’t in a supported country. The third call only lists models, so it’s a safe first test of the key.

Python: OpenAI SDK through the proxy

Scroll horizontally with the arrow keys to read all content.

# pip install -U openai   (reads OPENAI_API_KEY from the environment)
from openai import OpenAI, DefaultHttpx2Client

client = OpenAI(
    http_client=DefaultHttpx2Client(
        proxy="http://USERNAME:PASSWORD@HOST:PORT",  # your datacenter IP, HTTP line
    )
)

for model in client.models.list():
    print(model.id)

Current versions of the OpenAI Python SDK are built on HTTPX2, and DefaultHttpx2Client keeps the SDK’s defaults while adding the proxy (the older DefaultHttpxClient name still works). For SOCKS5, pip install "httpx2[socks]" and use a socks5:// URL.

Node.js: OpenAI SDK through the proxy

Scroll horizontally with the arrow keys to read all content.

// npm install openai undici   (reads OPENAI_API_KEY from the environment)
// Save as check.mjs and run: node check.mjs
import OpenAI from 'openai';
import { fetch, ProxyAgent } from 'undici';

const client = new OpenAI({
  fetch,
  fetchOptions: { dispatcher: new ProxyAgent('http://USERNAME:PASSWORD@HOST:PORT') },
});

for await (const model of client.models.list()) {
  console.log(model.id);
}

As in the OpenAI Node SDK’s proxy instructions: undici’s ProxyAgent as the dispatcher, paired with undici’s own fetch. The username and password in the proxy URL are sent as proxy authentication.

Quick fixes

403 “Country, region, or territory not supported”

Check Does ipinfo.io through the same proxy show a supported country, and does your client actually use the proxy?

Fix Pass the proxy to the client that calls the API, as in the examples, and use an IP in a supported country.

401 ip_not_authorized

Check Is the exit IP on the allowlist that applies to this key? A project allowlist replaces the organization’s.

Fix Add the exit IP to that allowlist, wait up to 15 minutes and test again.

407 from the proxy

Check Is a character missing from the username or password, or has the IP’s term ended?

Fix Copy the details again from My assets and check the end date.

Certificate errors after updating the Python SDK

Check Does the machine have the operating system’s CA certificates? HTTPX2 no longer uses certifi.

Fix Install the CA certificates, or set SSL_CERT_FILE to a CA bundle.

429 rate limit errors

Check How fast is your job sending requests?

Fix Pace the requests and follow the Retry-After header.

OpenAI API proxy FAQ

Can I call the OpenAI API from mainland China, Hong Kong or Russia?

Not from there directly: they aren’t on OpenAI’s supported list, and the API answers 403. A proxy changes your network exit, not OpenAI’s terms — OpenAI warns that access from outside its supported countries may get an account blocked or suspended.

Datacenter or static ISP for the API?

Datacenter for calls from code: a fixed server address at US$3.99 for 30 days. Choose static ISP, US$7.99 for 30 days, when a person signs in to ChatGPT in a browser.

Can I put the IP on OpenAI’s IP allowlist?

Yes. The IP stays the same for the term, so you can add it under Settings → Security → IP allowlist. An allowlist holds up to 50 addresses or ranges, and other addresses are then rejected even with a valid key.

HTTP or SOCKS5?

HTTP is simplest: both SDK examples take an HTTP proxy URL. The Python SDK also works with SOCKS5 once httpx2[socks] is installed. Buy the IP with the protocol you’ll use — each IP keeps one.

Does every program on my computer use the proxy?

No. In the examples only the OpenAI client goes through the proxy; your browser and other programs keep their normal network.

Related guides

Platform access by country

Which countries block Discord, YouTube, Instagram, Telegram and more — and hourly checks showing all 38 platforms reachable through residential IPs in 7 countries.

Check a proxy's IP, country and ISP

Check the exit IP, country and ISP your proxy really gives you in 30 seconds — and why IP databases disagree on the city. With our own test of three lookup services.

Residential vs ISP vs datacenter proxies

What separates rotating residential, static ISP and datacenter proxies — who owns the IP, whether it changes, how you pay — and which one Proxy302's own presets pick for each job.

ChatGPT account bans

Why OpenAI deactivates ChatGPT accounts, how to appeal with your User ID and Org ID, what happens to Plus or Pro after a ban, and what a proxy can’t change.

Proxy302 Helper setup

Use Proxy302 from mainland China: download the free Helper, keep it running, and paste its local address into AdsPower, the Chrome extension or your phone.

Reference links

8
  1. OpenAI: Supported countries and territories

    Official documentation · Confirmed on:

    Read on 21 October 2026: accessing or offering access to OpenAI’s services outside the listed countries and territories may get an account blocked or suspended. The list includes the United States, Canada, the United Kingdom, Germany, the Netherlands, Japan, South Korea and Singapore; mainland China, Hong Kong, Macau and Russia are not on it.

  2. OpenAI API: Error codes

    Official documentation · Confirmed on:

    Read on 21 October 2026: 403 “Country, region, or territory not supported” means the request comes from an unsupported country, region or territory; 401 “IP not authorized” means the request IP doesn’t match the IP allowlist; on 429 rate-limit errors, pace requests and follow the Retry-After header.

  3. OpenAI API: IP allowlist

    Official documentation · Confirmed on:

    Read on 21 October 2026: under Settings → Security → IP allowlist, an allowlist holds up to 50 IP addresses or CIDR ranges; once enabled, requests from other addresses fail with 401 ip_not_authorized even with a valid key; a project allowlist takes precedence over the organization’s; changes take up to 15 minutes; check the address after any proxy.

  4. OpenAI Python SDK: Migrating to HTTPX2

    Official documentation · Confirmed on:

    Read on 21 October 2026 (openai 3.35.1 on PyPI, released 18 October 2026): DefaultHttpx2Client(proxy=...) gives the SDK a proxy while keeping its defaults; the older DefaultHttpxClient name still works; HTTPX2 verifies TLS against the operating-system trust store instead of certifi, and SSL_CERT_FILE points it at a CA bundle.

  5. HTTPX2 docs: Proxies

    Official documentation · Confirmed on:

    Read on 21 October 2026: proxy credentials go in the userinfo part of the proxy URL; SOCKS needs pip install "httpx2[socks]" and a socks5:// URL.

  6. OpenAI Node SDK: Configuring proxies

    Official documentation · Confirmed on:

    Read on 21 October 2026: on Node, pass undici’s fetch and an undici ProxyAgent as fetchOptions.dispatcher; undici options must be paired with undici’s fetch.

  7. undici docs: ProxyAgent

    Official documentation · Confirmed on:

    Read on 21 October 2026: a username and password in the proxy URL are sent as the proxy-authorization header.

  8. Proxy302 product facts

    Product observation · Confirmed on:

    The site's product facts file (productFacts.json, values checked against the console, the backend and the price table on 18–19 October 2026), read on 21 October 2026: static ISP and datacenter IPs are leased per IP and term; each IP keeps the protocol chosen at purchase, HTTP or SOCKS5; Quantity takes up to 100 IPs per order; auto-renewal is not available; there is no free trial; 1 PTC = US$1; a failed IP is reissued after a Support ticket with the order number. Datacenter prices per IP: US$0.25 for 1 day, US$0.75 for 3 days, US$1.75 for 7 days, US$3.99 for 30 days, US$7.98 for 60 days and US$11.97 for 90 days; static ISP US$7.99 for 30 days; the same price in every country. With no platform preset the order page starts on Protocol HTTP and a 30-day term.

Ready to connect?

Create an account, top up once and pick rotating residential, static ISP or datacenter. Rotating residential exits cover 195+ countries and regions.