OpenAI API Not Available in Your Country:
Key, URL, Code

The OpenAI API isn't offered everywhere and its billing declines many cards. How to get a key, set the endpoint, compare official prices and fix errors.

Updated 13 min read

If OpenAI doesn’t offer its API where you are, or official billing keeps declining your card, you can still call GPT models through an OpenAI-compatible API. Get an API key from a provider such as Brioi, change the base URL to https://vip.brioi.com/v1, and the rest of your code stays the same as with the official SDK. This guide covers the key, the endpoint, sample code, model choice, official prices and common errors.

Based on OpenAI’s official docs, supported-countries page and pricing page (checked 2026-11). API use is billed by actual usage.

Where the OpenAI API is offered

OpenAI publishes a list of supported countries and territories for the API and warns that using or providing access from outside that list may get your account blocked or suspended. When we checked in 2026-11, the list did not include Russia, Belarus, Iran, mainland China, Hong Kong, Macau, Syria, Cuba, Venezuela or North Korea. Calls to the official API from an unsupported location return 403 Country, region, or territory not supported (OpenAI error codes).

Being on the list doesn’t guarantee you can pay. OpenAI’s help center says API credits can only be bought with a standard credit or debit card, prepaid cards aren’t accepted, and declines often come from the card issuer blocking international charges (Why was my credit card declined?). Teams in countries such as Vietnam, Turkey and parts of Latin America often report declines even though the API is offered there.

So there are two routes:

Route What you need Good for
Official OpenAI API An account in a supported country, a card OpenAI accepts Teams whose company and users are in supported countries
OpenAI-compatible API (e.g. Brioi) One API key, topped up with USDT or an international card Teams where the official API isn’t offered, or whose cards are declined

Brioi offers an OpenAI-compatible API that works in regions where the official API isn’t offered. It picks the best route automatically and bills by actual usage. Enterprise pricing is about 10–50% of the official price, and one balance also covers Claude, Gemini, Seedance and other models.

ChatGPT subscriptions and the API are separate

Many people searching for a “ChatGPT API key” expect a ChatGPT subscription to include API access. They are two products with separate billing:

ChatGPT subscription (Plus, Pro, etc.) OpenAI API
What it’s for Chat, images and Codex in the web and mobile apps Calling models from your own code
How it’s billed Fixed monthly fee; Plus is $20/month Per token, no monthly fee
API key included No Yes, created on the API platform

OpenAI’s help center says ChatGPT and the API platform have separate billing systems, and API credits belong to an API organization, separate from any ChatGPT subscription. Some eligible subscriptions (Pro and some Business workspaces) can claim promotional API credits for a linked API organization. Plus doesn’t qualify. Those credits still fall under the API’s terms, including the supported-countries rule above.

Sources: Managing billing for ChatGPT and the API platform, What is ChatGPT Plus? (checked 2026-11).

How to get an API key

With Brioi:

  1. Create an account on the main site and top up with USDT or an international card.
  2. Open the API keys page and click to create a key. Name it after your project, e.g. my-app.
  3. Choose the default group. It includes every GPT model recommended below.
  4. Save, copy the key and store it in an environment variable or a secrets manager.

The group decides which models the key can use and how they are billed. Besides default, GPT models are also available in these groups:

Group Description
GPT | Official OpenAI official route
GPT | Azure Azure GPT text route

Groups don’t all carry the same models. The pricing page has the current list.

Base URL and endpoints

Item Value
Base URL https://vip.brioi.com/v1
Auth Header Authorization: Bearer YOUR_API_KEY
Chat Completions POST /v1/chat/completions
Responses POST /v1/responses
Model list GET /v1/models

In the SDK, base_url must end in /v1, and /v1 must appear only once.

Check which models your key can use. The model in your requests must come from this live list:

curl "https://vip.brioi.com/v1/models" \
  -H "Authorization: Bearer YOUR_API_KEY"

Chat Completions example

Chat Completions is the most common format, and most open-source projects and frameworks support it. The answer is in choices[0].message.content.

curl:

curl "https://vip.brioi.com/v1/chat/completions" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-6.1-terra",
    "messages": [
      {"role": "system", "content": "You are a concise technical assistant."},
      {"role": "user", "content": "Explain what an API is in one sentence."}
    ]
  }'

Python. Install the official SDK first:

pip install openai

Put the key in an environment variable (macOS, Linux):

export BRIOI_API_KEY="YOUR_API_KEY"

On Windows, run setx BRIOI_API_KEY "YOUR_API_KEY" in PowerShell, then open a new terminal.

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["BRIOI_API_KEY"],
    base_url="https://vip.brioi.com/v1",
)

completion = client.chat.completions.create(
    model="gpt-6.1-terra",
    messages=[
        {"role": "system", "content": "You are a concise technical assistant."},
        {"role": "user", "content": "Explain what an API is in one sentence."},
    ],
)

print(completion.choices[0].message.content)

Responses example

Responses is the API OpenAI now leads with; its quickstart uses it, and Codex calls models through it. According to OpenAI’s model pages, tool calling on GPT-6.1 Sol and GPT-6.1 Terra requires the Responses API, and on GPT-6 Sol and GPT-6 Luna, Chat Completions supports function calling only with reasoning_effort set to none. For new projects, start with Responses.

curl:

curl "https://vip.brioi.com/v1/responses" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-6.1-terra",
    "instructions": "You are a concise technical assistant.",
    "input": "Explain what an API is in one sentence."
  }'

Python:

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["BRIOI_API_KEY"],
    base_url="https://vip.brioi.com/v1",
)

response = client.responses.create(
    model="gpt-6.1-terra",
    instructions="You are a concise technical assistant.",
    input="Explain what an API is in one sentence.",
)

print(response.output_text)

Which one to use:

Chat Completions Responses
Request shape messages array input, with the system prompt in instructions
Reading the result choices[0].message.content output_text
Good for Existing projects and frameworks built on it New projects, tool calls and multi-step tasks

Moving an existing project over from the official API usually takes two changes: api_key becomes your Brioi key, and base_url becomes https://vip.brioi.com/v1.

Switch with environment variables, no code changes

When no arguments are passed, the official Python SDK reads the key from OPENAI_API_KEY and the base URL from OPENAI_BASE_URL. If your project already uses client = OpenAI(), setting these two variables is enough to switch to Brioi:

export OPENAI_API_KEY="YOUR_API_KEY"
export OPENAI_BASE_URL="https://vip.brioi.com/v1"
from openai import OpenAI

client = OpenAI()  # reads the two environment variables above

response = client.responses.create(
    model="gpt-6.1-terra",
    input="Reply with BRIOI_OK only.",
)
print(response.output_text)

Many OpenAI-compatible tools and frameworks read the same two variables. Check each tool’s docs.

Streaming

Chat interfaces usually show text as it is generated. With Chat Completions, add stream=True and read delta.content chunk by chunk:

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["BRIOI_API_KEY"],
    base_url="https://vip.brioi.com/v1",
)

stream = client.chat.completions.create(
    model="gpt-6.1-terra",
    messages=[{"role": "user", "content": "Write three short product update notes."}],
    stream=True,
)

for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)
print()

Some chunks have no choices (the final usage chunk, for example), so check before reading.

Multi-turn conversations

The API doesn’t remember earlier turns. With Chat Completions you send the history each time (create client as above):

messages = [{"role": "system", "content": "You are a concise technical assistant."}]

for question in ["How do I read a JSON file in Python?", "What if the file is very large?"]:
    messages.append({"role": "user", "content": question})
    completion = client.chat.completions.create(
        model="gpt-6.1-terra",
        messages=messages,
    )
    answer = completion.choices[0].message.content
    messages.append({"role": "assistant", "content": answer})
    print(answer)

The history counts as input tokens on every turn. For long conversations, keep the last few turns or summarize earlier ones before sending.

Timeouts and retries

By default the official Python SDK times out a request after 10 minutes and retries certain errors twice. High reasoning effort and long outputs can run past that, so raise the timeout when you create the client:

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["BRIOI_API_KEY"],
    base_url="https://vip.brioi.com/v1",
    timeout=1200,
    max_retries=2,
)

For 429 and 5xx, retry with backoff (a longer wait each time). For 401, 403 and 400, retrying won’t help; check the error table below first.

Which GPT model to use

All of these models are in Brioi’s default group and support both Chat Completions and Responses. The descriptions come from OpenAI’s model pages.

Model OpenAI’s description Good for
gpt-6-astra Most capable, for the most demanding work Hard reasoning, research, long documents
gpt-6.1-sol Near-Astra performance at a lower cost Complex coding, agents, professional work
gpt-6.1-terra Fast and efficient; visual reasoning and clear writing Everyday Q&A, content, reading screenshots and diagrams
gpt-6-luna Most efficient, for focused high-volume tasks Classification, extraction, batch jobs at high concurrency
gpt-5.6-sol, gpt-5.6-terra, gpt-5.6-luna The previous generation’s three tiers Projects with prompts already tuned for GPT-5.6

OpenAI’s docs suggest GPT-6 Astra if you aren’t sure where to start. To keep costs down, try gpt-6.1-terra first and move to gpt-6.1-sol or gpt-6-astra if the results aren’t good enough. The four GPT-6 models have a 1.05M-token context window and up to 128K output tokens.

Source: OpenAI models (checked 2026-11).

OpenAI API pricing

The official OpenAI API bills per token. Standard tier, short context (up to 272K input tokens per request), USD per million tokens:

Model Input Cached input Output
gpt-6-astra 10.00 1.00 50.00
gpt-6.1-sol 2.00 0.10 10.00
gpt-6.1-terra 1.00 0.05 5.00
gpt-6-luna 0.10 0.01 0.50
gpt-6-sol 2.00 0.20 10.00
gpt-5.6-sol 4.00 0.40 20.00
gpt-5.6-terra 2.00 0.20 12.00
gpt-5.6-luna 0.20 0.02 1.20
gpt-5.5 5.00 0.50 30.00

Notes from OpenAI’s pricing page:

  • Requests with more than 272K input tokens use long-context rates: input and cached input double, output is 1.5×.
  • Batch costs half of Standard. Fast mode (formerly Priority processing) is 2× Standard for the GPT-6 and GPT-5.6 families.
  • gpt-5.6-sol is on promotional pricing, which OpenAI says runs until November 30, 2026.
  • Reasoning models bill their reasoning tokens as output tokens, so output usage is higher than the visible answer.

Sources: OpenAI API pricing, OpenAI reasoning guide, checked 2026-11.

Through Brioi, billing is also per token with no monthly fee. Enterprise pricing is about 10–50% of the official price, and every model and route is priced on the pricing page.

Tracking usage and controlling cost

Every response includes a usage field with the tokens used:

API Input Output Reasoning tokens
Chat Completions usage.prompt_tokens usage.completion_tokens usage.completion_tokens_details.reasoning_tokens
Responses usage.input_tokens usage.output_tokens usage.output_tokens_details.reasoning_tokens
print(response.usage)  # Responses object; for Chat Completions use completion.usage

Ways to keep the bill down:

  • Start with a cheaper model. For classification, extraction and rewriting, gpt-6-luna or gpt-6.1-terra is often enough.
  • Cap output length. Use max_output_tokens in Responses and max_completion_tokens in Chat Completions. The cap includes reasoning tokens, so set it too low and the model may stop before it answers.
  • Use the prompt cache. OpenAI caches repeated prompt prefixes and bills cache hits at the cached-input rate, far below normal input. For GPT-5.6 and later, writing to the cache costs 1.25× the normal input rate (30-minute lifetime), so caching pays off on long prompts you reuse. Put fixed system prompts and reference material first and the changing parts last. Per OpenAI’s docs, GPT-5.6 and later cache only prefixes of at least 1,024 tokens.
  • Check usage in the Brioi dashboard, where you can separate projects by key.

Source: OpenAI prompt caching (checked 2026-11).

API or ChatGPT subscription: which costs less?

They solve different problems, so start with what you need:

  • To chat or write in the web or mobile app yourself, use a ChatGPT subscription.
  • To call models from your own site, app, script or workflow, you need the API. Subscriptions don’t include an API key.

To compare spend, estimate the API cost at official prices. Say you run 1,000 requests on gpt-6.1-terra, each with 2,000 input tokens and 500 output tokens:

  • Input: 1,000 × 2,000 = 2M tokens at $1 per million = $2.
  • Output: 1,000 × 500 = 500K tokens at $5 per million = $2.50.
  • About $4.50 in total. Reasoning tokens add a little to the output side.

For programs with light, regular usage, pay-per-token API is usually cheaper than a fixed monthly fee. For heavy workloads, estimate tokens this way and then pick the model.

Common errors

Symptom Cause and fix
401, Invalid token Key missing, copied incompletely or disabled. Check the header is Authorization: Bearer YOUR_API_KEY and the environment variable is set
403 Balance or quota used up, or the key has no access to this model or group. Check the balance and the key’s group
503 model_not_found The key’s group doesn’t include this model. Check GET /v1/models or switch groups
404 Invalid URL (POST /v1/v1/...) /v1 appears twice in base_url. Use https://vip.brioi.com/v1
SDK parse error and the response is HTML base_url is missing /v1, so the request hit a web page. Add /v1
400 Bad parameters or malformed JSON. Check model, messages or input
429 Too many requests. Lower concurrency and retry after a pause
500, 502 Temporary server error. Retry later
403 Country, region, or territory not supported This comes from the official OpenAI API, so your requests are still going to api.openai.com. Check base_url and the OPENAI_BASE_URL variable

Error messages end with a request id, and responses carry an X-Oneapi-Request-Id header. When you report a problem, send the request id and the error text, never the key. Error codes are listed in the Brioi API docs (in Chinese).

Security

  • Keep keys in server-side environment variables or a secrets manager. Never put them in front-end code, app bundles or public repositories.
  • Don’t paste keys into group chats, ticket screenshots or public logs.
  • Create one key per project so you can disable each one and track its usage separately.
  • If you suspect a leak, disable the key on the Brioi API keys page right away and create a new one.

If you write code with Codex, see the Codex setup guide.

FAQ

How do I get an OpenAI API key if the API isn’t offered in my country?

ChatGPT subscriptions don’t come with an API key, and official keys only work in supported countries. Create a key on the Brioi API keys page, choose the default group, and set the base URL to https://vip.brioi.com/v1.

Can I get an OpenAI API key without a US credit card?

Official API billing accepts standard credit and debit cards, not prepaid cards, and many non-US cards are declined by the issuer. Brioi takes USDT or an international card on the main site, and one balance covers GPT, Claude, Gemini, Seedance and other models.

Does ChatGPT Plus include API access?

No. OpenAI bills API usage separately from ChatGPT subscriptions, and Plus doesn’t include API usage or the API credit benefit.

What is the OpenAI API base URL?

The official base URL is https://api.openai.com/v1. With Brioi, use https://vip.brioi.com/v1. The paths are the same as the official API, such as /v1/chat/completions and /v1/responses.

Is an OpenAI-compatible endpoint the same as the official API?

The request and response formats are the same, so the official SDK works by changing api_key and base_url. Requests go through Brioi’s gateway to upstream routes, and Brioi bills you instead of OpenAI. Brioi isn’t affiliated with OpenAI.