An OpenAI API key is issued in the OpenAI platform (the API keys page), and only the account owner has the right to do it. When a payment is refused, there are two ways forward. The first is to repair the payment instrument on OpenAI's side, which takes a card from a bank in a country that OpenAI supports. The second is to get a key from an intermediary that offers OpenAI models through a compatible API. That is a different deal with a different service, not an OpenAI key. The sections below explain how the two paths differ and when each one fits.
Where OpenAI creates the key
By the OpenAI quickstart, the steps are these.
- Go to
platform.openai.com/api-keys. The quickstart leads there through the "Create an API Key" link. - Issue a secret key and save it at once: OpenAI's help page says the full key is displayed only one time, at creation. A lost key cannot be recovered, so you create a new one and swap it into your app.
- Set the
OPENAI_API_KEYenvironment variable:export OPENAI_API_KEY="your_key"on macOS and Linux,setx OPENAI_API_KEY "your_key"on Windows. OpenAI's libraries pick it up with no extra setup.
A ChatGPT subscription and the API live apart, with separate billing. OpenAI's billing page states that API credits belong to an API organization and do not depend on a ChatGPT subscription. A paid ChatGPT plan does not open the API by itself, and the reverse is true as well. There is one exception: holders of Pro (the $100, $200 and $500 tiers) and of Business workspaces with paid seats may activate monthly API credits for a linked API organization once the plan has been active for at least 7 days. Billing stays separate anyway, Plus does not take part, and availability depends, in OpenAI's words, on the country and the enabled cohort. Anyone searching for "chatgpt api key" or "openai api key" lands in the same place, the API console, not in the chat settings.
OpenAI put its key-safety rules on a page of their own, and it pays to follow them from the start. A key is personal to each teammate (the Terms of Use forbid sharing it). It has no place in browser or mobile code or in a repository. New keys should get an expiry date and be rotated on a schedule.
API balance and prepaid billing
A new API account first buys credits, then spends them on requests. Open the organization's billing, click Add payment details and enter an amount. The minimum is $5 and the default is $10. Auto-reload is on from the start of setup, so if you do not want automatic charges, switch it off. After a purchase the balance sometimes takes a few minutes to update.
What else the prepaid-billing page says:
- Purchased credits live for one year, OpenAI cannot extend that, and there is no refund. The page names exceptions: a verified billing error, confirmed unauthorized charges, a service failure or a wrong account restriction on OpenAI's side, plus cases where law or contract requires a refund.
- The ceiling on your balance depends on your trust tier, which is computed from usage and payment history.
- If the account holds free credits, those go first.
- When credits run out, the API returns a billing error,
credit_balance_exhausted.
Why a payment gets declined
In the help article "Why was my credit card declined?", OpenAI singles out three groups of causes. Its content as of 10 November 2026 follows.
| Cause | What the page says | What to check |
|---|---|---|
| The bank declined | banks sometimes block online or international payments by default, and OpenAI usually does not receive a detailed reason | card details and billing address, the 3-D Secure prompt, a call to the bank |
| A prepaid card | prepaid cards cannot buy API credits, only standard credit or debit cards | the card type with your issuer, since many virtual cards are prepaid |
| Region or issuing bank | purchases work only in supported countries, and the card must be issued by a bank in one of them | OpenAI's country list |
The countries where OpenAI works are listed on the page "OpenAI API - Supported Countries and Territories", and on 10 November 2026 it has 208 entries. Among them are Kazakhstan, Armenia, Georgia, Uzbekistan, Turkey, the UAE, India, Nigeria, Pakistan, Indonesia, the Philippines, Mexico, Brazil, Vietnam and Egypt. Russia, Belarus and China are missing. OpenAI keeps no list of unsupported countries at all: if you are not on the list, the API is not supported there. The same page cautions that reaching the services from a country outside the list is risky, and the account may be blocked or suspended.
Your country is on the list but the card still fails: look for the cause in the first two rows of the table. Your country is not on the list: no card setting helps. No way to fake a country or a card is offered here, because by OpenAI's own page that can cost you the account. The dependable way out of a regional refusal is one: a card from a bank in a supported country. Where to get one is not discussed in this article.
What an OpenAI-compatible key is
A service is called OpenAI-compatible if it understands requests in OpenAI's API format: a path like /v1/chat/completions, an Authorization: Bearer <key> header, the usual model and messages fields. The openai library then keeps working with no code changes, and only base_url and the key change.
| OpenAI key | codexkey gateway key | |
|---|---|---|
| Issued by | OpenAI | codexkey |
| Created in | OpenAI platform, API keys page | codexkey dashboard, API Keys section |
| API address | https://api.openai.com/v1 | https://api.codexkey.online/v1 |
| Key format | whatever the OpenAI platform issues | sk_cdx_... |
| Payment | prepaid from $5, card from a bank in a supported country | top-up from $1: cards from Russia, SBP, crypto |
| Terms | OpenAI's agreement and policies | codexkey's terms plus the policies of the model providers |
| Models | OpenAI's catalog | GPT, Claude, Gemini, DeepSeek and others behind one key |
The two are not interchangeable: an sk_cdx_... key will not open api.openai.com, and an OpenAI key will not fit the gateway's address.
There are two reasons to look at a compatible key. One is about payment, covered above: a provider that takes SBP (the Russian Faster Payments System), cards from Russia or crypto removes the card step. The other has nothing to do with payments: you want one key and one balance across several model families so you can compare them on your own tasks. On 10 November 2026 the catalog at GET /v1/models holds gpt-6-astra, gpt-6.1-sol, gpt-6.1-terra, gpt-6-sol, gpt-6-luna, gpt-5.6-sol, gpt-5.6-terra, gpt-5.6-luna and the image models gpt-image-2, gpt-image-2-5, gpt-image-2-6, with Claude and other families alongside. The catalog changes, so check the models page for the current list and prices.
How to connect a gateway key
You can sign up with a login and password, or with Google, GitHub or Telegram. A top-up from $1 is accepted by card from Russia (YooKassa or Platega), by SBP and in crypto through CryptoCloud, CryptoBot or the 2328 service (USDT, BTC, ETH, TON). For people outside Russia, crypto does not depend on a bank, and Pay for API access with crypto: when it beats a card explains when it is the better choice. After the top-up, create a key in the API Keys section. Both kinds of keys, Anthropic's and ours, are compared in Claude Console and the Claude API key: how to get one and where to paste it.
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.codexkey.online/v1",
api_key=os.environ["CODEXKEY_API_KEY"],
)
reply = client.chat.completions.create(
model="gpt-6-sol",
messages=[{"role": "user", "content": "What separates a 401 from a 403? Two sentences."}],
)
print(reply.choices[0].message.content)
The same in Node and TypeScript:
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.CODEXKEY_API_KEY,
baseURL: "https://api.codexkey.online/v1",
});
const reply = await client.chat.completions.create({
model: "gpt-6-sol",
messages: [{ role: "user", content: "What separates a 401 from a 403? Two sentences." }],
});
console.log(reply.choices[0].message.content);
From here, comparing models is an edit of one word: change the model string and leave the rest. A finished app only needs its variables swapped: OPENAI_BASE_URL gets https://api.codexkey.online/v1, plus the key and the model ID. Checking the key itself takes a request that fails without one. GET /v1/models will not do: on 10 November 2026 it served the catalog with no key and with a made-up one. A short chat call on a cheap model does ask for the key:
curl -s -w "\nHTTP %{http_code}\n" https://api.codexkey.online/v1/chat/completions \
-H "Authorization: Bearer $CODEXKEY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "gpt-5.6-luna", "messages": [{"role": "user", "content": "Reply with one word: ok"}]}'
A working key returns HTTP 200 and a reply, while a wrong or missing one returns HTTP 401 and authentication_error; that is how the gateway answered on the same date with no key and with a made-up one. The call costs the usual amount: at the catalog rate of that date ($0.04 per 1M input and $0.20 per 1M output tokens for gpt-5.6-luna), a fraction of a cent. Model IDs are still easiest to take from the catalog, curl https://api.codexkey.online/v1/models, which is a quick reference.
A client complains about an unknown model: most often it is a typo in the ID or a base URL without /v1. Moving an existing codebase off the OpenAI SDK is covered in OpenAI-compatible API: switch providers with one line.
OpenAI's rules for intermediaries from 20 November 2026
On 21 October 2026 OpenAI updated its Usage Policies, and the new edition takes effect on 20 November 2026. The help page lists four changes, and one of them introduces approval for intermediaries that provide access to models. In the policy it is the section "Providing access to our models": if you operate an intermediary platform or another service through which third parties work with OpenAI models directly, you need OpenAI's prior review and approval. A product where OpenAI models are merely built in as one feature is not covered by the rule on that ground.
The phrase "a service through which third parties access OpenAI models" fits gateways too, codexkey included. The decision belongs to OpenAI, and it makes it per service. Neither criteria nor a list of approved services appears in the policy text or in the help page on the update (state of 10 November). We do not retell anyone else's status, and we do not promise that access to OpenAI models through any intermediary stays as it is. If your product rests on it, ask the provider how it handles the new rules, and prepare a fallback: models from another family in the same catalog, or a direct account if your country and bank allow it.
Before paying, study the provider's catalog and terms. Listings change. A model listed today may be gone tomorrow.
What a gateway does not replace
- An OpenAI account and agreement. Organizations, projects, trust tiers, limits, invoices for accounting and OpenAI support belong only to the owner of an OpenAI account.
- Features outside codexkey's documentation. It describes
POST /v1/chat/completions,GET /v1/models, image and video generation, and the Responses format for Codex. For Realtime, fine-tuning and Assistants the comparison with OpenAI in the docs points to OpenAI itself, and there is no documentation for Batch, so treat it as unavailable until you test it. - ChatGPT subscriptions and chat. codexkey sells only the API, with no ChatGPT plans and no web chat. Chat and plans are covered in ChatGPT in Russia: what is known in 2026 and how to avoid clones.
- Your company's requirements. A security policy that insists on a direct contract with the model vendor will not admit an intermediary, however convenient the payment is.
Which route to take
| Situation | What fits |
|---|---|
| You hold a card from a bank in a supported country and want an agreement with OpenAI | an OpenAI key from the platform |
| You need local payments or crypto, or several model families behind one key | an OpenAI-compatible gateway, with the rules above in mind |
| You want the ChatGPT chat with voice and files | a ChatGPT subscription, a different product |
| You need Realtime, fine-tuning or Assistants | OpenAI directly |
| Your code is written for the OpenAI SDK and you want to test another model | change base_url, starting with the GPT-6 and GPT-5.6 comparison |
Codex CLI and keys get a separate breakdown: Codex CLI with an API key instead of a ChatGPT plan.
FAQ
Where do I get an OpenAI or ChatGPT API key?
Open the OpenAI platform and go to the API keys page. A ChatGPT subscription and the API are separate: the key is created in an API account and paid for there. A subscription is not required for it, although eligible Pro and Business plans can activate API credits for a linked API organization.
Why is my card declined for the OpenAI API?
OpenAI names three causes: the bank blocked the payment, the card is prepaid, or a bank outside a supported country issued it. Start with the card type and issuer, then check the country list.
How do I pay for the OpenAI API from Russia?
Russia is not on the list of countries where OpenAI supports the API, and the card has to come from a bank in a supported country. No way to fake a country or a card is offered here. Instead of a direct account, a gateway key fits: it is paid for separately and works under different terms.
Is there a free OpenAI API key?
The prepaid-billing page describes no free tier. It says only that free credits on an account, if there are any, are spent first. You can see whether you have some on the billing page.
Can I buy an OpenAI API key from someone?
A key is issued by the account owner in the platform. OpenAI's help page plainly calls sharing keys a breach of the Terms of Use. A key bought from a reseller is tied to someone else's account and can be revoked at any moment.
How is a gateway key different from an OpenAI key?
A different service issues it, it works only at that service's address, and it is paid for under that service's rules. The request format is compatible, while the agreement and policies are not.
Will a codexkey key work with the openai library?
Yes. You need base_url set to https://api.codexkey.online/v1 and the key sk_cdx_.... Take the model ID from the catalog.