Guide
How to get an OpenAI API key (and keep it safe)
Prices checked Nov 26, 2026 · 4 min read

To get an OpenAI API key, sign in to the OpenAI dashboard, open platform.openai.com/api-keys and create a key. Store it as the OPENAI_API_KEY environment variable and never paste it into client-side code. Then add credits, because a key with no balance cannot make paid calls. This guide covers the steps, the safety rules from OpenAI's docs, and the one-key alternative.
Steps to generate an OpenAI API key
OpenAI's quickstart gives the path.
- Create the key. In the OpenAI dashboard, go to platform.openai.com/api-keys and create an API key. Store it somewhere safe.
- Export it. On macOS or Linux, run
export OPENAI_API_KEY="your_api_key_here". On Windows PowerShell the quickstart usessetx OPENAI_API_KEY "your_api_key_here". The SDK reads the variable automatically. - Install an SDK. For Python that is
pip install openai. - Make a call. The OpenAI Python guide has a working example.
Standard keys for application requests live on the API keys settings page. Admin keys, used only for administration endpoints, are created on a separate admin keys page. Do not use an admin key in an app that just generates text.
Why a ChatGPT login is not enough
Searches for "api key chatgpt" often come from people who already pay for ChatGPT. OpenAI's help page is clear: ChatGPT and the API platform have separate billing systems, and API usage is billed separately from your ChatGPT subscription. It adds that eligible subscriptions may come with promotional API credits for a linked API organization. It does not say which ones, so check your own billing page.
For the API you pay from prepaid credits. OpenAI says the minimum first purchase is $5, and purchased credits expire after one year. The full rules, with refunds and tiers, are in our OpenAI credits guide.
How the key is used
OpenAI's API reference says to send the credential with HTTP Bearer authentication in the Authorization header: the word Bearer, a space, then the key. If you belong to more than one organization, or you use a legacy user key to reach projects, add the OpenAI-Organization and OpenAI-Project headers. Usage then counts against that organization and project.
You rarely write the header yourself. The official SDK builds it from OPENAI_API_KEY.
Keep the key out of trouble
OpenAI's guidance, in short:
- Treat the key as a secret. Do not share it.
- Do not put it in client-side code such as a browser app or a mobile app.
- On a server, load it from an environment variable or a key management service.
- A revoked key stops working within a few seconds, so revoke at once if one leaks.
Two habits worth adding. Use one key per app, so you can revoke one without breaking the others. And never commit a .env file: add it to .gitignore before the first commit.
The same steps for a TapModels key
TapModels is a separate service. We do not issue OpenAI keys, and our key works on our endpoint only: https://api.tapmodels.com/v1. What it gives you is one key for GPT, Claude, Gemini and Grok chat models plus image, video and audio models, billed from one prepaid balance.
| OpenAI key | TapModels key | |
|---|---|---|
| Created in | OpenAI dashboard, API keys page | TapModels dashboard, Keys page |
| Works on | OpenAI's API | api.tapmodels.com/v1 |
| Sent as | Authorization: Bearer | Authorization: Bearer sk_live_... |
| Billing | OpenAI prepaid credits | TapModels credits, 100 per $1 |
| Shown again later | Check the dashboard when you create it | No: the secret is returned once, when you create it |
On our side you can add a spend limit to a key (spend_limit_credits) and restrict it to certain models (allowed_models). A leaked key with a limit of 500 credits can lose you at most $5.00, because the limit stops further spend with a 402 key_limit_reached error. New accounts start at 0 credits, so add credits before the first call.
What a first call costs
Say your first test sends 1,000 input tokens and gets 300 tokens back from GPT-6.2 Sol. OpenAI lists that model at $2.00 per 1M input tokens and $10.00 per 1M output tokens on its pricing page. The test costs 1,000 x $2.00 / 1,000,000 = $0.002 for input plus 300 x $10.00 / 1,000,000 = $0.003 for output, so $0.005. On TapModels the catalog price is $0.60 in and $3.00 out per 1M tokens, so the same call costs $0.0006 + $0.0009 = $0.0015.
A key costs nothing to create. What costs money is the tokens you send. If you are comparing both routes, how much the OpenAI API costs has a full monthly example.
When to stay with OpenAI directly
If you need OpenAI's own invoices, its data terms or an enterprise agreement, create the key with OpenAI. If you want several providers behind one key, or a lower price per token, a reseller layer such as ours can fit. The tradeoffs are covered in how to evaluate a third-party provider. Next step: create your key on the TapModels docs page walkthrough.
Frequently asked questions
Where do I create an OpenAI API key?
OpenAI's quickstart says to create an API key in the OpenAI dashboard at platform.openai.com/api-keys and store it somewhere safe. Standard keys for application requests are made on the API keys settings page. Admin keys, used for administration endpoints, are created on a separate admin keys page.
Is a ChatGPT Plus subscription the same as an API key?
No. OpenAI says ChatGPT and the API platform have separate billing systems, and API usage is billed separately from your ChatGPT subscription. You need an API key and a paid API balance to call the API, even if you already pay for ChatGPT.
How do I send my OpenAI API key with a request?
Send it as HTTP Bearer authentication in the Authorization header, with the value Bearer followed by the key. The official SDKs read it from the OPENAI_API_KEY environment variable automatically, so most code never touches the header directly.
Is it safe to put an API key in a website or mobile app?
No. OpenAI says to treat the key as a secret and keep it out of client-side code such as browsers or mobile apps. Load it on the server from an environment variable or a key management service, and revoke it if it leaks.
Does a TapModels key work on OpenAI's API?
No. TapModels does not issue OpenAI keys. A TapModels key works on the TapModels endpoint only, at api.tapmodels.com/v1. It calls GPT and other models through an OpenAI-compatible chat route, billed from your prepaid TapModels credits.
Sources
- OpenAI API quickstart · checked Nov 26, 2026
- OpenAI API reference: authentication · checked Nov 26, 2026
- OpenAI help: billing settings in ChatGPT vs Platform · checked Nov 26, 2026
- OpenAI help: prepaid billing · checked Nov 26, 2026