Look closely at an OpenAI API key and you'll learn almost nothing. It's a string of random characters that starts with sk-. It won't tell you whether it works, whether there's credit behind it or which models it can reach. Two keys can look identical and be worlds apart.
That's why, when you buy an OpenAI API key, you're really buying proof: proof that the key is accepted, proof that its account has credit and a way out if something goes wrong. The string of characters is the easy part.
This guide shows you how to spot that proof on a listing, buy in minutes, set the key up in the tools you already use, test it properly and keep track of every token you spend.
In short
- An OpenAI API key is a secret code your apps send with each request; the credit lives on the account behind it.
- On AI Token, look for three green lights: Key checked with a recent time, a price per thousand tokens below the live list price and a size that fits your work.
- Checkout takes minutes: pay in USDT or USDC on Solana, paste the transaction signature and reveal your key in My Tokens.
- Set the key as
OPENAI_API_KEYand OpenAI's SDKs, Codex and most tools pick it up automatically. - Test with a free model list call, then one small request on the exact model you plan to use.
- You get the key, not the account dashboard, so log the
usagenumbers from every response.
What an OpenAI API key is (and isn't)
An API key is a password for software. Your code sends it with every request, and OpenAI uses it to know which account to bill. The credit sits on that account, and each request draws it down by the tokens it uses. A token is a small piece of text, often part of a word.
A key from AI Token is a genuine OpenAI API key. It talks straight to OpenAI's API, works with OpenAI's own SDKs and slots into any tool that asks for an "OpenAI API key". There's no special endpoint and no base URL to change.
It is not a ChatGPT login. A ChatGPT subscription and API access are separate products; ChatGPT Plus vs API credits explains who needs which.
One detail experts keep in mind: OpenAI lets account owners scope keys and projects, for example to certain models or endpoints. That's why your own first test should use the exact model you plan to build on, as you'll see below.
How to read an OpenAI API key listing before you buy
Open the OpenAI listings on the marketplace and look for three green lights.
Green light one: the key status
Every listing shows its key status and when it was last checked. Key checked means AI Token asked OpenAI two things and got good answers. First, it requested the key's model list, which is free. Then it sent one tiny test request, paid for by the seller's account, to confirm the account still has credit.
That check runs when the key is listed, again when you check out and once more right before handover. Keys that OpenAI rejects and keys whose account has no credit left can't be sold, so you can't end up paying for a dud. Prefer listings marked Key checked with a recent check time.
Green light two: the price per thousand tokens
Each listing shows its price per thousand tokens and its total. Open the live model prices, refreshed every few minutes, and compare the listing with OpenAI's own rate for the model you'll use. The gap is your saving.
Green light three: the right size
Match the token quantity to your workload. The token estimator turns sample prompts into token counts, so you can buy enough for the job without overbuying. Remember that output tokens cost several times more than input tokens, and that reasoning models also spend hidden "thinking" tokens, billed as output.
Finally, read the seller's description and note which coin the listing is priced in, USDT or USDC. That's the coin you'll send.
Buy an OpenAI API key in minutes: the checkout
- Sign in with email, Google or Apple. No ID documents.
- Choose Proceed to payment on your listing. The summary shows the tokens, the small platform fee and exactly what you'll pay.
- Enter the Solana wallet you'll pay from and confirm it by QR scan or by typing it again.
- Send the exact amount in the listing's coin, on the Solana network, from that same wallet. Paying straight from an exchange doesn't match, because exchange withdrawals come from the exchange's own address.
- Paste the transaction signature from your wallet or Solscan. AI Token verifies it on Solana automatically.
- Reveal your key in My Tokens. It's checked with OpenAI once more before it's released to you.
Your payment is then held for a protection period before the seller is paid. If the key stops working in that time, click Report a problem: the seller's payout is paused and you can be refunded.
First time with stablecoins? Buy AI tokens with crypto explains wallets and networks step by step. Comparing routes before you commit? How to buy OpenAI credits puts card, crypto and marketplace side by side.
Set up your OpenAI API key in the tools you use
The golden rule: keep the key out of your code. OpenAI's production best practices recommend environment variables or a secrets manager, and the SDKs are built around that.
As an environment variable
On macOS or Linux, add this line to your shell profile (for example ~/.zshrc or ~/.bashrc):
export OPENAI_API_KEY="sk-your-key"
On Windows, run setx OPENAI_API_KEY "sk-your-key", then open a fresh terminal. setx only reaches windows opened after it runs, which catches out a lot of people.
In a project's .env file
For a single project, put OPENAI_API_KEY=sk-your-key in a file called .env and load it with a library such as python-dotenv. Then add .env to your .gitignore before your first commit, so the key never lands in your repository.
In the OpenAI SDKs
As OpenAI's quickstart notes, every OpenAI SDK reads OPENAI_API_KEY from the environment by itself. In Python, install with pip install openai and create a client with no arguments. In JavaScript, install with npm install openai and do the same.
In Codex and other tools
OpenAI's coding agent, Codex, can sign in with an API key instead of a ChatGPT account. From the command line, printenv OPENAI_API_KEY | codex login --with-api-key does it in one go, and usage is billed to the key's credit.
Editors, chat apps and automation tools usually have a settings field labeled "OpenAI API key". Paste the key there and leave any "base URL" setting at OpenAI's default.
Never in the browser
Don't put the key in front-end code, a mobile app or a public notebook. Anyone can read it there. Keep it on your server and let your front end talk to your server.
Test your key before you build on it
A smart first test costs nothing. Listing models uses no tokens:
from openai import OpenAI
client = OpenAI() # reads OPENAI_API_KEY
for model in client.models.list():
print(model.id)
If model IDs scroll past, the key is accepted. Then send one small request with client.responses.create, using the exact model you plan to build on. If it answers, you're ready.
If it doesn't, the error tells you what to do:
- Invalid or incorrect API key. Usually a copy problem: a missing character, a trailing space or stray quote marks. Copy it again from My Tokens.
- Model not found or no access. The key can't reach that model. Pick one from the list your test printed.
- Rate limit reached. You're sending too fast. Wait and retry with growing pauses, as OpenAI's rate limit guide describes.
- Insufficient quota. The account behind the key has run out of credit. Retrying won't fix it, so use Report a problem while your protection is active.
Do this the moment you reveal the key. The protection period is your safety net, and the best time to use a safety net is while it's up.
Track usage without a dashboard
Here's the thing most buyers miss: when you buy a key, you get the key, not the account's billing dashboard. So build your own meter. It's easier than it sounds, because every response already tells you what it cost.
- Read the
usageobject. In the Responses API it holdsinput_tokensandoutput_tokens, and its detail fields addcached_tokens(input billed at a lower rate) andreasoning_tokens(counted as output). Chat Completions names themprompt_tokensandcompletion_tokens. - Log it with every request. Save the model name and the token counts. Multiply by the rates on the live model prices page and you know your spend to the token.
- Watch the headers. Responses carry rate limit headers such as
x-ratelimit-remaining-requestsandx-ratelimit-remaining-tokens, so your app can slow down before it hits a wall. - Forecast your runway. The credit run-out calculator shows when a balance will run out at your current pace, so you can buy the next key before you need it.
Mistakes that waste a good key
- Committing the key. Add
.envto.gitignorefirst, and never paste the key into code. - Misspelling the variable. It must be exactly
OPENAI_API_KEY. A typo means the SDK can't find your key. - Forgetting the fresh terminal on Windows after running
setx. - Capping output too tightly on reasoning models. If the cap is too low, the model can spend it all on thinking and return no answer, and you still pay for the thinking.
- Testing a different model from the one you'll use. Your first real request should match your real workload.
- Testing late. Test right after you reveal the key, while protection is active.
FAQ
Is a key from AI Token a real OpenAI API key?
Yes. It's a genuine OpenAI key that calls OpenAI's API directly, with OpenAI's own SDKs and tools. AI Token checks it with OpenAI when it's listed, at checkout and right before handover.
Which GPT models can I use with it?
The ones the key's account can reach. Run a free model list call to see them, then test the model you plan to use before you build on it.
How do I know how much credit is left?
Use the listing's token quantity as your starting point and log the usage from every response. The credit run-out calculator turns that into a forecast.
Can I use the key with Codex or my editor?
Yes. Codex supports signing in with an API key, and most editors and chat apps have a field for an OpenAI key. Leave any base URL at OpenAI's default.
Do I need a credit card or ID documents?
No. You pay with USDT or USDC on Solana from your own wallet, and no ID documents are needed.
What if the key stops working?
During the protection period, click Report a problem. The seller's payout is paused while the team looks into it, and you can be refunded.
The bottom line
A key is just a string. A good key comes with proof that it works, a price below the list and a safety net while you test it. That's what every OpenAI listing on AI Token gives you. Prefer to try models in your browser first? The playground runs on your purchased tokens. When you're ready to build, browse OpenAI keys on AI Token, pay in minutes and send your first request before your coffee cools.